Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultCategoriesView.cs =================================================================== diff -u -re165cd0a0f0be54799bd4657d83d255acb10c962 -r4f29c5e0442b0ab7f72ec2d3fd40759d33c77aea --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultCategoriesView.cs (.../AssemblyResultCategoriesView.cs) (revision e165cd0a0f0be54799bd4657d83d255acb10c962) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultCategoriesView.cs (.../AssemblyResultCategoriesView.cs) (revision 4f29c5e0442b0ab7f72ec2d3fd40759d33c77aea) @@ -53,8 +53,12 @@ } InitializeComponent(); + + AssessmentSection = assessmentSection; } + public AssessmentSection AssessmentSection { get; } + public object Data { get; set; } } -} +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -r33205307965d58ef6ef2452c30465dd1712e707e -r4f29c5e0442b0ab7f72ec2d3fd40759d33c77aea --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 33205307965d58ef6ef2452c30465dd1712e707e) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 4f29c5e0442b0ab7f72ec2d3fd40759d33c77aea) @@ -641,6 +641,14 @@ context.AssessmentSection, context.GetFailureMechanismSectionAssemblyCategoriesFunc) }; + yield return new ViewInfo + { + GetViewName = (view, context) => RingtoetsCommonFormsResources.AssemblyCategories_DisplayName, + Image = RingtoetsCommonFormsResources.NormsIcon, + CloseForData = CloseAssemblyResultCategoriesViewForData, + CreateInstance = context => new AssemblyResultCategoriesView(context.WrappedData, + context.GetAssemblyCategoriesFunc) + }; } public override IEnumerable GetImportInfos() @@ -1411,8 +1419,18 @@ #endregion + #region AssemblyResultCategoriesContext ViewInfo + + private bool CloseAssemblyResultCategoriesViewForData(AssemblyResultCategoriesView view, object o) + { + var assessmentSection = o as AssessmentSection; + return assessmentSection != null && assessmentSection == view.AssessmentSection; + } + #endregion + #endregion + #region TreeNodeInfos #region FailureMechanismSectionsContext TreeNodeInfo Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssemblyResultCategoriesViewTest.cs =================================================================== diff -u -re165cd0a0f0be54799bd4657d83d255acb10c962 -r4f29c5e0442b0ab7f72ec2d3fd40759d33c77aea --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssemblyResultCategoriesViewTest.cs (.../AssemblyResultCategoriesViewTest.cs) (revision e165cd0a0f0be54799bd4657d83d255acb10c962) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssemblyResultCategoriesViewTest.cs (.../AssemblyResultCategoriesViewTest.cs) (revision 4f29c5e0442b0ab7f72ec2d3fd40759d33c77aea) @@ -57,14 +57,17 @@ [Test] public void Constructor_ExpectedValues() { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + // Call - using (var view = new AssemblyResultCategoriesView(new AssessmentSection(AssessmentSectionComposition.Dike), - () => null)) + using (var view = new AssemblyResultCategoriesView(assessmentSection, () => null)) { // Assert Assert.IsInstanceOf(view); Assert.IsInstanceOf(view); Assert.IsNull(view.Data); + Assert.AreSame(assessmentSection, view.AssessmentSection); } } } Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj =================================================================== diff -u -r0a4e2fb59de0845c3e978d997fda2fc9fa64cb51 -r4f29c5e0442b0ab7f72ec2d3fd40759d33c77aea --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 0a4e2fb59de0845c3e978d997fda2fc9fa64cb51) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 4f29c5e0442b0ab7f72ec2d3fd40759d33c77aea) @@ -145,6 +145,7 @@ + Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs =================================================================== diff -u -r0a4e2fb59de0845c3e978d997fda2fc9fa64cb51 -r4f29c5e0442b0ab7f72ec2d3fd40759d33c77aea --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 0a4e2fb59de0845c3e978d997fda2fc9fa64cb51) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 4f29c5e0442b0ab7f72ec2d3fd40759d33c77aea) @@ -394,7 +394,7 @@ ViewInfo[] viewInfos = plugin.GetViewInfos().ToArray(); // Assert - Assert.AreEqual(21, viewInfos.Length); + Assert.AreEqual(22, viewInfos.Length); PluginTestHelper.AssertViewInfoDefined( viewInfos, @@ -518,6 +518,12 @@ typeof(MacroStabilityOutwardsAssemblyCategoriesContext), typeof(MacroStabilityOutwardsFailureMechanism), typeof(MacroStabilityOutwardsAssemblyCategoriesView)); + + PluginTestHelper.AssertViewInfoDefined( + viewInfos, + typeof(AssemblyResultCategoriesContext), + typeof(AssessmentSection), + typeof(AssemblyResultCategoriesView)); } } Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/AssemblyResultCategoriesViewInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/AssemblyResultCategoriesViewInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/AssemblyResultCategoriesViewInfoTest.cs (revision 4f29c5e0442b0ab7f72ec2d3fd40759d33c77aea) @@ -0,0 +1,133 @@ +// 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 Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Integration.Data; +using Ringtoets.Integration.Forms.PresentationObjects; +using Ringtoets.Integration.Forms.Views; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Plugin.Test.ViewInfos +{ + [TestFixture] + public class AssemblyResultCategoriesViewInfoTest + { + private RingtoetsPlugin plugin; + private ViewInfo info; + + [SetUp] + public void SetUp() + { + plugin = new RingtoetsPlugin(); + info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(AssemblyResultCategoriesView)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(AssemblyResultCategoriesContext), info.DataType); + Assert.AreEqual(typeof(AssessmentSection), info.ViewDataType); + } + + [Test] + public void GetViewName_Always_ReturnsViewName() + { + // Call + string viewName = info.GetViewName(null, null); + + // Assert + Assert.AreEqual("Categoriegrenzen", viewName); + } + + [Test] + public void Image_Always_ReturnsGenericInputOutputIcon() + { + // Call + Image image = info.Image; + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.NormsIcon, image); + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() + { + // Setup + var random = new Random(21); + var assessmentSection = new AssessmentSection(random.NextEnumValue()); + + using (var view = new AssemblyResultCategoriesView(assessmentSection, () => null)) + { + // Call + bool closeForData = info.CloseForData(view, assessmentSection); + + // Assert + Assert.IsTrue(closeForData); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() + { + // Setup + var random = new Random(21); + var assessmentSection1 = new AssessmentSection(random.NextEnumValue()); + var assessmentSection2 = new AssessmentSection(random.NextEnumValue()); + + using (var view = new AssemblyResultCategoriesView(assessmentSection1, () => null)) + { + // Call + bool closeForData = info.CloseForData(view, assessmentSection2); + + // Assert + Assert.IsFalse(closeForData); + } + } + + [Test] + public void CreateInstance_WithContext_SetsExpectedViewProperties() + { + // Setup + var random = new Random(21); + var assessmentSection = new AssessmentSection(random.NextEnumValue()); + var context = new AssemblyResultCategoriesContext(assessmentSection); + + // Call + var view = (AssemblyResultCategoriesView) info.CreateInstance(context); + + // Assert + Assert.AreSame(assessmentSection, view.AssessmentSection); + } + } +} \ No newline at end of file