NUnit.Framework.Assert.Fail(string)

Here are the examples of the csharp api NUnit.Framework.Assert.Fail(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

327 Examples 7

19 Source : ConfigurationFactory.CanLoadAndSaveXmlTest.cs
with MIT License
from alexleen

[SetUp]
        public void SetUp()
        {
            IConfigurationXml configFactory = new ConfigurationFactory(Subsreplacedute.For<IToastService>()).Create(Filename);

            const string sutFieldName = "LoadAndSave";

            mSut = (ICanLoadAndSaveXml)configFactory.GetType().GetField(sutFieldName, BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(configFactory);

            if (mSut == null)
            {
                replacedert.Fail($"Unable to find private instance field '{sutFieldName}'");
            }

            mXmlDoc = Subsreplacedute.For<IXmlDoreplacedent>();

            IXmlDoreplacedentFactory xmlDocFactory = Subsreplacedute.For<IXmlDoreplacedentFactory>();
            xmlDocFactory.Create().Returns(mXmlDoc);

            SetSutField("mXmlDocFactory", xmlDocFactory);

            IFile file = Subsreplacedute.For<IFile>();
            file.Exists(Filename).Returns(ci => mFileExists);

            SetSutField("mFile", file);

            mXmlWriterFactory = Subsreplacedute.For<IXmlWriterFactory>();
            SetSutField("mXmlWriterFactory", mXmlWriterFactory);

            //Subsreplacedute fileStreamFactory to avoid disk access attempts
            IFileStreamFactory fileStreamFactory = Subsreplacedute.For<IFileStreamFactory>();
            SetSutField("mFileStreamFactory", fileStreamFactory);
        }

19 Source : MSRFile.Test.cs
with MIT License
from Autodesk

[Test]
        public void MSRFileEmptyFileTest()
        {
            try
            {
                Geometry.MSRFile msrFile =
                    new Geometry.MSRFile(AppDomain.CurrentDomain.BaseDirectory +
                                         "\\..\\..\\TestFiles\\MSRTestFiles\\Empty File.msr",
                                         true);
            }
            catch (Exception ex)
            {
                replacedert.Preplaced(ex.Message);
            }
            replacedert.Fail("Failed to throw exception");
        }

19 Source : MSRFile.Test.cs
with MIT License
from Autodesk

[Test]
        public void MSRFileNoDataTest()
        {
            try
            {
                Geometry.MSRFile msrFile =
                    new Geometry.MSRFile(AppDomain.CurrentDomain.BaseDirectory + "\\..\\..\\TestFiles\\MSRTestFiles\\No Data.msr",
                                         true);
            }
            catch (Exception ex)
            {
                replacedert.Preplaced(ex.Message);
            }
            replacedert.Fail("Failed to throw exception");
        }

19 Source : MSRFile.Test.cs
with MIT License
from Autodesk

[Test]
        public void MSRFileOddCharactersTest()
        {
            try
            {
                Geometry.MSRFile msrFile =
                    new Geometry.MSRFile(AppDomain.CurrentDomain.BaseDirectory +
                                         "\\..\\..\\TestFiles\\MSRTestFiles\\Odd Characters.msr",
                                         true);
            }
            catch (Exception ex)
            {
                replacedert.Preplaced(ex.Message);
            }
            replacedert.Fail("Failed to throw exception");
        }

19 Source : MSRFile.Test.cs
with MIT License
from Autodesk

[Test]
        public void MSRFileDuplicateControlCharacterTest()
        {
            try
            {
                Geometry.MSRFile msrFile =
                    new Geometry.MSRFile(AppDomain.CurrentDomain.BaseDirectory +
                                         "\\..\\..\\TestFiles\\MSRTestFiles\\Extra Ordinate.msr",
                                         true);
            }
            catch (Exception ex)
            {
                replacedert.Preplaced(ex.Message);
            }
            replacedert.Fail("Failed to throw exception");
        }

19 Source : MSRFile.Test.cs
with MIT License
from Autodesk

[Test]
        public void MSRFileMissingG800Test()
        {
            try
            {
                Geometry.MSRFile msrFile =
                    new Geometry.MSRFile(
                        AppDomain.CurrentDomain.BaseDirectory + "\\..\\..\\TestFiles\\MSRTestFiles\\Missing G800 Line.msr",
                        true);
            }
            catch (Exception ex)
            {
                replacedert.Preplaced(ex.Message);
            }
            replacedert.Fail("Failed to throw exception");
        }

19 Source : MSRFile.Test.cs
with MIT License
from Autodesk

[Test]
        public void MSRFileMissingG801Test()
        {
            try
            {
                Geometry.MSRFile msrFile =
                    new Geometry.MSRFile(
                        AppDomain.CurrentDomain.BaseDirectory + "\\..\\..\\TestFiles\\MSRTestFiles\\Missing G801 Line.msr",
                        true);
            }
            catch (Exception ex)
            {
                replacedert.Preplaced(ex.Message);
            }
            replacedert.Fail("Failed to throw exception");
        }

19 Source : MSRFile.Test.cs
with MIT License
from Autodesk

[Test]
        public void MSRFileLineNumberErrorTest()
        {
            try
            {
                Geometry.MSRFile msrFile =
                    new Geometry.MSRFile(
                        AppDomain.CurrentDomain.BaseDirectory + "\\..\\..\\TestFiles\\MSRTestFiles\\Line Number Error.msr",
                        true);
            }
            catch (Exception ex)
            {
                replacedert.Preplaced(ex.Message);
            }
            replacedert.Fail("Failed to throw exception");
        }

19 Source : MSRFile.Test.cs
with MIT License
from Autodesk

[Test]
        public void MSRFileTwoEndsTest()
        {
            try
            {
                Geometry.MSRFile msrFile =
                    new Geometry.MSRFile(AppDomain.CurrentDomain.BaseDirectory + "\\..\\..\\TestFiles\\MSRTestFiles\\TwoEnds.msr",
                                         true);
            }
            catch (Exception ex)
            {
                replacedert.Preplaced(ex.Message);
            }
            replacedert.Fail("Failed to throw exception");
        }

19 Source : MSRFile.Test.cs
with MIT License
from Autodesk

[Test]
        public void MSRFileTwoEndsTogetherTest()
        {
            try
            {
                Geometry.MSRFile msrFile =
                    new Geometry.MSRFile(AppDomain.CurrentDomain.BaseDirectory + "\\..\\..\\TestFiles\\MSRTestFiles\\TwoEndsOK.msr",
                                         true);
                replacedert.That(msrFile.Points.Count, Is.EqualTo(6));
            }
            catch (Exception ex)
            {
                replacedert.Fail(ex.Message);
            }
            replacedert.Preplaced("Failed to throw exception");
        }

19 Source : PMToolpathsCollectionTest.cs
with MIT License
from Autodesk

[Test]
        public void CreateRibMachiningToolpathTest()
        {
            if (_powerMILL.Version.Major >= PMEnreplacedy.POWER_MILL_2016.Major)
            {
                var toolpath = _powerMILL.ActiveProject.Toolpaths.CreateRibMachiningToolpath();
                replacedert.AreEqual("1", toolpath.Name);
            }
            else
            {
                try
                {
                    var toolpath = _powerMILL.ActiveProject.Toolpaths.CreateRibMachiningToolpath();
                    replacedert.Fail("Exception wasn't thrown");
                }
                catch (Exception)
                {
                    replacedert.Preplaced();
                }
            }
        }

19 Source : PMToolpathsCollectionTest.cs
with MIT License
from Autodesk

[Test]
        public void CreateBladeMachiningToolpathTest()
        {
            if (_powerMILL.Version.Major >= PMEnreplacedy.POWER_MILL_2016.Major)
            {
                var toolpath = _powerMILL.ActiveProject.Toolpaths.CreateBladeMachiningToolpath();
                replacedert.AreEqual("1", toolpath.Name);
            }
            else
            {
                try
                {
                    var toolpath = _powerMILL.ActiveProject.Toolpaths.CreateBladeMachiningToolpath();
                    replacedert.Fail("Exception wasn't thrown");
                }
                catch (Exception)
                {
                    replacedert.Preplaced();
                }
            }
        }

19 Source : PMMacroTest.cs
with MIT License
from Autodesk

[Test]
        public void RecordMacroTest()
        {
            File tmpMacFile = File.CreateTemporaryFile(".mac");
            tmpMacFile.Delete();
            _powerMILL.RecordMacro(tmpMacFile.Path);
            _powerMILL.Execute("CREATE PATTERN 'fred'");

            _powerMILL.StopMacroRecording();

            replacedert.True(tmpMacFile.Exists, "macro file should exist");

            string[] lines = System.IO.File.ReadAllLines(tmpMacFile.Path);
            if (lines == null || lines.Length < 1)
            {
                replacedert.Fail("Macro file is empty");
            }

            tmpMacFile.Delete();
        }

19 Source : MSRFile.Test.cs
with MIT License
from Autodesk

[Test]
        public void MSRFileTwoStartsTest()
        {
            try
            {
                Geometry.MSRFile msrFile =
                    new Geometry.MSRFile(AppDomain.CurrentDomain.BaseDirectory +
                                         "\\..\\..\\TestFiles\\MSRTestFiles\\TwoStarts.msr",
                                         true);
            }
            catch (Exception ex)
            {
                replacedert.Preplaced(ex.Message);
            }
            replacedert.Fail("Failed to throw exception");
        }

19 Source : MSRFile.Test.cs
with MIT License
from Autodesk

[Test]
        public void MSRFileCultureAgnosticTest()
        {
            // Switches system culture to French and attempts to parse file. If safeguards against culture disparities are in place, test should preplaced.
            var currentCulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = new CultureInfo("fr");

            try
            {
                Geometry.MSRFile msrFile =
                    new Geometry.MSRFile(
                        AppDomain.CurrentDomain.BaseDirectory + "\\..\\..\\TestFiles\\MSRTestFiles\\Culture Agnostic.msr",
                        true);
            }
            catch (Exception ex)
            {
                replacedert.Fail(ex.Message);
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture = currentCulture;
            }

            replacedert.Preplaced();
        }

19 Source : MSRFile.Test.cs
with MIT License
from Autodesk

[Test]
        public void MSRFileTwoStartsTogetherTest()
        {
            try
            {
                Geometry.MSRFile msrFile =
                    new Geometry.MSRFile(AppDomain.CurrentDomain.BaseDirectory +
                                         "\\..\\..\\TestFiles\\MSRTestFiles\\TwoStartsOK.msr",
                                         true);
                replacedert.That(msrFile.Points.Count, Is.EqualTo(6));
            }
            catch (Exception ex)
            {
                replacedert.Fail(ex.Message);
            }
            replacedert.Preplaced("File read ok");
        }

19 Source : CompCurvesCollectionTest.cs
with MIT License
from Autodesk

[SetUp]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            try
            {
                _powerSHAPECollection = _powerSHAPE.ActiveModel.CompCurves;
                _genericCurvesCollection = (PSGenericCurvesCollection<PSCompCurve>) _powerSHAPECollection;
            }
            catch (Exception e)
            {
                replacedert.Fail("_powerSHAPECollection could not be set to Active Model's CompCurvesCollection\n\n" +
                            e.Message);
            }
        }

19 Source : CompCurvesCollectionTest.cs
with MIT License
from Autodesk

[Test]
        public void CreateObliqueCurveTest()
        {
            try
            {
                var foot = _powerSHAPE.ActiveModel.Meshes.CreateMeshFromFile(new File(TestFiles.SINGLE_OBLIQUE_MESH1));
                _powerSHAPE.SetActivePlane(Planes.XY);

                var listCompCurves = _powerSHAPE.ActiveModel.CompCurves.CreateObliqueCurve(foot, Planes.XY, 45.0);

                if (listCompCurves.Count != 1)
                {
                    replacedert.Fail("Should be one comp curve");
                }
                else
                {
                    if (_powerSHAPE.Version.Major < 16)

                        // TODO: update the old version numbers of points. 
                    {
                        replacedert.AreEqual(44, listCompCurves[0].NumberPoints);
                    }
                    else
                    {
                        replacedert.AreEqual(32, listCompCurves[0].NumberPoints);
                    }
                    var bx = listCompCurves[0].BoundingBox;
                    if (bx.MinX != 1025.006342)
                    {
                        replacedert.Fail("Min X not equal: MinX={0}", bx.MinX);
                    }
                    if (bx.MaxX != 1824.995724)
                    {
                        replacedert.Fail("Max X not equal: MaxX={0}", bx.MaxX);
                    }
                }
            }
            catch (Exception ex)
            {
                replacedert.Fail("CreateObliqueCurveTest\n\n" + ex.Message);
            }
        }

19 Source : CurvesCollectionTest.cs
with MIT License
from Autodesk

[SetUp]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            try
            {
                _powerSHAPECollection = _powerSHAPE.ActiveModel.Curves;
                _genericCurvesCollection = (PSGenericCurvesCollection<PSCurve>) _powerSHAPECollection;
            }
            catch (Exception e)
            {
                replacedert.Fail("_powerSHAPECollection could not be set to Active Model's CurvesCollection\n\n" + e.Message);
            }
        }

19 Source : ArcsCollectionTest.cs
with MIT License
from Autodesk

[SetUp]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            try
            {
                _powerSHAPECollection = _powerSHAPE.ActiveModel.Arcs;
            }
            catch (Exception e)
            {
                replacedert.Fail("_powerSHAPECollection could not be set to Active Model's ArcsCollection\n\n" + e.Message);
            }
        }

19 Source : ElectrodesCollectionTest.cs
with MIT License
from Autodesk

[SetUp]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            try
            {
                _powerSHAPECollection = _powerSHAPE.ActiveModel.Electrodes;
            }
            catch (Exception e)
            {
                replacedert.Fail("_powerSHAPECollection could not be set to Active Model's ElectrodesCollection\n\n" + e.Message);
            }
        }

19 Source : ElectrodesCollectionTest.cs
with MIT License
from Autodesk

[Test]
        public void AddElectrodesToSelectionTest()
        {
            _powerSHAPE.Models.CreateModelFromFile(new File(TestFiles.THREE_ELECTRODES_MODEL));

            // Import single enreplacedy to remain
            _powerSHAPE.ActiveModel.Import(new File(TestFiles.SINGLE_SURFACE));

            // Get single enreplacedy
            PSEnreplacedy testEnreplacedy = _powerSHAPE.ActiveModel.SelectedItems[0];

            // Clear selection
            _powerSHAPE.ActiveModel.ClearSelectedItems();

            // Add multiple enreplacedies to selection
            _powerSHAPE.ActiveModel.Electrodes.AddToSelection(true);

            // Check the selection contains all three enreplacedies
            if (_powerSHAPE.ActiveModel.SelectedItems.Count == 0) // Nothing was selected
            {
                replacedert.Fail("Failed to select anything in PowerSHAPE");
            }
            else if (_powerSHAPE.ActiveModel.SelectedItems.Count == 4) // Everything was selected
            {
                replacedert.Fail("Selected everything in PowerSHAPE");
            }

            // Check the test enreplacedy is not selected
            foreach (PSEnreplacedy selectedEnreplacedy in _powerSHAPE.ActiveModel.SelectedItems)
            {
                if (selectedEnreplacedy.Equals(testEnreplacedy)) // Test enreplacedy is in selection
                {
                    replacedert.Fail("Added other enreplacedies to selection");
                }
            }
            replacedert.AreEqual(_powerSHAPE.ActiveModel.SelectedItems.Count,
                            3,
                            "Failed to add all " + _collectionType.ToLower() + " to collection");
        }

19 Source : ElectrodesCollectionTest.cs
with MIT License
from Autodesk

[Test]
        public void RemoveElectrodeAtTest()
        {
            // Import file with three enreplacedies
            _powerSHAPE.Models.CreateModelFromFile(new File(TestFiles.THREE_ELECTRODES_MODEL));
            _powerSHAPECollection = _powerSHAPE.ActiveModel.Electrodes;

            // Get index of enreplacedy to be deleted
            int index;
            try
            {
                index = GetIndexOfNamedEnreplacedy("SPM1_2");
            }
            catch (ApplicationException e)
            {
                replacedert.Fail(e.Message);
                return;
            }

            // Remove second enreplacedy
            _powerSHAPECollection.RemoveAt(index);

            // Check resultant PowerSHAPE state
            if (_powerSHAPECollection.Count == 3)
            {
                replacedert.Fail("Failed to remove " + _collectionType + " from collection");
            }
            else if (_powerSHAPECollection.Count != 2)
            {
                replacedert.Fail("Removed too many " + _collectionType + "s from the collection");
            }
            else
            {
                foreach (PSElectrode createdEnreplacedy in _powerSHAPECollection)
                {
                    if (createdEnreplacedy.Name == "SPM1_2")
                    {
                        replacedert.Fail("Incorrect " + _collectionType + " deleted");
                    }
                }
            }
        }

19 Source : ElectrodesCollectionTest.cs
with MIT License
from Autodesk

[Test]
        public void RemoveElectrodesFromSelectionTest()
        {
            // Import file with three enreplacedies
            _powerSHAPE.Models.CreateModelFromFile(new File(TestFiles.THREE_ELECTRODES_MODEL));
            _powerSHAPECollection = _powerSHAPE.ActiveModel.Electrodes;

            // Import single enreplacedy
            _powerSHAPE.ActiveModel.Import(new File(TestFiles.SINGLE_SURFACE));

            // Get single enreplacedy
            PSEnreplacedy testEnreplacedy = _powerSHAPE.ActiveModel.SelectedItems[0];

            // Select everything
            _powerSHAPE.ActiveModel.SelectAll(true);

            // Remove enreplacedies from selection
            ((PSEnreplacediesCollection<PSElectrode>) _powerSHAPECollection).RemoveFromSelection();

            // Check the selection contains only the single enreplacedy
            if (_powerSHAPE.ActiveModel.SelectedItems.Count == 0) // Everything was deselected
            {
                replacedert.Fail("Deselected all enreplacedies in PowerSHAPE");
            }
            else if (_powerSHAPE.ActiveModel.SelectedItems.Count == 4) // Nothing was deselected
            {
                replacedert.Fail("Deselected nothing in PowerSHAPE");
            }
            else if (_powerSHAPE.ActiveModel.SelectedItems.Count != 1) // More than just the single enreplacedy is selected
            {
                replacedert.Fail("Failed to remove all " + _collectionType.ToLower() + "s from selection");
            }

            replacedert.AreEqual(_powerSHAPE.ActiveModel.SelectedItems[0],
                            testEnreplacedy,
                            "Removed incorrect enreplacedies from the selection");
        }

19 Source : LinesCollectionTest.cs
with MIT License
from Autodesk

[SetUp]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            try
            {
                _powerSHAPECollection = _powerSHAPE.ActiveModel.Lines;
            }
            catch (Exception e)
            {
                replacedert.Fail("_powerSHAPECollection could not be set to Active Model's LinesCollection\n\n" + e.Message);
            }
        }

19 Source : MeshesCollectionTest.cs
with MIT License
from Autodesk

[SetUp]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            try
            {
                _powerSHAPECollection = _powerSHAPE.ActiveModel.Meshes;
            }
            catch (Exception e)
            {
                replacedert.Fail("_powerSHAPECollection could not be set to Active Model's MeshesCollection\n\n" + e.Message);
            }
        }

19 Source : MeshesCollectionTest.cs
with MIT License
from Autodesk

[Test]
        public void AddMeshesToSelectionTest()
        {
            // Import three enreplacedies to be deleted
            _powerSHAPE.ActiveModel.Import(new FileSystem.File(TestFiles.SINGLE_MESH1));
            _powerSHAPE.ActiveModel.Import(new FileSystem.File(TestFiles.SINGLE_MESH2));
            _powerSHAPE.ActiveModel.Import(new FileSystem.File(TestFiles.SINGLE_MESH3));

            // Import single enreplacedy to remain
            _powerSHAPE.ActiveModel.Import(new FileSystem.File(TestFiles.SINGLE_SURFACE));

            // Get single enreplacedy
            PSEnreplacedy testEnreplacedy = _powerSHAPE.ActiveModel.SelectedItems[0];

            // Clear selection
            _powerSHAPE.ActiveModel.ClearSelectedItems();

            // Add multiple enreplacedies to selection
            ((PSEnreplacediesCollection<PSMesh>) _powerSHAPECollection).AddToSelection(true);

            // Check the selection contains all three enreplacedies
            if (_powerSHAPE.ActiveModel.SelectedItems.Count == 0) // Nothing was selected
            {
                replacedert.Fail("Failed to select anything in PowerSHAPE");
            }
            else if (_powerSHAPE.ActiveModel.SelectedItems.Count == 4) // Everything was selected
            {
                replacedert.Fail("Selected everything in PowerSHAPE");
            }

            // Check the test enreplacedy is not selected
            foreach (PSEnreplacedy selectedEnreplacedy in _powerSHAPE.ActiveModel.SelectedItems)
            {
                if (selectedEnreplacedy.Equals(testEnreplacedy)) // Test enreplacedy is in selection
                {
                    replacedert.Fail("Added other enreplacedies to selection");
                }
            }
            replacedert.AreEqual(_powerSHAPE.ActiveModel.SelectedItems.Count,
                            3,
                            "Failed to add all " + _collectionType.ToLower() + " to collection");
        }

19 Source : MeshesCollectionTest.cs
with MIT License
from Autodesk

[Test]
        public void RemoveMeshAtTest()
        {
            {
                // Import file with three enreplacedies
                _powerSHAPE.ActiveModel.Import(new FileSystem.File(TestFiles.SINGLE_MESH1));
                _powerSHAPE.ActiveModel.Import(new FileSystem.File(TestFiles.SINGLE_MESH2));
                _powerSHAPE.ActiveModel.Import(new FileSystem.File(TestFiles.SINGLE_MESH3));

                // Get index of enreplacedy to be deleted
                int index;
                try
                {
                    index = GetIndexOfNamedEnreplacedy("2");
                }
                catch (ApplicationException e)
                {
                    replacedert.Fail(e.Message);
                    return;
                }

                // Remove second enreplacedy
                _powerSHAPECollection.RemoveAt(index);

                // Check resultant PowerSHAPE state
                if (_powerSHAPECollection.Count == 3)
                {
                    replacedert.Fail("Failed to remove " + _collectionType + " from collection");
                }
                else if (_powerSHAPECollection.Count != 2)
                {
                    replacedert.Fail("Removed too many " + _collectionType + "s from the collection");
                }
                else
                {
                    foreach (PSMesh createdEnreplacedy in _powerSHAPECollection)
                    {
                        if (createdEnreplacedy.Name == "2")
                        {
                            replacedert.Fail("Incorrect " + _collectionType + " deleted");
                        }
                    }
                }
            }
        }

19 Source : PointsCollectionTest.cs
with MIT License
from Autodesk

[SetUp]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            try
            {
                _powerSHAPECollection = _powerSHAPE.ActiveModel.Points;
            }
            catch (Exception e)
            {
                replacedert.Fail("_powerSHAPECollection could not be set to Active Model's PointsCollection\n\n" + e.Message);
            }
        }

19 Source : SolidsCollectionTest.cs
with MIT License
from Autodesk

[SetUp]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            try
            {
                _powerSHAPECollection = _powerSHAPE.ActiveModel.Solids;
            }
            catch (Exception e)
            {
                replacedert.Fail("_powerSHAPECollection could not be set to Active Model's SolidsCollection\n\n" + e.Message);
            }
        }

19 Source : SurfacesCollectionTest.cs
with MIT License
from Autodesk

[SetUp]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            try
            {
                _powerSHAPECollection = _powerSHAPE.ActiveModel.Surfaces;
            }
            catch (Exception e)
            {
                replacedert.Fail("_powerSHAPECollection could not be set to Active Model's SurfacesCollection\n\n" +
                            e.Message);
            }
        }

19 Source : WorkplanesCollectionTest.cs
with MIT License
from Autodesk

[SetUp]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            try
            {
                _powerSHAPECollection = _powerSHAPE.ActiveModel.Workplanes;
            }
            catch (Exception e)
            {
                replacedert.Fail("_powerSHAPECollection could not be set to Active Model's WorkplanesCollection\n\n" +
                            e.Message);
            }
        }

19 Source : WorkplanesCollectionTest.cs
with MIT License
from Autodesk

[Test]
        public void RemoveWorkplanesFromSelectionTest()
        {
            // Import multiple enreplacedies
            _powerSHAPE.ActiveModel.Import(new File(TestFiles.THREE_WORKPLANES));

            // Import single enreplacedy
            _powerSHAPE.ActiveModel.Import(new File(TestFiles.SINGLE_WORKPLANE1));

            // Get single enreplacedy
            var testEnreplacedy = _powerSHAPE.ActiveModel.SelectedItems[0];

            // Select everything
            _powerSHAPE.ActiveModel.Workplanes.AddToSelection();

            // Remove enreplacedies from selection
            ((PSWorkplanesCollection) _powerSHAPECollection).RemoveFromSelection();

            // Check the selection was cleared
            if (_powerSHAPE.ActiveModel.SelectedItems.Count == 4) // Nothing was deselected
            {
                replacedert.Fail("Deselected nothing in PowerSHAPE");
            }
            else if (_powerSHAPE.ActiveModel.SelectedItems.Count != 0) // Everything was deselected
            {
                replacedert.Fail("Failed to remove all " + _collectionType.ToLower() + "s from selection");
            }
        }

19 Source : EntitiesCollectionTest.cs
with MIT License
from Autodesk

public virtual void RemoveAtTest(string fileToImport, string nameOfEnreplacedyToRemove)
        {
            // Import file with three enreplacedies
            _powerSHAPE.ActiveModel.Import(new FileSystem.File(fileToImport));

            // Get index of enreplacedy to be deleted
            int index;
            try
            {
                index = GetIndexOfNamedEnreplacedy(nameOfEnreplacedyToRemove);
            }
            catch (ApplicationException e)
            {
                replacedert.Fail(e.Message);
                return;
            }

            // Remove second enreplacedy
            _powerSHAPECollection.RemoveAt(index);

            // Check resultant PowerSHAPE state
            if (_powerSHAPECollection.Count == 3)
            {
                replacedert.Fail("Failed to remove " + _collectionType + " from collection");
            }
            else if (_powerSHAPECollection.Count != 2)
            {
                replacedert.Fail("Removed too many " + _collectionType + "s from the collection");
            }
            else
            {
                foreach (T createdEnreplacedy in _powerSHAPECollection)
                {
                    if (createdEnreplacedy.Name == nameOfEnreplacedyToRemove)
                    {
                        replacedert.Fail("Incorrect " + _collectionType + " deleted");
                    }
                }
            }
        }

19 Source : EntitiesCollectionTest.cs
with MIT License
from Autodesk

public virtual void RemoveTest(string fileToImport, string nameOfEnreplacedyToRemove)
        {
            // Import three enreplacedies
            _powerSHAPE.ActiveModel.Import(new FileSystem.File(fileToImport));

            var originalCount = _powerSHAPECollection.Count;

            T enreplacedyToDelete = _powerSHAPECollection.FirstOrDefault(x => x.Name == nameOfEnreplacedyToRemove);
            if (enreplacedyToDelete == null)
            {
                replacedert.Fail("Couldn't find enreplacedy name " + nameOfEnreplacedyToRemove);
            }

            // Remove second enreplacedy
            _powerSHAPECollection.Remove(enreplacedyToDelete);

            if (_powerSHAPECollection.Count == originalCount)
            {
                replacedert.Fail("Failed to remove " + _collectionType.ToLower() + " from collection");
            }
            else if (_powerSHAPECollection.Count != originalCount - 1)
            {
                replacedert.Fail("Removed too many " + _collectionType.ToLower() + "s from the collection");
            }
            else
            {
                foreach (T createdEnreplacedy in _powerSHAPECollection)
                {
                    if (createdEnreplacedy.Name == nameOfEnreplacedyToRemove)
                    {
                        replacedert.Fail("Incorrect " + _collectionType.ToLower() + " deleted");
                    }
                }
            }
        }

19 Source : EntitiesCollectionTest.cs
with MIT License
from Autodesk

public virtual void AddToSelectionTest(string multipleEnreplacediesFile, string singleEnreplacediesFile)
        {
            // Import three enreplacedies to be deleted
            _powerSHAPE.ActiveModel.Import(new FileSystem.File(multipleEnreplacediesFile));

            // Import single enreplacedy to remain
            _powerSHAPE.ActiveModel.Import(new FileSystem.File(singleEnreplacediesFile));

            // Get single enreplacedy
            PSEnreplacedy testEnreplacedy = _powerSHAPE.ActiveModel.SelectedItems[0];

            // Clear selection
            _powerSHAPE.ActiveModel.ClearSelectedItems();

            // Add multiple enreplacedies to selection
            ((PSEnreplacediesCollection<T>) _powerSHAPECollection).AddToSelection(true);

            // Check the selection contains all three enreplacedies
            if (_powerSHAPE.ActiveModel.SelectedItems.Count == 0) // Nothing was selected
            {
                replacedert.Fail("Failed to select anything in PowerSHAPE");
            }
            else if (_powerSHAPE.ActiveModel.SelectedItems.Count == 4) // Everything was selected
            {
                replacedert.Fail("Selected everything in PowerSHAPE");
            }

            // Check the test enreplacedy is not selected
            foreach (PSEnreplacedy selectedEnreplacedy in _powerSHAPE.ActiveModel.SelectedItems)
            {
                if (selectedEnreplacedy.Equals(testEnreplacedy)) // Test enreplacedy is in selection
                {
                    replacedert.Fail("Added other enreplacedies to selection");
                }
            }
            replacedert.AreEqual(_powerSHAPE.ActiveModel.SelectedItems.Count,
                            3,
                            "Failed to add all " + _collectionType.ToLower() + " to collection");
        }

19 Source : EntitiesCollectionTest.cs
with MIT License
from Autodesk

public virtual void RemoveFromSelectionTest(string multipleEnreplacediesFile, string singleEnreplacediesFile)
        {
            // Import multiple enreplacedies
            _powerSHAPE.ActiveModel.Import(new FileSystem.File(multipleEnreplacediesFile));

            // Import single enreplacedy
            _powerSHAPE.ActiveModel.Import(new FileSystem.File(singleEnreplacediesFile));

            // Get single enreplacedy
            PSEnreplacedy testEnreplacedy = _powerSHAPE.ActiveModel.SelectedItems[0];

            // Select everything
            _powerSHAPE.ActiveModel.SelectAll(true);

            // Remove enreplacedies from selection
            ((PSEnreplacediesCollection<T>) _powerSHAPECollection).RemoveFromSelection();

            // Check the selection contains only the single enreplacedy
            if (_powerSHAPE.ActiveModel.SelectedItems.Count == 0) // Everything was deselected
            {
                replacedert.Fail("Deselected all enreplacedies in PowerSHAPE");
            }
            else if (_powerSHAPE.ActiveModel.SelectedItems.Count == 4) // Nothing was deselected
            {
                replacedert.Fail("Deselected nothing in PowerSHAPE");
            }
            else if (_powerSHAPE.ActiveModel.SelectedItems.Count != 1) // More than just the single enreplacedy is selected
            {
                replacedert.Fail("Failed to remove all " + _collectionType.ToLower() + "s from selection");
            }

            replacedert.AreEqual(_powerSHAPE.ActiveModel.SelectedItems[0],
                            testEnreplacedy,
                            "Removed incorrect enreplacedies from the selection");
        }

19 Source : CompCurveTest.cs
with MIT License
from Autodesk

[SetUp]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            try
            {
                _powerSHAPECollection = _powerSHAPE.ActiveModel.CompCurves;
                _genericCurvesCollection = (PSGenericCurvesCollection<PSCompCurve>) _powerSHAPECollection;
            }
            catch (Exception e)
            {
                replacedert.Fail("_enreplacedyCollection could not be set to Active Model's CompCurvesCollection\n\n" + e.Message);
            }
        }

19 Source : CurveTest.cs
with MIT License
from Autodesk

[SetUp]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            try
            {
                _powerSHAPECollection = _powerSHAPE.ActiveModel.Curves;
                _genericCurvesCollection = (PSGenericCurvesCollection<PSCurve>) _powerSHAPECollection;
            }
            catch (Exception e)
            {
                replacedert.Fail("_enreplacedyCollection could not be set to Active Model's CurvesCollection\n\n" + e.Message);
            }
        }

19 Source : LateralTest.cs
with MIT License
from Autodesk

[Test]
        public void LateralBoundingBoxTest()
        {
            try
            {
                var bb = _parentSurface.Laterals[1].BoundingBox;
                replacedert.Fail("Exception not thrown");
            }
            catch (Exception)
            {
                replacedert.Preplaced();
            }
        }

19 Source : LongitudinalTest.cs
with MIT License
from Autodesk

[Test]
        public void LongitudinalBoundingBoxTest()
        {
            try
            {
                var bb = _parentSurface.Longitudinals[1].BoundingBox;
                replacedert.Fail("Exception not thrown");
            }
            catch (Exception)
            {
                replacedert.Preplaced();
            }
        }

19 Source : LineTest.cs
with MIT License
from Autodesk

[SetUp]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            try
            {
                _powerSHAPECollection = _powerSHAPE.ActiveModel.Lines;
            }
            catch (Exception e)
            {
                replacedert.Fail("_enreplacedyCollection could not be set to Active Model's LinesCollection\n\n" + e.Message);
            }
        }

19 Source : AnnotationTest.cs
with MIT License
from Autodesk

[SetUp]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            try
            {
                _powerSHAPECollection = _powerSHAPE.ActiveModel.Annotations;
            }
            catch (Exception e)
            {
                replacedert.Fail("_enreplacedyCollection could not be set to Active Model's AnnotationsCollection\n\n" + e.Message);
            }
        }

19 Source : AnnotationTest.cs
with MIT License
from Autodesk

[Test]
        public void AnnotationBoundingBoxTest()
        {
            try
            {
                BoundingBoxTest(TestFiles.SINGLE_ANNOTATION, new Point(), new Point());
                replacedert.Fail("Exception not thrown");
            }
            catch (Exception)
            {
                replacedert.Preplaced();
            }
        }

19 Source : ArcTest.cs
with MIT License
from Autodesk

[SetUp]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            try
            {
                _powerSHAPECollection = _powerSHAPE.ActiveModel.Arcs;
            }
            catch (Exception e)
            {
                replacedert.Fail("_enreplacedyCollection could not be set to Active Model's ArcsCollection\n\n" + e.Message);
            }
        }

19 Source : ElectrodeTest.cs
with MIT License
from Autodesk

[SetUp]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            try
            {
                _powerSHAPECollection = _powerSHAPE.ActiveModel.Electrodes;
            }
            catch (Exception e)
            {
                replacedert.Fail("_enreplacedyCollection could not be set to Active Model's ElectrodesCollection\n\n" + e.Message);
            }
        }

19 Source : ElectrodeTest.cs
with MIT License
from Autodesk

[Test]
        public void BlankElectrodeTest()
        {
            _powerSHAPE.Models.CreateModelFromFile(new File(TestFiles.SINGLE_ELECTRODE_MODEL));
            _powerSHAPECollection = _powerSHAPE.ActiveModel.Electrodes;
            var importedEnreplacedy = _powerSHAPE.ActiveModel.Electrodes[0];

            // Select everything
            _powerSHAPE.ActiveModel.SelectAll(true);

            // Add desired enreplacedy to selection, cancelling current selection
            importedEnreplacedy.AddToSelection(true);

            var count = _powerSHAPE.ActiveModel.SelectedItems.Count;

            // Check the selection contains the correct enreplacedy
            if (count == 0)
            {
                replacedert.Fail("Failed to select anything in PowerSHAPE");
            }
            else if (count == 2)
            {
                replacedert.Fail("Selected everything in PowerSHAPE");
            }

            // Check the other enreplacedy is not selected
            replacedert.IsTrue(_powerSHAPE.ActiveModel.SelectedItems.Contains(importedEnreplacedy), "Select incorrect enreplacedy");
        }

19 Source : ElectrodeTest.cs
with MIT License
from Autodesk

[Test]
        public void RemoveElectrodeFromSelectionTest()
        {
            _powerSHAPE.Models.CreateModelFromFile(new File(TestFiles.SINGLE_ELECTRODE_MODEL));
            _powerSHAPECollection = _powerSHAPE.ActiveModel.Electrodes;
            var enreplacedyToDeselect = _powerSHAPE.ActiveModel.Electrodes[0];

            // Get other enreplacedy
            var otherEnreplacedy = ImportAndGetEnreplacedy(TestFiles.SINGLE_SURFACE);

            // Select everything
            _powerSHAPE.ActiveModel.SelectAll(true);
            if (_powerSHAPE.ActiveModel.SelectedItems.Count == 0)
            {
                _powerSHAPE.ActiveModel.Workplanes.AddToSelection(false);
            }

            // Remove desired enreplacedy from selection, cancelling current selection
            enreplacedyToDeselect.RemoveFromSelection();

            // Check the selection doesn't contain the enreplacedy
            if (_powerSHAPE.ActiveModel.SelectedItems.Count == 0) // Everything was deselected
            {
                replacedert.Fail("Deselected everything in PowerSHAPE");
            }
            else if (_powerSHAPE.ActiveModel.SelectedItems.Count == 2) // Nothing was deselected
            {
                replacedert.Fail("Nothing was deselected in PowerSHAPE");
            }

            // Check the enreplacedy is not selected
            replacedert.IsTrue(_powerSHAPE.ActiveModel.SelectedItems.Contains(otherEnreplacedy), "Deselected incorrect enreplacedy");
        }

19 Source : MeshTest.cs
with MIT License
from Autodesk

[SetUp]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            try
            {
                _powerSHAPECollection = _powerSHAPE.ActiveModel.Meshes;
            }
            catch (Exception e)
            {
                replacedert.Fail("_enreplacedyCollection could not be set to Active Model's MeshesCollection\n\n" + e.Message);
            }
        }

19 Source : PointTest.cs
with MIT License
from Autodesk

[SetUp]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            try
            {
                _powerSHAPECollection = _powerSHAPE.ActiveModel.Points;
            }
            catch (Exception e)
            {
                replacedert.Fail("_enreplacedyCollection could not be set to Active Model's PointsCollection\n\n" + e.Message);
            }
        }

See More Examples