Index: Ringtoets/Common/test/Ringtoets.Common.Plugin.TestUtil/ShouldCloseViewWithCalculationDataTester.cs =================================================================== diff -u -r613dc4314e1caf2c551178bec360667bdb1e7823 -rd6f67b18eba9be133de89079e68794b319c16233 --- Ringtoets/Common/test/Ringtoets.Common.Plugin.TestUtil/ShouldCloseViewWithCalculationDataTester.cs (.../ShouldCloseViewWithCalculationDataTester.cs) (revision 613dc4314e1caf2c551178bec360667bdb1e7823) +++ Ringtoets/Common/test/Ringtoets.Common.Plugin.TestUtil/ShouldCloseViewWithCalculationDataTester.cs (.../ShouldCloseViewWithCalculationDataTester.cs) (revision d6f67b18eba9be133de89079e68794b319c16233) @@ -259,6 +259,7 @@ /// Gets a calculation for testing purposes. /// /// A calculation object. + /// A default implementation is added for creating a . protected virtual ICalculation GetCalculation() { return new TestCalculation("Calculation"); @@ -268,6 +269,7 @@ /// Gets a calculation context for testing purposes. /// /// A calculation context object. + /// A default implementation is added for creating a . protected virtual ICalculationContext GetCalculationContextWithCalculation() { return new TestCalculationContext(); @@ -277,6 +279,7 @@ /// Gets a calculation group context for testing purposes. /// /// A calculation group context object. + /// A default implementation is added for creating a . protected virtual ICalculationContext GetCalculationGroupContextWithCalculation() { return new TestCalculationGroupContext(); @@ -286,6 +289,7 @@ /// Gets a failure mechanism context for testing purposes. /// /// A failure mechanism context object. + /// A default implementation is added for creating a . protected virtual IFailureMechanismContext GetFailureMechanismContextWithCalculation() { return new TestFailureMechanismContext(); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj =================================================================== diff -u -rf2c3b3ac67e3549f3a615298376b42ca5bf473c0 -rd6f67b18eba9be133de89079e68794b319c16233 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision f2c3b3ac67e3549f3a615298376b42ca5bf473c0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision d6f67b18eba9be133de89079e68794b319c16233) @@ -227,6 +227,10 @@ {4843D6E5-066F-4795-94F5-1D53932DD03C} Ringtoets.Common.Data.TestUtil + + {6346BADF-D331-4948-9772-08E8CD1E1FC9} + Ringtoets.Common.Plugin.TestUtil + {52093DA6-D545-476A-ADFD-12F56625E36B} Ringtoets.Common.Service.TestUtil Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/GeneralResultFaultTreeIllustrationPointViewInfoTest.cs =================================================================== diff -u -rb080cb9fb0858490cddf9f9f6bb043230146e4c2 -rd6f67b18eba9be133de89079e68794b319c16233 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/GeneralResultFaultTreeIllustrationPointViewInfoTest.cs (.../GeneralResultFaultTreeIllustrationPointViewInfoTest.cs) (revision b080cb9fb0858490cddf9f9f6bb043230146e4c2) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/GeneralResultFaultTreeIllustrationPointViewInfoTest.cs (.../GeneralResultFaultTreeIllustrationPointViewInfoTest.cs) (revision d6f67b18eba9be133de89079e68794b319c16233) @@ -19,8 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System.Collections.Generic; using System.Linq; +using Core.Common.Controls.Views; using Core.Common.Gui.Plugin; using Core.Common.TestUtil; using NUnit.Framework; @@ -34,6 +34,7 @@ using Ringtoets.Common.Data.TestUtil.IllustrationPoints; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.Views; +using Ringtoets.Common.Service.Test; using Ringtoets.HeightStructures.Data; using Ringtoets.HeightStructures.Forms.PresentationObjects; using Ringtoets.Integration.Data; @@ -101,560 +102,163 @@ Assert.AreSame(calculation, viewData); } - [Test] - [TestCaseSource(nameof(GetCalculationContextDatas), - new object[] - { - "CloseForData_CorrespondingToCalculationContext_ReturnTrue({0})" - })] - public void CloseForData_ViewCorrespondingToRemovedCalculationContext_ReturnsTrue( - ICalculationContext context, - IStructuresCalculation calculation) + public class ShouldCloseGeneralResultFaultTreeIllustrationPointViewForStructuresTester : ShouldCloseViewWithCalculationDataTester { - // Setup - using (var view = new GeneralResultFaultTreeIllustrationPointView(() => new TestGeneralResultFaultTreeIllustrationPoint()) + protected override bool PerformShouldCloseViewWithCalculationDataMethod(IView view, object o) { - Data = calculation - }) - { - // Call - bool closeForData = info.CloseForData(view, context); - - // Assert - Assert.IsTrue(closeForData); + using (var plugin = new RingtoetsPlugin()) + { + return plugin.GetViewInfos() + .First(tni => tni.ViewType == typeof(GeneralResultFaultTreeIllustrationPointView)) + .CloseForData(view, o); + } } - } - [Test] - [TestCaseSource(nameof(GetCalculationContextDatas), - new object[] + protected override IView GetView() { - "CloseForData_NotCorrespondingToCalculationContext_ReturnFalse({0})" - })] - public void CloseForData_ViewNotCorrespondingToRemovedCalculationContext_ReturnsFalse( - ICalculationContext context, - IStructuresCalculation calculation) - { - // Setup - var calculationToRemove = new TestStructuresCalculation(); - - using (var view = new GeneralResultFaultTreeIllustrationPointView(() => new TestGeneralResultFaultTreeIllustrationPoint()) - { - Data = calculationToRemove - }) - { - // Call - bool closeForData = info.CloseForData(view, context); - - // Assert - Assert.IsFalse(closeForData); + return new GeneralResultFaultTreeIllustrationPointView(() => new TestGeneralResultFaultTreeIllustrationPoint()); } } - [Test] - [TestCaseSource(nameof(GetCalculationGroupDatas), - new object[] - { - "CloseForData_CorrespondingWithCalculationGroupContext_ReturnTrue({0})" - })] - public void CloseForData_ViewCorrespondingWithRemovedCalculationGroupContext_ReturnsTrue( - ICalculationContext context, - IStructuresCalculation calculation) + [TestFixture] + public class ShouldCloseGeneralResultFaultTreeIllustrationPointViewForHeightStructuresTester : ShouldCloseGeneralResultFaultTreeIllustrationPointViewForStructuresTester { - // Setup - using (var view = new GeneralResultFaultTreeIllustrationPointView(() => new TestGeneralResultFaultTreeIllustrationPoint()) + protected override ICalculation GetCalculation() { - Data = calculation - }) - { - // Call - bool closeForData = info.CloseForData(view, context); - - // Assert - Assert.IsTrue(closeForData); + return new StructuresCalculation(); } - } - [Test] - [TestCaseSource(nameof(GetCalculationGroupDatas), - new object[] + protected override ICalculationContext GetCalculationContextWithCalculation() { - "CloseForData_NotCorrespondingWithCalculationGroupContext_ReturnFalse({0})" - })] - public void CloseForData_ViewNotCorrespondingWithRemovedCalculationGroupContext_ReturnsFalse( - ICalculationContext context, - IStructuresCalculation calculation) - { - // Setup - var contextToRemove = new HeightStructuresCalculationGroupContext(new CalculationGroup(), - new HeightStructuresFailureMechanism(), - new AssessmentSection(AssessmentSectionComposition.Dike)); - using (var view = new GeneralResultFaultTreeIllustrationPointView(() => new TestGeneralResultFaultTreeIllustrationPoint()) - { - Data = calculation - }) - { - // Call - bool closeForData = info.CloseForData(view, contextToRemove); - - // Assert - Assert.IsFalse(closeForData); + return new HeightStructuresCalculationContext( + new StructuresCalculation(), + new HeightStructuresFailureMechanism(), + new AssessmentSection(AssessmentSectionComposition.Dike)); } - } - [Test] - [TestCaseSource(nameof(GetFailureMechanismContextDatas), - new object[] + protected override ICalculationContext GetCalculationGroupContextWithCalculation() { - "CloseForData_CorrespondingWithFailureMechanismContext_ReturnTrue({0})" - })] - public void CloseForData_ViewCorrespondingWithRemovedFailureMechanismContext_ReturnsTrue( - IFailureMechanismContext context, - IStructuresCalculation calculation) - { - // Setup - using (var view = new GeneralResultFaultTreeIllustrationPointView(() => new TestGeneralResultFaultTreeIllustrationPoint()) - { - Data = calculation - }) - { - // Call - bool closeForData = info.CloseForData(view, context); - - // Assert - Assert.IsTrue(closeForData); + return new HeightStructuresCalculationGroupContext( + new CalculationGroup + { + Children = + { + new StructuresCalculation() + } + }, + new HeightStructuresFailureMechanism(), + new AssessmentSection(AssessmentSectionComposition.Dike)); } - } - [Test] - [TestCaseSource(nameof(GetFailureMechanismContextDatas), - new object[] + protected override IFailureMechanismContext GetFailureMechanismContextWithCalculation() { - "CloseForData_NotCorrespondingWithFailureMechanismContext_ReturnFalse({0})" - })] - public void CloseForData_ViewNotCorrespondingWithRemovedFailureMechanismContext_ReturnsFalse( - IFailureMechanismContext context, - IStructuresCalculation calculation) - { - // Setup - using (var view = new GeneralResultFaultTreeIllustrationPointView(() => new TestGeneralResultFaultTreeIllustrationPoint()) - { - Data = calculation - }) - { - // Call - bool closeForData = info.CloseForData(view, - new FailureMechanismContext( - new TestFailureMechanism(), - new AssessmentSection(AssessmentSectionComposition.Dike))); - - // Assert - Assert.IsFalse(closeForData); + return new HeightStructuresFailureMechanismContext( + new HeightStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + new StructuresCalculation() + } + } + }, + new AssessmentSection(AssessmentSectionComposition.Dike)); } } - [Test] - [TestCaseSource(nameof(GetFailureMechanismDatas), - new object[] - { - "CloseForData_CorrespondingWithFailureMechanism_ReturnTrue({0})" - })] - public void CloseForData_ViewCorrespondingWithRemovedFailureMechanism_ReturnsTrue( - IFailureMechanism failureMechanism, - IStructuresCalculation calculation) + [TestFixture] + public class ShouldCloseGeneralResultFaultTreeIllustrationPointViewForClosingStructuresTester : ShouldCloseGeneralResultFaultTreeIllustrationPointViewForStructuresTester { - // Setup - using (var view = new GeneralResultFaultTreeIllustrationPointView(() => new TestGeneralResultFaultTreeIllustrationPoint()) + protected override ICalculation GetCalculation() { - Data = calculation - }) - { - // Call - bool closeForData = info.CloseForData(view, failureMechanism); - - // Assert - Assert.IsTrue(closeForData); + return new StructuresCalculation(); } - } - [Test] - [TestCaseSource(nameof(GetFailureMechanismDatas), - new object[] + protected override ICalculationContext GetCalculationContextWithCalculation() { - "CloseForData_NotCorrespondingWithFailureMechanism_ReturnFalse({0})" - })] - public void CloseForData_ViewNotCorrespondingWithRemovedFailureMechanism_ReturnsFalse( - IFailureMechanism failureMechanism, - IStructuresCalculation calculation) - { - // Setup - using (var view = new GeneralResultFaultTreeIllustrationPointView(() => new TestGeneralResultFaultTreeIllustrationPoint()) - { - Data = calculation - }) - { - // Call - bool closeForData = info.CloseForData(view, new TestFailureMechanism()); - - // Assert - Assert.IsFalse(closeForData); + return new ClosingStructuresCalculationContext( + new StructuresCalculation(), + new ClosingStructuresFailureMechanism(), + new AssessmentSection(AssessmentSectionComposition.Dike)); } - } - [Test] - [TestCaseSource(nameof(GetAssessmentSectionDatas), - new object[] + protected override ICalculationContext GetCalculationGroupContextWithCalculation() { - "CloseForData_CorrespondingWithAssessmentSection_ReturnTrue({0})" - })] - public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue(AssessmentSection assessmentSection, - IStructuresCalculation calculation) - { - // Setup - using (var view = new GeneralResultFaultTreeIllustrationPointView(() => new TestGeneralResultFaultTreeIllustrationPoint()) - { - Data = calculation - }) - { - // Call - bool closeForData = info.CloseForData(view, assessmentSection); - - // Assert - Assert.IsTrue(closeForData); + return new ClosingStructuresCalculationGroupContext( + new CalculationGroup + { + Children = + { + new StructuresCalculation() + } + }, + new ClosingStructuresFailureMechanism(), + new AssessmentSection(AssessmentSectionComposition.Dike)); } - } - [Test] - [TestCaseSource(nameof(GetAssessmentSectionDatas), - new object[] + protected override IFailureMechanismContext GetFailureMechanismContextWithCalculation() { - "CloseForData_NotCorrespondingWithAssessmentSection_ReturnFalse({0})" - })] - public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse(AssessmentSection assessmentSection, - IStructuresCalculation calculation) - { - // Setup - using (var view = new GeneralResultFaultTreeIllustrationPointView(() => new TestGeneralResultFaultTreeIllustrationPoint()) - { - Data = new TestStructuresCalculation() - }) - { - // Call - bool closeForData = info.CloseForData(view, assessmentSection); - - // Assert - Assert.IsFalse(closeForData); + return new ClosingStructuresFailureMechanismContext( + new ClosingStructuresFailureMechanism + { + CalculationsGroup = + { + Children = + { + new StructuresCalculation() + } + } + }, + new AssessmentSection(AssessmentSectionComposition.Dike)); } } - [Test] - [TestCaseSource(nameof(GetCalculationGroupDatas), - new object[] - { - "CloseForData_NestedCorrespondingWithCalculationGroupContext_ReturnTrue({0})" - })] - public void CloseForData_NestedViewCorrespondingWithRemovedCalculationGroupContext_ReturnsTrue( - ICalculationContext context, - IStructuresCalculation calculation) + [TestFixture] + public class ShouldCloseGeneralResultFaultTreeIllustrationPointViewForStabilityPointStructuresTester : ShouldCloseGeneralResultFaultTreeIllustrationPointViewForStructuresTester { - // Setup - context.WrappedData.Children.RemoveAt(0); - context.WrappedData.Children.Add(new CalculationGroup + protected override ICalculation GetCalculation() { - Children = - { - calculation - } - }); - - using (var view = new GeneralResultFaultTreeIllustrationPointView(() => new TestGeneralResultFaultTreeIllustrationPoint()) - { - Data = calculation - }) - { - // Call - bool closeForData = info.CloseForData(view, context); - - // Assert - Assert.IsTrue(closeForData); + return new StructuresCalculation(); } - } - [Test] - [TestCaseSource(nameof(GetCalculationGroupDatas), - new object[] + protected override ICalculationContext GetCalculationContextWithCalculation() { - "CloseForData_NestedNotCorrespondingWithCalculationGroupContext_ReturnFalse({0})" - })] - public void CloseForData_NestedViewNotCorrespondingWithRemovedCalculationGroupContext_ReturnsFalse( - ICalculationContext context, - IStructuresCalculation calculation) - { - // Setup - context.WrappedData.Children.RemoveAt(0); - context.WrappedData.Children.Add(new CalculationGroup - { - Children = - { - calculation - } - }); - - var contextToRemove = new HeightStructuresCalculationGroupContext(new CalculationGroup(), - new HeightStructuresFailureMechanism(), - new AssessmentSection(AssessmentSectionComposition.Dike)); - using (var view = new GeneralResultFaultTreeIllustrationPointView(() => new TestGeneralResultFaultTreeIllustrationPoint()) - { - Data = calculation - }) - { - // Call - bool closeForData = info.CloseForData(view, contextToRemove); - - // Assert - Assert.IsFalse(closeForData); + return new StabilityPointStructuresCalculationContext( + new StructuresCalculation(), + new StabilityPointStructuresFailureMechanism(), + new AssessmentSection(AssessmentSectionComposition.Dike)); } - } - #region TestCaseData - - private static IEnumerable GetCalculationContextDatas(string testNameFormat) - { - var heightStructuresCalculation = new StructuresCalculation(); - yield return new TestCaseData( - new HeightStructuresCalculationContext( - heightStructuresCalculation, - new HeightStructuresFailureMechanism(), - new AssessmentSection(AssessmentSectionComposition.Dike)), - heightStructuresCalculation) - .SetName(string.Format(testNameFormat, "HeightStructuresCalculation")); - - var closingStructuresCalculation = new StructuresCalculation(); - yield return new TestCaseData( - new ClosingStructuresCalculationContext( - closingStructuresCalculation, - new ClosingStructuresFailureMechanism(), - new AssessmentSection(AssessmentSectionComposition.Dike)), - closingStructuresCalculation) - .SetName(string.Format(testNameFormat, "ClosingStructuresCalculation")); - - var stabilityPointStructuresCalculation = new StructuresCalculation(); - yield return new TestCaseData( - new StabilityPointStructuresCalculationContext( - stabilityPointStructuresCalculation, - new StabilityPointStructuresFailureMechanism(), - new AssessmentSection(AssessmentSectionComposition.Dike)), - stabilityPointStructuresCalculation) - .SetName(string.Format(testNameFormat, "StabilityPointStructuresCalculation")); - } - - private static IEnumerable GetFailureMechanismDatas(string testNameFormat) - { - var heightStructuresCalculation = new StructuresCalculation(); - yield return new TestCaseData( - GetFailureMechanism(heightStructuresCalculation), - heightStructuresCalculation) - .SetName(string.Format(testNameFormat, - nameof(HeightStructuresFailureMechanism))); - - var closingStructuresCalculation = new StructuresCalculation(); - yield return new TestCaseData( - GetFailureMechanism(closingStructuresCalculation), - closingStructuresCalculation) - .SetName(string.Format(testNameFormat, - nameof(ClosingStructuresFailureMechanism))); - - var stabilityPointStructuresCalculation = new StructuresCalculation(); - yield return new TestCaseData( - GetFailureMechanism(stabilityPointStructuresCalculation), - stabilityPointStructuresCalculation) - .SetName(string.Format(testNameFormat, - nameof(StabilityPointStructuresFailureMechanism))); - } - - private static IEnumerable GetFailureMechanismContextDatas(string testNameFormat) - { - var heightStructuresCalculation = new StructuresCalculation(); - yield return new TestCaseData( - new HeightStructuresFailureMechanismContext( - GetFailureMechanism(heightStructuresCalculation), - new AssessmentSection(AssessmentSectionComposition.Dike)), - heightStructuresCalculation) - .SetName(string.Format(testNameFormat, - nameof(HeightStructuresFailureMechanismContext))); - - var closingStructuresCalculation = new StructuresCalculation(); - yield return new TestCaseData( - new ClosingStructuresFailureMechanismContext( - GetFailureMechanism(closingStructuresCalculation), - new AssessmentSection(AssessmentSectionComposition.Dike)), - closingStructuresCalculation) - .SetName(string.Format(testNameFormat, - nameof(ClosingStructuresFailureMechanismContext))); - - var stabilityPointStructuresCalculation = new StructuresCalculation(); - yield return new TestCaseData( - new StabilityPointStructuresFailureMechanismContext( - GetFailureMechanism(stabilityPointStructuresCalculation), - new AssessmentSection(AssessmentSectionComposition.Dike)), - stabilityPointStructuresCalculation) - .SetName(string.Format(testNameFormat, - nameof(StabilityPointStructuresFailureMechanismContext))); - } - - private static IEnumerable GetCalculationGroupDatas(string testNameFormat) - { - var heightStructuresCalculation = new StructuresCalculation(); - yield return new TestCaseData( - new HeightStructuresCalculationGroupContext( - new CalculationGroup - { - Children = - { - heightStructuresCalculation - } - }, - new HeightStructuresFailureMechanism(), - new AssessmentSection(AssessmentSectionComposition.Dike)), - heightStructuresCalculation) - .SetName(string.Format(testNameFormat, - nameof(HeightStructuresCalculationGroupContext))); - - var closingStructuresCalculation = new StructuresCalculation(); - yield return new TestCaseData( - new ClosingStructuresCalculationGroupContext( - new CalculationGroup - { - Children = - { - closingStructuresCalculation - } - }, - new ClosingStructuresFailureMechanism(), - new AssessmentSection(AssessmentSectionComposition.Dike)), - closingStructuresCalculation) - .SetName(string.Format(testNameFormat, - nameof(ClosingStructuresCalculationGroupContext))); - - var stabilityPointStructuresCalculation = new StructuresCalculation(); - yield return new TestCaseData( - new StabilityPointStructuresCalculationGroupContext( - new CalculationGroup - { - Children = - { - stabilityPointStructuresCalculation - } - }, - new StabilityPointStructuresFailureMechanism(), - new AssessmentSection(AssessmentSectionComposition.Dike)), - stabilityPointStructuresCalculation) - .SetName(string.Format(testNameFormat, - nameof(StabilityPointStructuresCalculationGroupContext))); - } - - private static IEnumerable GetAssessmentSectionDatas(string testNameFormat) - { - var heightStructuresCalculation = new StructuresCalculation(); - yield return new TestCaseData( - new AssessmentSection(AssessmentSectionComposition.Dike) + protected override ICalculationContext GetCalculationGroupContextWithCalculation() + { + return new StabilityPointStructuresCalculationGroupContext( + new CalculationGroup { - HeightStructures = + Children = { - CalculationsGroup = - { - Children = - { - heightStructuresCalculation - } - } + new StructuresCalculation() } }, - heightStructuresCalculation) - .SetName(string.Format(testNameFormat, - "assessmentSectionHeightStructures")); + new StabilityPointStructuresFailureMechanism(), + new AssessmentSection(AssessmentSectionComposition.Dike)); + } - var closingStructuresCalculation = new StructuresCalculation(); - yield return new TestCaseData( - new AssessmentSection(AssessmentSectionComposition.Dike) + protected override IFailureMechanismContext GetFailureMechanismContextWithCalculation() + { + return new StabilityPointStructuresFailureMechanismContext( + new StabilityPointStructuresFailureMechanism { - ClosingStructures = + CalculationsGroup = { - CalculationsGroup = + Children = { - Children = - { - closingStructuresCalculation - } + new StructuresCalculation() } } }, - closingStructuresCalculation) - .SetName(string.Format(testNameFormat, - "assessmentSectionClosingStructures")); - - var stabilityPointStructuresCalculation = new StructuresCalculation(); - yield return new TestCaseData( - new AssessmentSection(AssessmentSectionComposition.Dike) - { - StabilityPointStructures = - { - CalculationsGroup = - { - Children = - { - stabilityPointStructuresCalculation - } - } - } - }, - stabilityPointStructuresCalculation) - .SetName(string.Format(testNameFormat, - "assessmentSectionStabilityPointStructures")); + new AssessmentSection(AssessmentSectionComposition.Dike)); + } } - - private static HeightStructuresFailureMechanism GetFailureMechanism(StructuresCalculation calculation) - { - return new HeightStructuresFailureMechanism - { - CalculationsGroup = - { - Children = - { - calculation - } - } - }; - } - - private static ClosingStructuresFailureMechanism GetFailureMechanism(StructuresCalculation calculation) - { - return new ClosingStructuresFailureMechanism - { - CalculationsGroup = - { - Children = - { - calculation - } - } - }; - } - - private static StabilityPointStructuresFailureMechanism GetFailureMechanism(StructuresCalculation calculation) - { - return new StabilityPointStructuresFailureMechanism - { - CalculationsGroup = - { - Children = - { - calculation - } - } - }; - } - - #endregion } } \ No newline at end of file