Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/FailureMechanismSectionsViewInfoTest.cs =================================================================== diff -u -rf07d6418a5280c74ea8a35de183dbaed51dda066 -r34f83cd0a18bf396a2b1551a0fb5fbb3f3125dc7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/FailureMechanismSectionsViewInfoTest.cs (.../FailureMechanismSectionsViewInfoTest.cs) (revision f07d6418a5280c74ea8a35de183dbaed51dda066) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/FailureMechanismSectionsViewInfoTest.cs (.../FailureMechanismSectionsViewInfoTest.cs) (revision 34f83cd0a18bf396a2b1551a0fb5fbb3f3125dc7) @@ -31,31 +31,22 @@ using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.Views; +using Ringtoets.Common.Plugin.TestUtil; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.Integration.Plugin.Test.ViewInfos { [TestFixture] public class FailureMechanismSectionsViewInfoTest { - private MockRepository mocks; - private RingtoetsPlugin plugin; private ViewInfo info; [SetUp] public void SetUp() { - mocks = new MockRepository(); - plugin = new RingtoetsPlugin(); - info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(FailureMechanismSectionsView)); + info = GetViewInfo(); } - [TearDown] - public void TearDown() - { - plugin.Dispose(); - } - [Test] public void Initialized_Always_ExpectedPropertiesSet() { @@ -78,6 +69,7 @@ public void GetViewData_Always_ReturnsFailureMechanismSections() { // Setup + var mocks = new MockRepository(); var assessmentSection = mocks.Stub(); mocks.ReplayAll(); @@ -102,125 +94,26 @@ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.SectionsIcon, image); } - [Test] - public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() + [TestFixture] + public class FailureMechanismSectionsViewInfoCloseForDataTester : ShouldCloseFailureMechanismSectionsViewTester { - // Setup - var assessmentSection = mocks.Stub(); - assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(Enumerable.Empty()); - mocks.ReplayAll(); - - var failureMechanism = new TestFailureMechanism(); - using (var view = new FailureMechanismSectionsView(failureMechanism.Sections, failureMechanism)) + protected override bool ShouldCloseMethod(FailureMechanismSectionsView view, object o) { - // Call - bool closeForData = info.CloseForData(view, assessmentSection); - - // Assert - Assert.IsFalse(closeForData); + return GetViewInfo().CloseForData(view, o); } - mocks.VerifyAll(); - } - - [Test] - public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() - { - // Setup - var failureMechanism = new TestFailureMechanism(); - var assessmentSection = mocks.Stub(); - assessmentSection.Stub(asm => asm.GetFailureMechanisms()).Return(new[] + protected override FailureMechanismSectionsView GetView(IFailureMechanism failureMechanism) { - failureMechanism - }); - mocks.ReplayAll(); - - using (var view = new FailureMechanismSectionsView(failureMechanism.Sections, failureMechanism)) - { - // Call - bool closeForData = info.CloseForData(view, assessmentSection); - - // Assert - Assert.IsTrue(closeForData); + return new FailureMechanismSectionsView(failureMechanism.Sections, failureMechanism); } - - mocks.VerifyAll(); } - [Test] - public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnsFalse() + private static ViewInfo GetViewInfo() { - // Setup - var failureMechanism = new TestFailureMechanism(); - - using (var view = new FailureMechanismSectionsView(failureMechanism.Sections, failureMechanism)) + using (var plugin = new RingtoetsPlugin()) { - // Call - bool closeForData = info.CloseForData(view, new TestFailureMechanism()); - - // Assert - Assert.IsFalse(closeForData); + return plugin.GetViewInfos().First(tni => tni.ViewType == typeof(FailureMechanismSectionsView)); } } - - [Test] - public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnsTrue() - { - // Setup - var failureMechanism = new TestFailureMechanism(); - - using (var view = new FailureMechanismSectionsView(failureMechanism.Sections, failureMechanism)) - { - // Call - bool closeForData = info.CloseForData(view, failureMechanism); - - // Assert - Assert.IsTrue(closeForData); - } - } - - [Test] - public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanismContext_ReturnsFalse() - { - // Setup - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); - - var failureMechanism = new TestFailureMechanism(); - var failureMechanismContext = new FailureMechanismContext(new TestFailureMechanism(), assessmentSection); - - using (var view = new FailureMechanismSectionsView(failureMechanism.Sections, failureMechanism)) - { - // Call - bool closeForData = info.CloseForData(view, failureMechanismContext); - - // Assert - Assert.IsFalse(closeForData); - } - - mocks.VerifyAll(); - } - - [Test] - public void CloseForData_ViewCorrespondingToRemovedFailureMechanismContext_ReturnsTrue() - { - // Setup - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); - - var failureMechanism = new TestFailureMechanism(); - var failureMechanismContext = new FailureMechanismContext(failureMechanism, assessmentSection); - - using (var view = new FailureMechanismSectionsView(failureMechanism.Sections, failureMechanism)) - { - // Call - bool closeForData = info.CloseForData(view, failureMechanismContext); - - // Assert - Assert.IsTrue(closeForData); - } - - mocks.VerifyAll(); - } } } \ No newline at end of file