public void CurrentPath_FailureMechanismSectionsHasPathSet_ReturnsExpectedPath() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); const string expectedFilePath = "path"; var failureMechanism = new SpecificFailureMechanism(); failureMechanism.SetSections(Enumerable.Empty <FailureMechanismSection>(), expectedFilePath); var context = new SpecificFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new RiskeerPlugin()) { UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call string currentFilePath = updateInfo.CurrentPath(context); // Assert Assert.AreEqual(expectedFilePath, currentFilePath); mocks.VerifyAll(); } }
public void GivenSpecificFailureMechanismWithoutSections_WhenSettingValidSections_ThenExpectedSectionsAndSourcePathAndSectionResultsSet() { // Given const string sourcePath = "some/Path"; var failureMechanism = new SpecificFailureMechanism(); 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)); }
public void IsEnabled_SourcePathSet_ReturnTrue() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var failureMechanism = new SpecificFailureMechanism(); failureMechanism.SetSections(Enumerable.Empty <FailureMechanismSection>(), "path"); var context = new SpecificFailureMechanismSectionsContext(failureMechanism, assessmentSection); using (var plugin = new RiskeerPlugin()) { UpdateInfo updateInfo = GetUpdateInfo(plugin); // Call bool isEnabled = updateInfo.IsEnabled(context); // Assert Assert.IsTrue(isEnabled); } mocks.VerifyAll(); }
public void ClearAllSections_HasSections_ClearSectionsAndSectionResultsAndSourcePath() { // Setup var section = new FailureMechanismSection("A", new[] { new Point2D(1.1, 2.2), new Point2D(3.3, 4.4) }); var failureMechanism = new SpecificFailureMechanism(); const string sourcePath = "some/Path"; failureMechanism.SetSections(new[] { section }, sourcePath); // Precondition Assert.AreEqual(sourcePath, failureMechanism.FailureMechanismSectionSourcePath); CollectionAssert.IsNotEmpty(failureMechanism.Sections); CollectionAssert.IsNotEmpty(failureMechanism.SectionResults); // Call failureMechanism.ClearAllSections(); // Assert Assert.IsNull(failureMechanism.FailureMechanismSectionSourcePath); CollectionAssert.IsEmpty(failureMechanism.Sections); CollectionAssert.IsEmpty(failureMechanism.SectionResults); }
public void SetSections_SecondSectionDoesNotConnectToFirst_ThrowArgumentException() { // Setup var failureMechanism = new SpecificFailureMechanism(); 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); }
public void SetSections_SecondSectionEndConnectingToStartOfFirst_ThrowArgumentException() { // Setup var failureMechanism = new SpecificFailureMechanism(); 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); }
public void SetSections_SourcePathNull_ThrowArgumentNullException() { // Setup var failureMechanism = new SpecificFailureMechanism(); // Call void Call() => failureMechanism.SetSections(Enumerable.Empty <FailureMechanismSection>(), null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("sourcePath", exception.ParamName); }
public void SetSections_SectionsNull_ThrowArgumentNullException() { // Setup var failureMechanism = new SpecificFailureMechanism(); // Call void Call() => failureMechanism.SetSections(null, string.Empty); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("sections", exception.ParamName); }