Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Factories/WaterPressureAsphaltCoverAssemblyMapDataFeaturesFactory.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Factories/WaterPressureAsphaltCoverAssemblyMapDataFeaturesFactory.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Factories/WaterPressureAsphaltCoverAssemblyMapDataFeaturesFactory.cs (revision 04700304da9df7d33beab0c2482521ba1c252ba7) @@ -0,0 +1,94 @@ +// Copyright (C) Stichting Deltares 2018. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using Core.Components.Gis.Features; +using Ringtoets.Common.Forms.Factories; +using Ringtoets.Integration.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.AssemblyFactories; +using Ringtoets.Integration.Data.StandAlone.SectionResults; + +namespace Ringtoets.Integration.Forms.Factories +{ + /// + /// Factory for creating collections of for assembly results in a . + /// + public static class WaterPressureAsphaltCoverAssemblyMapDataFeaturesFactory + { + /// + /// Creates features for the simple assembly results in . + /// + /// The to create the features for. + /// A collection of . + /// Thrown when + /// is null. + public static IEnumerable CreateSimpleAssemblyFeatures(WaterPressureAsphaltCoverFailureMechanism failureMechanism) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures( + failureMechanism, + WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleSimpleAssessment); + } + + /// + /// Creates features for the tailor made assembly results in . + /// + /// The to create the features for. + /// A collection of . + /// Thrown when + /// is null. + public static IEnumerable CreateTailorMadeAssemblyFeatures(WaterPressureAsphaltCoverFailureMechanism failureMechanism) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures( + failureMechanism, + WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment); + } + + /// + /// Creates features for the combined assembly results in . + /// + /// The to create the features for. + /// A collection of . + /// Thrown when + /// is null. + public static IEnumerable CreateCombinedAssemblyFeatures(WaterPressureAsphaltCoverFailureMechanism failureMechanism) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + return AssemblyMapDataFeaturesFactory.CreateAssemblyCategoryGroupFeatures( + failureMechanism, + WaterPressureAsphaltCoverFailureMechanismAssemblyFactory.AssembleCombinedAssessment); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj =================================================================== diff -u -r478a735f1898614f13c7f625353b89c0d35726d6 -r04700304da9df7d33beab0c2482521ba1c252ba7 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 478a735f1898614f13c7f625353b89c0d35726d6) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 04700304da9df7d33beab0c2482521ba1c252ba7) @@ -20,6 +20,7 @@ + @@ -137,12 +138,6 @@ FailureMechanismWithDetailedAssessmentView.cs - - UserControl - - - FailureMechanismView.cs - UserControl @@ -370,9 +365,6 @@ FailureMechanismWithDetailedAssessmentView.cs - - FailureMechanismView.cs - MacroStabilityOutwardsAssemblyCategoriesView.cs Fisheye: Tag 04700304da9df7d33beab0c2482521ba1c252ba7 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismView.Designer.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 04700304da9df7d33beab0c2482521ba1c252ba7 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismView.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 04700304da9df7d33beab0c2482521ba1c252ba7 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismView.resx'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -r478a735f1898614f13c7f625353b89c0d35726d6 -r04700304da9df7d33beab0c2482521ba1c252ba7 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 478a735f1898614f13c7f625353b89c0d35726d6) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 04700304da9df7d33beab0c2482521ba1c252ba7) @@ -543,14 +543,13 @@ () => TechnicalInnovationAssemblyMapDataFeaturesFactory.CreateTailorMadeAssemblyFeatures(context.WrappedData), () => TechnicalInnovationAssemblyMapDataFeaturesFactory.CreateCombinedAssemblyFeatures(context.WrappedData))); - yield return new ViewInfo, FailureMechanismView> - { - GetViewName = (view, context) => context.WrappedData.Name, - Image = RingtoetsCommonFormsResources.CalculationIcon, - CloseForData = CloseFailureMechanismViewForData, - AdditionalDataCheck = context => context.WrappedData.IsRelevant, - CreateInstance = context => new FailureMechanismView(context.WrappedData, context.Parent) - }; + yield return CreateFailureMechanismWithoutDetailedAssessmentViewInfo( + context => new FailureMechanismWithoutDetailedAssessmentView( + context.WrappedData, + context.Parent, + () => WaterPressureAsphaltCoverAssemblyMapDataFeaturesFactory.CreateSimpleAssemblyFeatures(context.WrappedData), + () => WaterPressureAsphaltCoverAssemblyMapDataFeaturesFactory.CreateTailorMadeAssemblyFeatures(context.WrappedData), + () => WaterPressureAsphaltCoverAssemblyMapDataFeaturesFactory.CreateCombinedAssemblyFeatures(context.WrappedData))); yield return CreateFailureMechanismResultViewInfo< GrassCoverSlipOffInwardsFailureMechanism, @@ -1381,20 +1380,6 @@ #endregion - #region FailureMechanismView ViewInfo - - private static bool CloseFailureMechanismViewForData(FailureMechanismView view, object o) - { - var assessmentSection = o as IAssessmentSection; - var failureMechanism = o as IFailureMechanism; - - return assessmentSection != null - ? ReferenceEquals(view.AssessmentSection, assessmentSection) - : ReferenceEquals(view.FailureMechanism, failureMechanism); - } - - #endregion - #region FailureMechanismContributionContext ViewInfo private static bool CloseFailureMechanismContributionViewForData(FailureMechanismContributionView view, object o) Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Factories/WaterPressureAsphaltCoverAssemblyMapDataFeaturesFactoryTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Factories/WaterPressureAsphaltCoverAssemblyMapDataFeaturesFactoryTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Factories/WaterPressureAsphaltCoverAssemblyMapDataFeaturesFactoryTest.cs (revision 04700304da9df7d33beab0c2482521ba1c252ba7) @@ -0,0 +1,144 @@ +// Copyright (C) Stichting Deltares 2018. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using Core.Common.TestUtil; +using Core.Components.Gis.Features; +using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.TestUtil; +using Ringtoets.Integration.Data.StandAlone; +using Ringtoets.Integration.Forms.Factories; + +namespace Ringtoets.Integration.Forms.Test.Factories +{ + [TestFixture] + public class WaterPressureAsphaltCoverAssemblyMapDataFeaturesFactoryTest + { + [Test] + public void CreateSimpleAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => WaterPressureAsphaltCoverAssemblyMapDataFeaturesFactory.CreateSimpleAssemblyFeatures(null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("failureMechanism", paramName); + } + + [Test] + public void CreateSimpleAssemblyFeatures_WithValidData_ReturnsFeaturesCollection() + { + // Setup + var random = new Random(39); + var failureMechanism = new WaterPressureAsphaltCoverFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(0, 10)); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + calculator.SimpleAssessmentAssemblyOutput = new FailureMechanismSectionAssembly(random.NextDouble(), + random.NextEnumValue()); + + // Call + IEnumerable features = WaterPressureAsphaltCoverAssemblyMapDataFeaturesFactory.CreateSimpleAssemblyFeatures(failureMechanism); + + // Assert + MapFeaturesTestHelper.AssertAssemblyCategoryGroupMapFeatures(calculator.SimpleAssessmentAssemblyOutput.Group, failureMechanism, features); + } + } + + [Test] + public void CreateTailorMadeAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => WaterPressureAsphaltCoverAssemblyMapDataFeaturesFactory.CreateTailorMadeAssemblyFeatures(null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("failureMechanism", paramName); + } + + [Test] + public void CreateTailorMadeAssemblyFeatures_WithValidData_ReturnsFeaturesCollection() + { + // Setup + var random = new Random(39); + var failureMechanism = new WaterPressureAsphaltCoverFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(0, 10)); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + calculator.TailorMadeAssemblyCategoryOutput = random.NextEnumValue(); + + // Call + IEnumerable features = WaterPressureAsphaltCoverAssemblyMapDataFeaturesFactory.CreateTailorMadeAssemblyFeatures(failureMechanism); + + // Assert + MapFeaturesTestHelper.AssertAssemblyCategoryGroupMapFeatures(calculator.TailorMadeAssemblyCategoryOutput.Value, failureMechanism, features); + } + } + + [Test] + public void CreateCombinedAssemblyFeatures_FailureMechanismNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => WaterPressureAsphaltCoverAssemblyMapDataFeaturesFactory.CreateCombinedAssemblyFeatures(null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("failureMechanism", paramName); + } + + [Test] + public void CreateCombinedAssemblyFeatures_WithValidData_ReturnsFeaturesCollection() + { + // Setup + var random = new Random(39); + var failureMechanism = new WaterPressureAsphaltCoverFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, random.Next(0, 10)); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + + calculator.CombinedAssemblyCategoryOutput = random.NextEnumValue(); + + // Call + IEnumerable features = WaterPressureAsphaltCoverAssemblyMapDataFeaturesFactory.CreateCombinedAssemblyFeatures(failureMechanism); + + // Assert + MapFeaturesTestHelper.AssertAssemblyCategoryGroupMapFeatures(calculator.CombinedAssemblyCategoryOutput.Value, failureMechanism, features); + } + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj =================================================================== diff -u -r478a735f1898614f13c7f625353b89c0d35726d6 -r04700304da9df7d33beab0c2482521ba1c252ba7 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 478a735f1898614f13c7f625353b89c0d35726d6) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 04700304da9df7d33beab0c2482521ba1c252ba7) @@ -35,6 +35,7 @@ + @@ -96,7 +97,6 @@ - Fisheye: Tag 04700304da9df7d33beab0c2482521ba1c252ba7 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/FailureMechanismViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj =================================================================== diff -u -r570913df78640ee38f91c9fa6f95e2b14f44ddf7 -r04700304da9df7d33beab0c2482521ba1c252ba7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 570913df78640ee38f91c9fa6f95e2b14f44ddf7) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 04700304da9df7d33beab0c2482521ba1c252ba7) @@ -151,6 +151,8 @@ + + @@ -162,7 +164,6 @@ - Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs =================================================================== diff -u -r478a735f1898614f13c7f625353b89c0d35726d6 -r04700304da9df7d33beab0c2482521ba1c252ba7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 478a735f1898614f13c7f625353b89c0d35726d6) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 04700304da9df7d33beab0c2482521ba1c252ba7) @@ -427,11 +427,6 @@ PluginTestHelper.AssertViewInfoDefined( viewInfos, - typeof(IFailureMechanismContext), - typeof(FailureMechanismView)); - - PluginTestHelper.AssertViewInfoDefined( - viewInfos, typeof(FailureMechanismSectionResultContext), typeof(IObservableEnumerable), typeof(StrengthStabilityLengthwiseConstructionResultView)); @@ -559,6 +554,11 @@ viewInfos, typeof(TechnicalInnovationFailureMechanismContext), typeof(FailureMechanismWithoutDetailedAssessmentView)); + + PluginTestHelper.AssertViewInfoDefined( + viewInfos, + typeof(WaterPressureAsphaltCoverFailureMechanismContext), + typeof(FailureMechanismWithoutDetailedAssessmentView)); } } Fisheye: Tag 04700304da9df7d33beab0c2482521ba1c252ba7 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/FailureMechanismViewInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaterPressureAsphaltCoverFailureMechanismViewInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaterPressureAsphaltCoverFailureMechanismViewInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaterPressureAsphaltCoverFailureMechanismViewInfoTest.cs (revision 04700304da9df7d33beab0c2482521ba1c252ba7) @@ -0,0 +1,234 @@ +// Copyright (C) Stichting Deltares 2018. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Drawing; +using System.Linq; +using Core.Common.Controls.Views; +using Core.Common.Gui.Plugin; +using Core.Common.TestUtil; +using Core.Components.Gis.Features; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Integration.Data.StandAlone; +using Ringtoets.Integration.Data.StandAlone.SectionResults; +using Ringtoets.Integration.Forms.PresentationObjects.StandAlone; +using Ringtoets.Integration.Forms.Views; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Plugin.Test.ViewInfos +{ + [TestFixture] + public class WaterPressureAsphaltCoverFailureMechanismViewInfoTest + { + 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(FailureMechanismWithoutDetailedAssessmentView)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(WaterPressureAsphaltCoverFailureMechanismContext), info.DataType); + Assert.AreEqual(typeof(WaterPressureAsphaltCoverFailureMechanismContext), info.ViewDataType); + } + + [Test] + public void GetViewName_WithFailureMechanismContext_ReturnsNameOfFailureMechanism() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaterPressureAsphaltCoverFailureMechanism(); + var failureMechanismContext = new WaterPressureAsphaltCoverFailureMechanismContext(failureMechanism, assessmentSection); + + // Call + string viewName = info.GetViewName(null, failureMechanismContext); + + // Assert + Assert.AreEqual(failureMechanism.Name, viewName); + } + + [Test] + public void Image_Always_ReturnsGenericInputOutputIcon() + { + // Call + Image image = info.Image; + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CalculationIcon, image); + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() + { + // Setup + var assessmentSection = new AssessmentSectionStub(); + var otherAssessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaterPressureAsphaltCoverFailureMechanism(); + + using (FailureMechanismWithoutDetailedAssessmentView view = + CreateView(failureMechanism, assessmentSection)) + { + // Call + bool closeForData = info.CloseForData(view, otherAssessmentSection); + + // Assert + Assert.IsFalse(closeForData); + } + + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() + { + // Setup + var assessmentSection = new AssessmentSectionStub(); + var failureMechanism = new WaterPressureAsphaltCoverFailureMechanism(); + + using (FailureMechanismWithoutDetailedAssessmentView view = + CreateView(failureMechanism, assessmentSection)) + { + // Call + bool closeForData = info.CloseForData(view, assessmentSection); + + // Assert + Assert.IsTrue(closeForData); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnsFalse() + { + // Setup + var assessmentSection = new AssessmentSectionStub(); + var failureMechanism = new WaterPressureAsphaltCoverFailureMechanism(); + var otherFailureMechanism = new WaterPressureAsphaltCoverFailureMechanism(); + + using (FailureMechanismWithoutDetailedAssessmentView view = + CreateView(failureMechanism, assessmentSection)) + { + // Call + bool closeForData = info.CloseForData(view, otherFailureMechanism); + + // Assert + Assert.IsFalse(closeForData); + } + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnsTrue() + { + // Setup + var assessmentSection = new AssessmentSectionStub(); + var failureMechanism = new WaterPressureAsphaltCoverFailureMechanism(); + + using (FailureMechanismWithoutDetailedAssessmentView view = + CreateView(failureMechanism, assessmentSection)) + { + // Call + bool closeForData = info.CloseForData(view, failureMechanism); + + // Assert + Assert.IsTrue(closeForData); + } + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void AdditionalDataCheck_Always_ReturnTrueOnlyIfFailureMechanismRelevant(bool isRelevant) + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaterPressureAsphaltCoverFailureMechanism + { + IsRelevant = isRelevant + }; + + var context = new WaterPressureAsphaltCoverFailureMechanismContext(failureMechanism, assessmentSection); + + // Call + bool result = info.AdditionalDataCheck(context); + + // Assert + Assert.AreEqual(isRelevant, result); + mocks.VerifyAll(); + } + + [Test] + public void CreateInstance_WithData_ReturnFailureMechanismView() + { + // Setup + var assessmentSection = new AssessmentSectionStub(); + var failureMechanism = new WaterPressureAsphaltCoverFailureMechanism(); + + var context = new WaterPressureAsphaltCoverFailureMechanismContext(failureMechanism, assessmentSection); + + // Call + IView view = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf>(view); + + var failureMechanismView = (FailureMechanismWithoutDetailedAssessmentView) view; + Assert.AreSame(failureMechanism, failureMechanismView.FailureMechanism); + Assert.AreSame(assessmentSection, failureMechanismView.AssessmentSection); + } + + private static FailureMechanismWithoutDetailedAssessmentView CreateView( + WaterPressureAsphaltCoverFailureMechanism failureMechanism, IAssessmentSection assessmentSection) + { + return new FailureMechanismWithoutDetailedAssessmentView( + failureMechanism, + assessmentSection, + Enumerable.Empty, + Enumerable.Empty, + Enumerable.Empty); + } + } +} \ No newline at end of file