Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -rc1dacdcb866d2c12cacd5a9f7be63c2c344382b0 -r0c4b61d828b7118cd511f996cab4b7e13bd5bdbc --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision c1dacdcb866d2c12cacd5a9f7be63c2c344382b0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 0c4b61d828b7118cd511f996cab4b7e13bd5bdbc) @@ -572,6 +572,14 @@ CloseForData = CloseAssemblyResultTotalViewForData, CreateInstance = context => new AssemblyResultTotalView(context.WrappedData) }; + + yield return new ViewInfo + { + GetViewName = (view, context) => Resources.AssemblyResultPerSection_DisplayName, + Image = Resources.AssemblyResultPerSection, + CloseForData = CloseAssemblyResultPerSectionViewForData, + CreateInstance = context => new AssemblyResultPerSectionView(context.WrappedData) + }; } public override IEnumerable GetImportInfos() @@ -1245,7 +1253,7 @@ #endregion - #region AssemblyTotalResultContext ViewInfo + #region AssemblyResultTotalContext ViewInfo private static bool CloseAssemblyResultTotalViewForData(AssemblyResultTotalView view, object o) { @@ -1255,8 +1263,18 @@ #endregion + #region AssemblyResultPerSectionContext ViewInfo + + private static bool CloseAssemblyResultPerSectionViewForData(AssemblyResultPerSectionView 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.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj =================================================================== diff -u -r5973ea19f0223d8e4331d1646e505032a569f0b4 -r0c4b61d828b7118cd511f996cab4b7e13bd5bdbc --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 5973ea19f0223d8e4331d1646e505032a569f0b4) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 0c4b61d828b7118cd511f996cab4b7e13bd5bdbc) @@ -99,6 +99,7 @@ + Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs =================================================================== diff -u -r5973ea19f0223d8e4331d1646e505032a569f0b4 -r0c4b61d828b7118cd511f996cab4b7e13bd5bdbc --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 5973ea19f0223d8e4331d1646e505032a569f0b4) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 0c4b61d828b7118cd511f996cab4b7e13bd5bdbc) @@ -369,7 +369,7 @@ ViewInfo[] viewInfos = plugin.GetViewInfos().ToArray(); // Assert - Assert.AreEqual(19, viewInfos.Length); + Assert.AreEqual(20, viewInfos.Length); PluginTestHelper.AssertViewInfoDefined( viewInfos, @@ -481,6 +481,12 @@ typeof(AssemblyResultTotalContext), typeof(AssessmentSection), typeof(AssemblyResultTotalView)); + + PluginTestHelper.AssertViewInfoDefined( + viewInfos, + typeof(AssemblyResultPerSectionContext), + typeof(AssessmentSection), + typeof(AssemblyResultPerSectionView)); } } Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/AssemblyResultPerSectionViewInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/AssemblyResultPerSectionViewInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/AssemblyResultPerSectionViewInfoTest.cs (revision 0c4b61d828b7118cd511f996cab4b7e13bd5bdbc) @@ -0,0 +1,143 @@ +// 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 Ringtoets.Integration.Plugin.Properties; + +namespace Ringtoets.Integration.Plugin.Test.ViewInfos +{ + [TestFixture] + public class AssemblyResultPerSectionViewInfoTest + { + private RingtoetsPlugin plugin; + private ViewInfo info; + + [SetUp] + public void SetUp() + { + plugin = new RingtoetsPlugin(); + info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(AssemblyResultPerSectionView)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(AssemblyResultPerSectionContext), info.DataType); + Assert.AreEqual(typeof(AssessmentSection), info.ViewDataType); + } + + [Test] + public void GetViewName_Always_ReturnsViewName() + { + // Call + string viewName = info.GetViewName(null, null); + + // Assert + Assert.AreEqual("Gecombineerd vakoordeel", viewName); + } + + [Test] + public void ViewType_Always_ReturnsViewType() + { + // Call + Type viewType = info.ViewType; + + // Assert + Assert.AreEqual(typeof(AssemblyResultPerSectionView), viewType); + } + + [Test] + public void Image_Always_ReturnsGenericInputOutputIcon() + { + // Call + Image image = info.Image; + + // Assert + TestHelper.AssertImagesAreEqual(Resources.AssemblyResultPerSection, image); + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() + { + // Setup + var random = new Random(21); + var assessmentSection = new AssessmentSection(random.NextEnumValue()); + + using (var view = new AssemblyResultPerSectionView(assessmentSection)) + { + // 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 AssemblyResultPerSectionView(assessmentSection1)) + { + // 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 AssemblyResultPerSectionContext(assessmentSection); + + // Call + var view = (AssemblyResultPerSectionView) info.CreateInstance(context); + + // Assert + Assert.AreSame(assessmentSection, view.AssessmentSection); + } + } +} \ No newline at end of file