Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssessmentSectionAssemblyCategoriesView.cs =================================================================== diff -u -rf656ad7d168ebf3ac3a3e906ec8c8a88f9806ad9 -rebca6343380bd74afcdb2c0bf4f98de0844c07af --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssessmentSectionAssemblyCategoriesView.cs (.../AssessmentSectionAssemblyCategoriesView.cs) (revision f656ad7d168ebf3ac3a3e906ec8c8a88f9806ad9) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssessmentSectionAssemblyCategoriesView.cs (.../AssessmentSectionAssemblyCategoriesView.cs) (revision ebca6343380bd74afcdb2c0bf4f98de0844c07af) @@ -25,7 +25,7 @@ using Core.Common.Controls.Views; using Ringtoets.AssemblyTool.Data; using Ringtoets.Common.Data.AssemblyTool; -using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Contribution; namespace Ringtoets.Integration.Forms.Views { @@ -39,32 +39,32 @@ /// /// Creates a new instance of . /// - /// The assessment section the view belongs to. - /// Thrown when + /// The failure mechanism contribution belonging to the view. + /// Thrown when /// is null. - public AssessmentSectionAssemblyCategoriesView(IAssessmentSection assessmentSection) + public AssessmentSectionAssemblyCategoriesView(FailureMechanismContribution failureMechanismContribution) { - if (assessmentSection == null) + if (failureMechanismContribution == null) { - throw new ArgumentNullException(nameof(assessmentSection)); + throw new ArgumentNullException(nameof(failureMechanismContribution)); } InitializeComponent(); failureMechanismContributionObserver = new Observer(UpdateTableData) { - Observable = assessmentSection.FailureMechanismContribution + Observable = failureMechanismContribution }; - AssessmentSection = assessmentSection; + FailureMechanismContribution = failureMechanismContribution; UpdateTableData(); } /// - /// Gets the the view belongs to. + /// Gets the the view belongs to. /// - public IAssessmentSection AssessmentSection { get; } + public FailureMechanismContribution FailureMechanismContribution { get; } public object Data { get; set; } @@ -87,8 +87,8 @@ private void UpdateTableData() { assessmentSectionAssemblyCategoriesTable.SetData(AssemblyToolCategoriesFactory.CreateAssessmentSectionAssemblyCategories( - AssessmentSection.FailureMechanismContribution.SignalingNorm, - AssessmentSection.FailureMechanismContribution.LowerLimitNorm)); + FailureMechanismContribution.SignalingNorm, + FailureMechanismContribution.LowerLimitNorm)); } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -r72d74ba7563680f48c3774676573aaf1efb548fb -rebca6343380bd74afcdb2c0bf4f98de0844c07af --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 72d74ba7563680f48c3774676573aaf1efb548fb) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision ebca6343380bd74afcdb2c0bf4f98de0844c07af) @@ -399,6 +399,14 @@ AfterCreate = (view, context) => view.AssessmentSection = context.Parent }; + yield return new ViewInfo + { + GetViewName = (view, context) => RingtoetsCommonFormsResources.Norms_DisplayName, + Image = RingtoetsCommonFormsResources.NormsIcon, + CloseForData = CloseAssessmentSectionCategoriesViewForData, + CreateInstance = context => new AssessmentSectionAssemblyCategoriesView(context.AssessmentSection.FailureMechanismContribution) + }; + yield return new ViewInfo, DesignWaterLevelCalculationsView> { GetViewName = (view, context) => $"{RingtoetsFormsResources.DesignWaterLevelCalculationsContext_DisplayName} - {context.CategoryBoundaryName}", @@ -1065,6 +1073,16 @@ #endregion + #region NormContext ViewInfo + + private static bool CloseAssessmentSectionCategoriesViewForData(AssessmentSectionAssemblyCategoriesView view, object o) + { + var assessmentSection = o as IAssessmentSection; + return assessmentSection != null && assessmentSection.FailureMechanismContribution == view.FailureMechanismContribution; + } + + #endregion + #region FailureMechanismResults ViewInfo private static bool CloseFailureMechanismResultViewForData(TView view, object dataToCloseFor) Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssessmentSectionAssemblyCategoriesViewTest.cs =================================================================== diff -u -rf656ad7d168ebf3ac3a3e906ec8c8a88f9806ad9 -rebca6343380bd74afcdb2c0bf4f98de0844c07af --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssessmentSectionAssemblyCategoriesViewTest.cs (.../AssessmentSectionAssemblyCategoriesViewTest.cs) (revision f656ad7d168ebf3ac3a3e906ec8c8a88f9806ad9) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssessmentSectionAssemblyCategoriesViewTest.cs (.../AssessmentSectionAssemblyCategoriesViewTest.cs) (revision ebca6343380bd74afcdb2c0bf4f98de0844c07af) @@ -30,6 +30,7 @@ using Ringtoets.AssemblyTool.KernelWrapper.Calculators; using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Categories; +using Ringtoets.Common.Data.Contribution; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.TestUtil; using Ringtoets.Integration.Forms.Views; @@ -40,32 +41,32 @@ public class AssessmentSectionAssemblyCategoriesViewTest { [Test] - public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() + public void Constructor_FailureMechanismContributionNull_ThrowsArgumentNullException() { // Call TestDelegate test = () => new AssessmentSectionAssemblyCategoriesView(null); // Assert string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("assessmentSection", paramName); + Assert.AreEqual("failureMechanismContribution", paramName); } [Test] public void Constructor_WithData_CreatesViewAndTableWithData() { // Setup - var assessmentSection = new ObservableTestAssessmentSectionStub(); + FailureMechanismContribution failureMechanismContribution = FailureMechanismContributionTestFactory.CreateFailureMechanismContribution(); // Call using (new AssemblyToolCalculatorFactoryConfig()) - using (var view = new AssessmentSectionAssemblyCategoriesView(assessmentSection)) + using (var view = new AssessmentSectionAssemblyCategoriesView(failureMechanismContribution)) { // Assert Assert.IsInstanceOf(view); Assert.IsInstanceOf(view); Assert.IsNull(view.Data); Assert.AreEqual(1, view.Controls.Count); - Assert.AreSame(assessmentSection, view.AssessmentSection); + Assert.AreSame(failureMechanismContribution, view.FailureMechanismContribution); AssessmentSectionAssemblyCategoriesTable tableControl = GetCategoriesTable(view); Assert.NotNull(tableControl); @@ -75,21 +76,21 @@ } [Test] - public void GivenViewWithAssessmentSection_WhenAssessmentSectionUpdated_ThenDataTableUpdated() + public void GivenViewWithFailureMechanismContribution_WhenFailureMechanismContributionUpdated_ThenDataTableUpdated() { // Given var mocks = new MockRepository(); var observer = mocks.StrictMock(); observer.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); - var assessmentSection = new ObservableTestAssessmentSectionStub(); + FailureMechanismContribution failureMechanismContribution = FailureMechanismContributionTestFactory.CreateFailureMechanismContribution(); using (new AssemblyToolCalculatorFactoryConfig()) - using (var view = new AssessmentSectionAssemblyCategoriesView(assessmentSection)) + using (var view = new AssessmentSectionAssemblyCategoriesView(failureMechanismContribution)) { AssessmentSectionAssemblyCategoriesTable categoriesTable = GetCategoriesTable(view); - assessmentSection.FailureMechanismContribution.Attach(observer); + failureMechanismContribution.Attach(observer); // Precondition Assert.AreEqual(3, categoriesTable.Rows.Count); @@ -102,7 +103,7 @@ { new AssessmentSectionAssemblyCategory(1, 2, AssessmentSectionAssemblyCategoryGroup.A) }; - assessmentSection.FailureMechanismContribution.NotifyObservers(); + failureMechanismContribution.NotifyObservers(); // Then Assert.AreEqual(1, categoriesTable.Rows.Count); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj =================================================================== diff -u -r2d3979f45682cd0678d8210208c468bee4095619 -rebca6343380bd74afcdb2c0bf4f98de0844c07af --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 2d3979f45682cd0678d8210208c468bee4095619) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision ebca6343380bd74afcdb2c0bf4f98de0844c07af) @@ -98,6 +98,7 @@ + @@ -177,6 +178,10 @@ {F0FB401A-3494-4237-9E6D-02CDF77912A8} Core.Components.Gis.TestUtil + + {0AB432BB-E2CC-42EA-A72C-7AFEF7536B38} + Ringtoets.AssemblyTool.KernelWrapper.TestUtil + {c6309704-d67b-434c-bc98-9f8910bc1d10} Ringtoets.ClosingStructures.Data Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs =================================================================== diff -u -rc602baeb36d745d3a356bd7832e132cb21cad711 -rebca6343380bd74afcdb2c0bf4f98de0844c07af --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision c602baeb36d745d3a356bd7832e132cb21cad711) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision ebca6343380bd74afcdb2c0bf4f98de0844c07af) @@ -368,7 +368,7 @@ ViewInfo[] viewInfos = plugin.GetViewInfos().ToArray(); // Assert - Assert.AreEqual(17, viewInfos.Length); + Assert.AreEqual(18, viewInfos.Length); PluginTestHelper.AssertViewInfoDefined( viewInfos, @@ -378,6 +378,12 @@ PluginTestHelper.AssertViewInfoDefined( viewInfos, + typeof(NormContext), + typeof(FailureMechanismContribution), + typeof(AssessmentSectionAssemblyCategoriesView)); + + PluginTestHelper.AssertViewInfoDefined( + viewInfos, typeof(DesignWaterLevelCalculationsContext), typeof(IEnumerable), typeof(DesignWaterLevelCalculationsView)); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/AssessmentSectionAssemblyCategoriesViewInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/AssessmentSectionAssemblyCategoriesViewInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/AssessmentSectionAssemblyCategoriesViewInfoTest.cs (revision ebca6343380bd74afcdb2c0bf4f98de0844c07af) @@ -0,0 +1,147 @@ +// Copyright (C) Stichting Deltares 2017. 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.Drawing; +using System.Linq; +using Core.Common.Gui.Plugin; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Contribution; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.Integration.Forms.Views; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Plugin.Test.ViewInfos +{ + [TestFixture] + public class AssessmentSectionAssemblyCategoriesViewInfoTest + { + 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(AssessmentSectionAssemblyCategoriesView)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(NormContext), info.DataType); + Assert.AreEqual(typeof(FailureMechanismContribution), info.ViewDataType); + } + + [Test] + public void GetViewName_Always_ReturnsViewName() + { + // Call + string viewName = info.GetViewName(null, null); + + // Assert + Assert.AreEqual("Normen", viewName); + } + + [Test] + public void ViewType_Always_ReturnsViewType() + { + // Call + Type viewType = info.ViewType; + + // Assert + Assert.AreEqual(typeof(AssessmentSectionAssemblyCategoriesView), viewType); + } + + [Test] + public void Image_Always_ReturnsGenericInputOutputIcon() + { + // Call + Image image = info.Image; + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.NormsIcon, image); + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() + { + // Setup + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(null, mocks); + assessmentSection.Stub(section => section.Composition) + .Return(AssessmentSectionComposition.Dike); + + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + using (var view = new AssessmentSectionAssemblyCategoriesView(assessmentSection.FailureMechanismContribution)) + { + // Call + bool closeForData = info.CloseForData(view, assessmentSection); + + // Assert + Assert.IsTrue(closeForData); + } + + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() + { + // Setup + IAssessmentSection assessmentSection1 = AssessmentSectionHelper.CreateAssessmentSectionStub(null, mocks); + assessmentSection1.Stub(section => section.Composition) + .Return(AssessmentSectionComposition.DikeAndDune); + + IAssessmentSection assessmentSection2 = AssessmentSectionHelper.CreateAssessmentSectionStub(null, mocks); + assessmentSection2.Stub(section => section.Composition) + .Return(AssessmentSectionComposition.DikeAndDune); + mocks.ReplayAll(); + + using (new AssemblyToolCalculatorFactoryConfig()) + using (var view = new AssessmentSectionAssemblyCategoriesView(assessmentSection1.FailureMechanismContribution)) + { + // Call + bool closeForData = info.CloseForData(view, assessmentSection2); + + // Assert + Assert.IsFalse(closeForData); + } + + mocks.VerifyAll(); + } + } +} \ No newline at end of file