Index: Ringtoets/Common/test/Ringtoets.Common.Plugin.Test/RingtoetsPluginHelperTest.cs =================================================================== diff -u -rd77e03b530f7a8621552659810f70b0c3b24bd9d -re4310a61841a0e3cefc1854f6d3f998f825e923b --- Ringtoets/Common/test/Ringtoets.Common.Plugin.Test/RingtoetsPluginHelperTest.cs (.../RingtoetsPluginHelperTest.cs) (revision d77e03b530f7a8621552659810f70b0c3b24bd9d) +++ Ringtoets/Common/test/Ringtoets.Common.Plugin.Test/RingtoetsPluginHelperTest.cs (.../RingtoetsPluginHelperTest.cs) (revision e4310a61841a0e3cefc1854f6d3f998f825e923b) @@ -22,7 +22,6 @@ using System.Linq; using Core.Common.Controls.Views; using NUnit.Framework; -using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; @@ -38,214 +37,10 @@ namespace Ringtoets.Common.Service.Test { [TestFixture] - public class RingtoetsPluginHelperTest + public class RingtoetsPluginHelperTest : ShouldCloseViewWithCalculationDataTester { - [Test] - public void CloseForData_ViewCorrespondingToRemovedCalculationContext_ReturnsTrue() + protected override bool PerformShouldCloseViewWithCalculationDataMethod(IView view, object o) { - // Setup - ICalculationContext calculationContext = GetCalculationContextWithCalculation(); - - using (IView view = GetView()) - { - view.Data = calculationContext.WrappedData; - - // Call - bool closeForData = PerformCloseMethod(view, calculationContext); - - // Assert - Assert.IsTrue(closeForData); - } - } - - [Test] - public void CloseForData_ViewNotCorrespondingToRemovedCalculationContext_ReturnsFalse() - { - // Setup - ICalculationContext calculationContext = GetCalculationContextWithCalculation(); - - using (IView view = GetView()) - { - view.Data = GetCalculation(); - - // Call - bool closeForData = PerformCloseMethod(view, calculationContext); - - // Assert - Assert.IsFalse(closeForData); - } - } - - [Test] - public void CloseForData_ViewCorrespondingWithRemovedCalculationGroupContext_ReturnsTrue() - { - // Setup - ICalculationContext calculationGroupContext = GetCalculationGroupContextWithCalculation(); - - using (IView view = GetView()) - { - view.Data = calculationGroupContext.WrappedData.GetCalculations().First(); - - // Call - bool closeForData = PerformCloseMethod(view, calculationGroupContext); - - // Assert - Assert.IsTrue(closeForData); - } - } - - [Test] - public void CloseForData_ViewNotCorrespondingWithRemovedCalculationGroupContext_ReturnsFalse() - { - // Setup - ICalculationContext calculationGroupContext = GetCalculationGroupContextWithCalculation(); - - using (IView view = GetView()) - { - view.Data = GetCalculation(); - - // Call - bool closeForData = PerformCloseMethod(view, calculationGroupContext); - - // Assert - Assert.IsFalse(closeForData); - } - } - - [Test] - public void CloseForData_ViewCorrespondingWithRemovedFailureMechanism_ReturnsTrue() - { - // Setup - IFailureMechanismContext failureMechanismContext = GetFailureMechanismContextWithCalculation(); - - using (IView view = GetView()) - { - view.Data = failureMechanismContext.WrappedData.Calculations.First(); - - // Call - bool closeForData = PerformCloseMethod(view, failureMechanismContext.WrappedData); - - // Assert - Assert.IsTrue(closeForData); - } - } - - [Test] - public void CloseForData_ViewNotCorrespondingWithRemovedFailureMechanism_ReturnsFalse() - { - // Setup - IFailureMechanismContext failureMechanismContext = GetFailureMechanismContextWithCalculation(); - - using (IView view = GetView()) - { - view.Data = GetCalculation(); - - // Call - bool closeForData = PerformCloseMethod(view, failureMechanismContext.WrappedData); - - // Assert - Assert.IsFalse(closeForData); - } - } - - [Test] - public void CloseForData_ViewCorrespondingWithRemovedFailureMechanismContext_ReturnsTrue() - { - // Setup - IFailureMechanismContext failureMechanismContext = GetFailureMechanismContextWithCalculation(); - - using (IView view = GetView()) - { - view.Data = failureMechanismContext.WrappedData.Calculations.First(); - - // Call - bool closeForData = PerformCloseMethod(view, failureMechanismContext); - - // Assert - Assert.IsTrue(closeForData); - } - } - - [Test] - public void CloseForData_ViewNotCorrespondingWithRemovedFailureMechanismContext_ReturnsFalse() - { - // Setup - IFailureMechanismContext failureMechanismContext = GetFailureMechanismContextWithCalculation(); - - using (IView view = GetView()) - { - view.Data = GetCalculation(); - - // Call - bool closeForData = PerformCloseMethod(view, failureMechanismContext); - - // Assert - Assert.IsFalse(closeForData); - } - } - - [Test] - public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() - { - // Setup - var mocks = new MockRepository(); - var assessmentSectionStub = mocks.Stub(); - - IFailureMechanism failureMechanism = GetFailureMechanismContextWithCalculation().WrappedData; - - assessmentSectionStub.Stub(a => a.GetFailureMechanisms()).Return(new[] - { - failureMechanism - }); - - mocks.ReplayAll(); - - using (IView view = GetView()) - { - view.Data = failureMechanism.Calculations.First(); - - // Call - bool closeForData = PerformCloseMethod(view, assessmentSectionStub); - - // Assert - Assert.IsTrue(closeForData); - } - - mocks.VerifyAll(); - } - - [Test] - public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() - { - // Setup - var mocks = new MockRepository(); - var assessmentSectionStub = mocks.Stub(); - - IFailureMechanism failureMechanism = GetFailureMechanismContextWithCalculation().WrappedData; - - assessmentSectionStub.Stub(a => a.GetFailureMechanisms()).Return(new[] - { - failureMechanism - }); - - mocks.ReplayAll(); - - using (IView view = GetView()) - { - view.Data = GetCalculation(); - - // Call - bool closeForData = PerformCloseMethod(view, assessmentSectionStub); - - // Assert - Assert.IsFalse(closeForData); - } - - mocks.VerifyAll(); - } - - protected static bool PerformCloseMethod(IView view, object o) - { using (var plugin = new RingtoetsPlugin()) { return plugin.GetViewInfos() @@ -254,25 +49,25 @@ } } - protected static IView GetView() + protected override IView GetView() { return new GeneralResultFaultTreeIllustrationPointView(() => new TestGeneralResultFaultTreeIllustrationPoint()); } - protected static ICalculation GetCalculation() + protected override ICalculation GetCalculation() { return new StructuresCalculation(); } - protected static ICalculationContext GetCalculationContextWithCalculation() + protected override ICalculationContext GetCalculationContextWithCalculation() { return new HeightStructuresCalculationContext( new StructuresCalculation(), new HeightStructuresFailureMechanism(), new AssessmentSection(AssessmentSectionComposition.Dike)); } - protected static ICalculationContext GetCalculationGroupContextWithCalculation() + protected override ICalculationContext GetCalculationGroupContextWithCalculation() { return new HeightStructuresCalculationGroupContext( new CalculationGroup @@ -286,7 +81,7 @@ new AssessmentSection(AssessmentSectionComposition.Dike)); } - protected static IFailureMechanismContext GetFailureMechanismContextWithCalculation() + protected override IFailureMechanismContext GetFailureMechanismContextWithCalculation() { return new HeightStructuresFailureMechanismContext( new HeightStructuresFailureMechanism