Ejemplo n.º 1
0
        public void ClearAllSections_HasSections_ClearSectionsAndSectionDependentDataAndSourcePath()
        {
            // Setup
            var section = new FailureMechanismSection("A", new[]
            {
                new Point2D(1.1, 2.2),
                new Point2D(3.3, 4.4)
            });

            var          failureMechanism = new SimpleFailureMechanismBase();
            const string sourcePath       = "some/Path";

            failureMechanism.SetSections(new[]
            {
                section
            }, sourcePath);

            // Precondition
            Assert.AreEqual(sourcePath, failureMechanism.FailureMechanismSectionSourcePath);
            CollectionAssert.IsNotEmpty(failureMechanism.Sections);

            // Call
            failureMechanism.ClearAllSections();

            // Assert
            Assert.IsNull(failureMechanism.FailureMechanismSectionSourcePath);
            CollectionAssert.IsEmpty(failureMechanism.Sections);
            CollectionAssert.IsEmpty(failureMechanism.SectionResults);
        }
Ejemplo n.º 2
0
        public void SetSections_SecondSectionDoesNotConnectToFirst_ThrowArgumentException()
        {
            // Setup
            var failureMechanism = new SimpleFailureMechanismBase();

            var section1 = new FailureMechanismSection("A", new[]
            {
                new Point2D(1, 2),
                new Point2D(3, 4)
            });
            var section2 = new FailureMechanismSection("B", new[]
            {
                new Point2D(5, 6),
                new Point2D(7, 8)
            });

            // Call
            void Call() => failureMechanism.SetSections(new[]
            {
                section1,
                section2
            }, string.Empty);

            // Assert
            const string expectedMessage = "Vak 'B' sluit niet aan op de al gedefinieerde vakken van het faalmechanisme.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(Call, expectedMessage);
        }
Ejemplo n.º 3
0
        public void SetSections_SecondSectionEndConnectingToStartOfFirst_ThrowArgumentException()
        {
            // Setup
            var failureMechanism = new SimpleFailureMechanismBase();

            const int matchingX = 1;
            const int matchingY = 2;

            var section1 = new FailureMechanismSection("A", new[]
            {
                new Point2D(matchingX, matchingY),
                new Point2D(3, 4)
            });
            var section2 = new FailureMechanismSection("B", new[]
            {
                new Point2D(-2, -1),
                new Point2D(matchingX, matchingY)
            });

            // Call
            void Call() => failureMechanism.SetSections(new[]
            {
                section1,
                section2
            }, string.Empty);

            // Assert
            const string expectedMessage = "Vak 'B' sluit niet aan op de al gedefinieerde vakken van het faalmechanisme.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(Call, expectedMessage);
        }
Ejemplo n.º 4
0
        public void GivenFailureMechanismWithoutSections_WhenSettingValidSections_ThenExpectedSectionsAndSourcePathAndSectionResultsSet()
        {
            // Given
            const string sourcePath       = "some/Path";
            var          failureMechanism = new SimpleFailureMechanismBase();

            const int matchingX = 1;
            const int matchingY = 2;

            var section1 = new FailureMechanismSection("A", new[]
            {
                new Point2D(3, 4),
                new Point2D(matchingX, matchingY)
            });
            var section2 = new FailureMechanismSection("B", new[]
            {
                new Point2D(matchingX, matchingY),
                new Point2D(-2, -1)
            });

            FailureMechanismSection[] sections =
            {
                section1,
                section2
            };

            // When
            failureMechanism.SetSections(sections, sourcePath);

            // Then
            Assert.AreEqual(sourcePath, failureMechanism.FailureMechanismSectionSourcePath);
            CollectionAssert.AreEqual(sections, failureMechanism.Sections);
            Assert.AreEqual(sections.Length, failureMechanism.SectionResults.Count());
            CollectionAssert.AreEqual(sections, failureMechanism.SectionResults.Select(sr => sr.Section));
        }
Ejemplo n.º 5
0
        public void SetSections_SectionsNull_ThrowArgumentNullException()
        {
            // Setup
            var failureMechanism = new SimpleFailureMechanismBase();

            // Call
            void Call() => failureMechanism.SetSections(null, string.Empty);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("sections", exception.ParamName);
        }
Ejemplo n.º 6
0
        public void SetSections_SourcePathNull_ThrowArgumentNullException()
        {
            // Setup
            var failureMechanism = new SimpleFailureMechanismBase();

            // Call
            void Call() => failureMechanism.SetSections(Enumerable.Empty <FailureMechanismSection>(), null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("sourcePath", exception.ParamName);
        }
Ejemplo n.º 7
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            const string name = "<cool name>";
            const string code = "<cool code>";

            // Call
            var failureMechanism = new SimpleFailureMechanismBase(name, code);

            // Assert
            Assert.IsInstanceOf <Observable>(failureMechanism);
            Assert.IsInstanceOf <IFailureMechanism>(failureMechanism);
            Assert.AreEqual(name, failureMechanism.Name);
            Assert.AreEqual(code, failureMechanism.Code);
            Assert.IsNotNull(failureMechanism.InAssemblyInputComments);
            Assert.IsNotNull(failureMechanism.InAssemblyOutputComments);
            Assert.IsNotNull(failureMechanism.NotInAssemblyComments);
            Assert.IsNotNull(failureMechanism.AssemblyResult);
            Assert.IsTrue(failureMechanism.InAssembly);
            CollectionAssert.IsEmpty(failureMechanism.Sections);
            CollectionAssert.IsEmpty(failureMechanism.SectionResults);
        }