Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsScenariosContext.cs =================================================================== diff -u -r8d33f259735b765767405b7691924bc8c0182d72 -r9bd00cf5c538409ebb1c1c68f90ca0146e93d155 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsScenariosContext.cs (.../GrassCoverErosionInwardsScenariosContext.cs) (revision 8d33f259735b765767405b7691924bc8c0182d72) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsScenariosContext.cs (.../GrassCoverErosionInwardsScenariosContext.cs) (revision 9bd00cf5c538409ebb1c1c68f90ca0146e93d155) @@ -19,14 +19,24 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using Core.Common.Controls.PresentationObjects; + +using Ringtoets.Common.Data.Calculation; +using Ringtoets.GrassCoverErosionInwards.Data; + namespace Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects { /// /// Presentation object for configuration of scenarios for the Grass Cover Erosion Inwards /// failure mechanism. /// - public class GrassCoverErosionInwardsScenariosContext + public class GrassCoverErosionInwardsScenariosContext : WrappedObjectContextBase { - + public GrassCoverErosionInwardsScenariosContext(CalculationGroup wrappedData, GrassCoverErosionInwardsFailureMechanism failureMechanism) : base(wrappedData) + { + ParentFailureMechanism = failureMechanism; + } + + public GrassCoverErosionInwardsFailureMechanism ParentFailureMechanism { get; private set; } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj =================================================================== diff -u -r3a736a0978850c0b268fb9948ea7ff37a577745e -r9bd00cf5c538409ebb1c1c68f90ca0146e93d155 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.csproj) (revision 3a736a0978850c0b268fb9948ea7ff37a577745e) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.csproj) (revision 9bd00cf5c538409ebb1c1c68f90ca0146e93d155) @@ -34,8 +34,10 @@ + + @@ -89,6 +91,12 @@ GrassCoverErosionInwardsInputView.cs + + UserControl + + + GrassCoverErosionInwardsScenariosView.cs + @@ -167,6 +175,9 @@ GrassCoverErosionInwardsInputView.cs + + GrassCoverErosionInwardsScenariosView.cs + Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsScenariosView.Designer.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsScenariosView.Designer.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsScenariosView.Designer.cs (revision 9bd00cf5c538409ebb1c1c68f90ca0146e93d155) @@ -0,0 +1,57 @@ +namespace Ringtoets.GrassCoverErosionInwards.Forms.Views +{ + partial class GrassCoverErosionInwardsScenariosView + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.dataGridViewControl1 = new Core.Common.Controls.DataGrid.DataGridViewControl(); + this.SuspendLayout(); + // + // dataGridViewControl1 + // + this.dataGridViewControl1.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridViewControl1.Location = new System.Drawing.Point(0, 0); + this.dataGridViewControl1.Name = "dataGridViewControl1"; + this.dataGridViewControl1.Size = new System.Drawing.Size(498, 451); + this.dataGridViewControl1.TabIndex = 0; + // + // GrassCoverErosionInwardsScenariosView + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.dataGridViewControl1); + this.Name = "GrassCoverErosionInwardsScenariosView"; + this.Size = new System.Drawing.Size(498, 451); + this.ResumeLayout(false); + + } + + #endregion + + private Core.Common.Controls.DataGrid.DataGridViewControl dataGridViewControl1; + } +} Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsScenariosView.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsScenariosView.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsScenariosView.cs (revision 9bd00cf5c538409ebb1c1c68f90ca0146e93d155) @@ -0,0 +1,47 @@ +// Copyright (C) Stichting Deltares 2016. 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 System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +using Core.Common.Controls.Views; + +using Ringtoets.GrassCoverErosionInwards.Data; + +namespace Ringtoets.GrassCoverErosionInwards.Forms.Views +{ + public partial class GrassCoverErosionInwardsScenariosView : UserControl, IView + { + public GrassCoverErosionInwardsScenariosView() + { + InitializeComponent(); + } + + public object Data { get; set; } + public IEnumerable SectionResults { get; set; } + } +} Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsScenariosView.resx =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsScenariosView.resx (revision 0) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsScenariosView.resx (revision 9bd00cf5c538409ebb1c1c68f90ca0146e93d155) @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsGuiPlugin.cs =================================================================== diff -u -r18a53a9b2a6c09a3af46cb9c023de3f323639f30 -r9bd00cf5c538409ebb1c1c68f90ca0146e93d155 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsGuiPlugin.cs (.../GrassCoverErosionInwardsGuiPlugin.cs) (revision 18a53a9b2a6c09a3af46cb9c023de3f323639f30) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsGuiPlugin.cs (.../GrassCoverErosionInwardsGuiPlugin.cs) (revision 9bd00cf5c538409ebb1c1c68f90ca0146e93d155) @@ -69,6 +69,36 @@ public override IEnumerable GetViewInfos() { + yield return new ViewInfo + { + GetViewData = context => context.WrappedData, + GetViewName = (view, calculationGroup) => GrassCoverErosionInwardsPluginResources.GrassCoverErosionInwardsGuiPlugin_Scenarios_DisplayName, + AfterCreate = (view, context) => + { + view.SectionResults = context.ParentFailureMechanism.SectionResults; + }, + CloseForData = (view, removedData) => + { + var assessmentSection = removedData as IAssessmentSection; + if (assessmentSection != null) + { + return assessmentSection.GetFailureMechanisms() + .OfType() + .Any(fm => ReferenceEquals(view.Data, fm.CalculationsGroup)); + } + + var grassCoverErosionInwardsFailureMechanism = removedData as GrassCoverErosionInwardsFailureMechanism; + if (grassCoverErosionInwardsFailureMechanism != null) + { + return ReferenceEquals(view.Data, grassCoverErosionInwardsFailureMechanism.CalculationsGroup); + } + return false; + }, + Image = GrassCoverErosionInwardsPluginResources.ScenariosIcon + }; + yield return new ViewInfo< FailureMechanismSectionResultContext, IEnumerable, @@ -332,7 +362,7 @@ { return new ArrayList { - new GrassCoverErosionInwardsScenariosContext(), + new GrassCoverErosionInwardsScenariosContext(failureMechanism.CalculationsGroup, failureMechanism), new FailureMechanismSectionResultContext(failureMechanism.SectionResults, failureMechanism) }; } Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Properties/Resources.Designer.cs =================================================================== diff -u -rc9396d0af18873fda14c7e486decbfca7d4e8b21 -r9bd00cf5c538409ebb1c1c68f90ca0146e93d155 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision c9396d0af18873fda14c7e486decbfca7d4e8b21) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 9bd00cf5c538409ebb1c1c68f90ca0146e93d155) @@ -22,7 +22,7 @@ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { + public class Resources { private static global::System.Resources.ResourceManager resourceMan; @@ -36,7 +36,7 @@ /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Ringtoets.GrassCoverErosionInwards.Plugin.Properties.Resources", typeof(Resources).Assembly); @@ -51,7 +51,7 @@ /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + public static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -63,7 +63,7 @@ /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap DikeProfile { + public static System.Drawing.Bitmap DikeProfile { get { object obj = ResourceManager.GetObject("DikeProfile", resourceCulture); return ((System.Drawing.Bitmap)(obj)); @@ -73,7 +73,7 @@ /// /// Looks up a localized string similar to Er zijn geen dijkprofielen beschikbaar om berekeningen voor te genereren.. /// - internal static string GrassCoverErosionInwardsGuiPlugin_CreateGenerateCalculationsItem_NoDikeLocations_ToolTip { + public static string GrassCoverErosionInwardsGuiPlugin_CreateGenerateCalculationsItem_NoDikeLocations_ToolTip { get { return ResourceManager.GetString("GrassCoverErosionInwardsGuiPlugin_CreateGenerateCalculationsItem_NoDikeLocations_" + "ToolTip", resourceCulture); @@ -83,7 +83,7 @@ /// /// Looks up a localized string similar to Genereer scenario's op basis van geselecteerde dijkprofielen.. /// - internal static string GrassCoverErosionInwardsGuiPlugin_CreateGenerateCalculationsItem_ToolTip { + public static string GrassCoverErosionInwardsGuiPlugin_CreateGenerateCalculationsItem_ToolTip { get { return ResourceManager.GetString("GrassCoverErosionInwardsGuiPlugin_CreateGenerateCalculationsItem_ToolTip", resourceCulture); } @@ -92,7 +92,7 @@ /// /// Looks up a localized string similar to Dijkprofielen. /// - internal static string GrassCoverErosionInwardsGuiPlugin_DikeProfilesContext_DisplayName { + public static string GrassCoverErosionInwardsGuiPlugin_DikeProfilesContext_DisplayName { get { return ResourceManager.GetString("GrassCoverErosionInwardsGuiPlugin_DikeProfilesContext_DisplayName", resourceCulture); } @@ -101,7 +101,7 @@ /// /// Looks up a localized string similar to Er is een fout opgetreden tijdens de berekening.. /// - internal static string GrassCoverErosionInwardsGuiPlugin_Error_during_overtopping_calculation { + public static string GrassCoverErosionInwardsGuiPlugin_Error_during_overtopping_calculation { get { return ResourceManager.GetString("GrassCoverErosionInwardsGuiPlugin_Error_during_overtopping_calculation", resourceCulture); } @@ -110,7 +110,7 @@ /// /// Looks up a localized string similar to Scenarios. /// - internal static string GrassCoverErosionInwardsGuiPlugin_Scenarios_DisplayName { + public static string GrassCoverErosionInwardsGuiPlugin_Scenarios_DisplayName { get { return ResourceManager.GetString("GrassCoverErosionInwardsGuiPlugin_Scenarios_DisplayName", resourceCulture); } @@ -119,7 +119,7 @@ /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// - internal static System.Drawing.Bitmap ScenariosIcon { + public static System.Drawing.Bitmap ScenariosIcon { get { object obj = ResourceManager.GetObject("ScenariosIcon", resourceCulture); return ((System.Drawing.Bitmap)(obj)); Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Ringtoets.GrassCoverErosionInwards.Plugin.csproj =================================================================== diff -u -r8b9903ce9a5e5b860ee8ba6719737783be7a8cab -r9bd00cf5c538409ebb1c1c68f90ca0146e93d155 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Ringtoets.GrassCoverErosionInwards.Plugin.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.csproj) (revision 8b9903ce9a5e5b860ee8ba6719737783be7a8cab) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Ringtoets.GrassCoverErosionInwards.Plugin.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.csproj) (revision 9bd00cf5c538409ebb1c1c68f90ca0146e93d155) @@ -151,7 +151,7 @@ - ResXFileCodeGenerator + PublicResXFileCodeGenerator Resources.Designer.cs Designer Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsScenariosContextTest.cs =================================================================== diff -u -r8d33f259735b765767405b7691924bc8c0182d72 -r9bd00cf5c538409ebb1c1c68f90ca0146e93d155 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsScenariosContextTest.cs (.../GrassCoverErosionInwardsScenariosContextTest.cs) (revision 8d33f259735b765767405b7691924bc8c0182d72) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsScenariosContextTest.cs (.../GrassCoverErosionInwardsScenariosContextTest.cs) (revision 9bd00cf5c538409ebb1c1c68f90ca0146e93d155) @@ -19,8 +19,12 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using Core.Common.Controls.PresentationObjects; + using NUnit.Framework; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects; namespace Ringtoets.GrassCoverErosionInwards.Forms.Test.PresentationObjects @@ -31,11 +35,17 @@ [Test] public void Constructor_ExpectedValues() { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var calculationGroup = new CalculationGroup(); + // Call - var context = new GrassCoverErosionInwardsScenariosContext(); + var context = new GrassCoverErosionInwardsScenariosContext(calculationGroup, failureMechanism); // Assert - // TODO: Only need state as part of WTI-638 + Assert.IsInstanceOf>(context); + Assert.AreSame(calculationGroup, context.WrappedData); + Assert.AreSame(failureMechanism, context.ParentFailureMechanism); } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj =================================================================== diff -u -rc9396d0af18873fda14c7e486decbfca7d4e8b21 -r9bd00cf5c538409ebb1c1c68f90ca0146e93d155 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj) (revision c9396d0af18873fda14c7e486decbfca7d4e8b21) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj) (revision 9bd00cf5c538409ebb1c1c68f90ca0146e93d155) @@ -99,6 +99,7 @@ + Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r20415b2886919a103cb4677f56a8f61abbb7aa8a -r9bd00cf5c538409ebb1c1c68f90ca0146e93d155 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision 20415b2886919a103cb4677f56a8f61abbb7aa8a) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision 9bd00cf5c538409ebb1c1c68f90ca0146e93d155) @@ -141,7 +141,10 @@ Assert.AreEqual("Oordeel", outputsFolder.Name); Assert.AreEqual(TreeFolderCategory.Output, outputsFolder.Category); Assert.AreEqual(2, outputsFolder.Contents.Count); - Assert.IsInstanceOf(outputsFolder.Contents[0]); + var scenariosContext = (GrassCoverErosionInwardsScenariosContext)outputsFolder.Contents[0]; + Assert.AreSame(failureMechanism.CalculationsGroup, scenariosContext.WrappedData); + Assert.AreSame(failureMechanism, scenariosContext.ParentFailureMechanism); + var failureMechanismResultsContext = (FailureMechanismSectionResultContext) outputsFolder.Contents[1]; Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism); Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.WrappedData); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsScenariosContextTreeNodeInfoTest.cs =================================================================== diff -u -rc9396d0af18873fda14c7e486decbfca7d4e8b21 -r9bd00cf5c538409ebb1c1c68f90ca0146e93d155 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsScenariosContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsScenariosContextTreeNodeInfoTest.cs) (revision c9396d0af18873fda14c7e486decbfca7d4e8b21) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsScenariosContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsScenariosContextTreeNodeInfoTest.cs) (revision 9bd00cf5c538409ebb1c1c68f90ca0146e93d155) @@ -31,6 +31,8 @@ using Rhino.Mocks; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects; using Ringtoets.GrassCoverErosionInwards.Plugin; using Ringtoets.GrassCoverErosionInwards.Plugin.Properties; @@ -84,7 +86,9 @@ public void Text_Always_ReturnScenarios() { // Setup - var context = new GrassCoverErosionInwardsScenariosContext(); + var group = new CalculationGroup(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var context = new GrassCoverErosionInwardsScenariosContext(group, failureMechanism); // Call string text = info.Text(context); @@ -97,7 +101,9 @@ public void Image_Always_ReturnExpectedImage() { // Setup - var context = new GrassCoverErosionInwardsScenariosContext(); + var group = new CalculationGroup(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var context = new GrassCoverErosionInwardsScenariosContext(group, failureMechanism); // Call Image image = info.Image(context); @@ -112,7 +118,9 @@ // Setup using (var treeViewControl = new TreeViewControl()) { - var context = new GrassCoverErosionInwardsScenariosContext(); + var group = new CalculationGroup(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var context = new GrassCoverErosionInwardsScenariosContext(group, failureMechanism); var mocks = new MockRepository(); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsScenariosViewTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsScenariosViewTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsScenariosViewTest.cs (revision 9bd00cf5c538409ebb1c1c68f90ca0146e93d155) @@ -0,0 +1,46 @@ +// Copyright (C) Stichting Deltares 2016. 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 Core.Common.Controls.Views; + +using NUnit.Framework; + +using Ringtoets.GrassCoverErosionInwards.Forms.Views; + +namespace Ringtoets.GrassCoverErosionInwards.Forms.Test.Views +{ + [TestFixture] + public class GrassCoverErosionInwardsScenariosViewTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + using(var view = new GrassCoverErosionInwardsScenariosView()) + { + // Assert + Assert.IsInstanceOf(view); + Assert.IsNull(view.Data); + Assert.IsNull(view.SectionResults); + } + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/GrassCoverErosionInwardsGuiPluginTest.cs =================================================================== diff -u -r87fcb2097e3a58e611c0de6913cb48851006f7af -r9bd00cf5c538409ebb1c1c68f90ca0146e93d155 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/GrassCoverErosionInwardsGuiPluginTest.cs (.../GrassCoverErosionInwardsGuiPluginTest.cs) (revision 87fcb2097e3a58e611c0de6913cb48851006f7af) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/GrassCoverErosionInwardsGuiPluginTest.cs (.../GrassCoverErosionInwardsGuiPluginTest.cs) (revision 9bd00cf5c538409ebb1c1c68f90ca0146e93d155) @@ -146,10 +146,11 @@ ViewInfo[] viewInfos = guiPlugin.GetViewInfos().ToArray(); // Assert - Assert.AreEqual(2, viewInfos.Length); + Assert.AreEqual(3, viewInfos.Length); Assert.IsTrue(viewInfos.Any(vi => vi.ViewType == typeof(GrassCoverErosionInwardsFailureMechanismResultView))); Assert.IsTrue(viewInfos.Any(vi => vi.ViewType == typeof(GrassCoverErosionInwardsInputView))); + Assert.IsTrue(viewInfos.Any(vi => vi.ViewType == typeof(GrassCoverErosionInwardsScenariosView))); } } } Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj =================================================================== diff -u -r87fcb2097e3a58e611c0de6913cb48851006f7af -r9bd00cf5c538409ebb1c1c68f90ca0146e93d155 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj) (revision 87fcb2097e3a58e611c0de6913cb48851006f7af) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj) (revision 9bd00cf5c538409ebb1c1c68f90ca0146e93d155) @@ -56,6 +56,7 @@ + Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsScenariosViewInfoTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsScenariosViewInfoTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsScenariosViewInfoTest.cs (revision 9bd00cf5c538409ebb1c1c68f90ca0146e93d155) @@ -0,0 +1,249 @@ +// Copyright (C) Stichting Deltares 2016. 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.Gui.Plugin; +using Core.Common.TestUtil; + +using NUnit.Framework; + +using Rhino.Mocks; + +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.GrassCoverErosionInwards.Data; +using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects; +using Ringtoets.GrassCoverErosionInwards.Forms.Views; + +using Resources = Ringtoets.GrassCoverErosionInwards.Plugin.Properties.Resources; + +namespace Ringtoets.GrassCoverErosionInwards.Plugin.Test.ViewInfos +{ + [TestFixture] + public class GrassCoverErosionInwardsScenariosViewInfoTest + { + private GrassCoverErosionInwardsGuiPlugin plugin; + private ViewInfo info; + + [SetUp] + public void SetUp() + { + plugin = new GrassCoverErosionInwardsGuiPlugin(); + info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(GrassCoverErosionInwardsScenariosView)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(GrassCoverErosionInwardsScenariosContext), info.DataType); + Assert.AreEqual(typeof(CalculationGroup), info.ViewDataType); + } + + [Test] + public void GetViewName_Always_ReturnViewName() + { + // Setup + using (var view = new GrassCoverErosionInwardsScenariosView()) + { + var viewData = new CalculationGroup(); + + // Call + string viewName = info.GetViewName(view, viewData); + + // Assert + Assert.AreEqual("Scenarios", viewName); + } + } + + [Test] + public void GetViewData_Always_ReturnWrappedData() + { + // Setup + var calculationGroup = new CalculationGroup(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var context = new GrassCoverErosionInwardsScenariosContext(calculationGroup, failureMechanism); + + // Call + object viewData = info.GetViewData(context); + + // Assert + Assert.AreSame(calculationGroup, viewData); + } + + [Test] + public void Image_Always_ReturnScenariosIcon() + { + // Call + Image image = info.Image; + + // Assert + TestHelper.AssertImagesAreEqual(Resources.ScenariosIcon, image); + } + + [Test] + public void CloseForData_AssessmentSectionRemovedWithoutFailureMechanism_ReturnFalse() + { + // Setup + using (var view = new GrassCoverErosionInwardsScenariosView + { + Data = new CalculationGroup() + }) + { + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + assessmentSection.Stub(section => section.GetFailureMechanisms()).Return(new IFailureMechanism[0]); + mocks.ReplayAll(); + + // Call + bool closeForData = info.CloseForData(view, assessmentSection); + + // Assert + Assert.IsFalse(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnFalse() + { + // Setup + using (var view = new GrassCoverErosionInwardsScenariosView + { + Data = new CalculationGroup() + }) + { + var unrelatedFailureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + assessmentSection.Expect(asm => asm.GetFailureMechanisms()).Return(new[] + { + unrelatedFailureMechanism + }); + mocks.ReplayAll(); + + // Precondition + Assert.AreNotSame(view.Data, unrelatedFailureMechanism.CalculationsGroup); + + // Call + bool closeForData = info.CloseForData(view, assessmentSection); + + // Assert + Assert.IsFalse(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnTrue() + { + // Setup + var relatedFailureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + using (var view = new GrassCoverErosionInwardsScenariosView + { + Data = relatedFailureMechanism.CalculationsGroup + }) + { + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + assessmentSection.Expect(asm => asm.GetFailureMechanisms()).Return(new[] + { + relatedFailureMechanism + }); + mocks.ReplayAll(); + + // Precondition + Assert.AreSame(view.Data, relatedFailureMechanism.CalculationsGroup); + + // Call + bool closeForData = info.CloseForData(view, assessmentSection); + + // Assert + Assert.IsTrue(closeForData); + mocks.VerifyAll(); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnFalse() + { + // Setup + using (var view = new GrassCoverErosionInwardsScenariosView + { + Data = new CalculationGroup() + }) + { + // Call + bool closeForData = info.CloseForData(view, new GrassCoverErosionInwardsFailureMechanism()); + + // Assert + Assert.IsFalse(closeForData); + } + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnTrue() + { + // Setup + var correspondingFailureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + using (var view = new GrassCoverErosionInwardsScenariosView + { + Data = correspondingFailureMechanism.CalculationsGroup + }) + { + // Call + bool closeForData = info.CloseForData(view, correspondingFailureMechanism); + + // Assert + Assert.IsTrue(closeForData); + } + } + + [Test] + public void AfterCreate_Always_SetsSpecificPropertiesToView() + { + // Setup + using (var view = new GrassCoverErosionInwardsScenariosView()) + { + var group = new CalculationGroup(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var context = new GrassCoverErosionInwardsScenariosContext(group, failureMechanism); + + // Call + info.AfterCreate(view, context); + + // Assert + Assert.AreSame(failureMechanism.SectionResults, view.SectionResults); + } + } + } +} \ No newline at end of file