Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsOutputProperties.cs =================================================================== diff -u -rb2841ec8a6fc64308b1ede3988aeddc479a749a0 -r027027b23d66d1372718b775d7f2626cfd025910 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsOutputProperties.cs (.../GrassCoverErosionInwardsOutputProperties.cs) (revision b2841ec8a6fc64308b1ede3988aeddc479a749a0) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsOutputProperties.cs (.../GrassCoverErosionInwardsOutputProperties.cs) (revision 027027b23d66d1372718b775d7f2626cfd025910) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.ComponentModel; using Core.Common.Base.Data; using Core.Common.Gui.Attributes; @@ -39,6 +40,21 @@ /// public class GrassCoverErosionInwardsOutputProperties : ObjectProperties { + /// + /// Creates a new instance of . + /// + /// The data to show properties for. + /// Thrown when + /// is null. + public GrassCoverErosionInwardsOutputProperties(GrassCoverErosionInwardsOutput data) + { + if (data == null) + { + throw new ArgumentNullException(nameof(data)); + } + Data = data; + } + [DynamicVisibleValidationMethod] public bool DynamicVisibleValidationMethod(string propertyName) { Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs =================================================================== diff -u -rcf2b3bf77b9af7560f00a7ba96596bed349a5cf1 -r027027b23d66d1372718b775d7f2626cfd025910 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision cf2b3bf77b9af7560f00a7ba96596bed349a5cf1) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 027027b23d66d1372718b775d7f2626cfd025910) @@ -83,7 +83,10 @@ context, new ObservablePropertyChangeHandler(context.Calculation, context.WrappedData)) }; - yield return new PropertyInfo(); + yield return new PropertyInfo + { + CreateInstance = context => new GrassCoverErosionInwardsOutputProperties(context.WrappedData) + }; yield return new PropertyInfo { CreateInstance = context => new DikeProfileCollectionProperties(context.WrappedData) Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsOutputPropertiesTest.cs =================================================================== diff -u -r711f6909f672eff30cea67489cb7372f01e7aff9 -r027027b23d66d1372718b775d7f2626cfd025910 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsOutputPropertiesTest.cs (.../GrassCoverErosionInwardsOutputPropertiesTest.cs) (revision 711f6909f672eff30cea67489cb7372f01e7aff9) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsOutputPropertiesTest.cs (.../GrassCoverErosionInwardsOutputPropertiesTest.cs) (revision 027027b23d66d1372718b775d7f2626cfd025910) @@ -53,17 +53,31 @@ [Test] public void Constructor_ExpectedValues() { + // Setup + var data = new TestGrassCoverErosionInwardsOutput(); + // Call - var properties = new GrassCoverErosionInwardsOutputProperties(); + var properties = new GrassCoverErosionInwardsOutputProperties(data); // Assert Assert.IsInstanceOf>(properties); - Assert.IsNull(properties.Data); + Assert.AreSame(data, properties.Data); } [Test] - public void Data_SetNewInputContextInstance_ReturnCorrectPropertyValues() + public void Constructor_DataNull_ThrowsArgumentNullException() { + // Call + TestDelegate test = () => new GrassCoverErosionInwardsOutputProperties(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("data", exception.ParamName); + } + + [Test] + public void Constructor_WithDataSet_ReturnCorrectPropertyValues() + { // Setup var random = new Random(); double waveHeight = random.NextDouble(); @@ -108,10 +122,7 @@ var output = new GrassCoverErosionInwardsOutput(resultOutput, dikeHeightOutput, overtoppingRateOutput); // Call - var properties = new GrassCoverErosionInwardsOutputProperties - { - Data = output - }; + var properties = new GrassCoverErosionInwardsOutputProperties(output); // Assert Assert.AreEqual(2, properties.WaveHeight.NumberOfDecimalPlaces); @@ -179,10 +190,7 @@ overtoppingRateOutput); // Call - var properties = new GrassCoverErosionInwardsOutputProperties - { - Data = output - }; + var properties = new GrassCoverErosionInwardsOutputProperties(output); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); @@ -223,10 +231,7 @@ overtoppingRateOutput); // Call - var properties = new GrassCoverErosionInwardsOutputProperties - { - Data = output - }; + var properties = new GrassCoverErosionInwardsOutputProperties(output); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); @@ -259,10 +264,7 @@ var output = new GrassCoverErosionInwardsOutput(resultOutput, null, null); // Call - var properties = new GrassCoverErosionInwardsOutputProperties - { - Data = output - }; + var properties = new GrassCoverErosionInwardsOutputProperties(output); // Assert int propertiesCount = double.IsNaN(waveHeight) ? 6 : 7; Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/PropertyInfos/GrassCoverErosionInwardsOutputContextPropertyInfoTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/PropertyInfos/GrassCoverErosionInwardsOutputContextPropertyInfoTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/PropertyInfos/GrassCoverErosionInwardsOutputContextPropertyInfoTest.cs (revision 027027b23d66d1372718b775d7f2626cfd025910) @@ -0,0 +1,82 @@ +// 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.Linq; +using Core.Common.Gui.Plugin; +using Core.Common.Gui.PropertyBag; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.GrassCoverErosionInwards.Data; +using Ringtoets.GrassCoverErosionInwards.Data.TestUtil; +using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects; +using Ringtoets.GrassCoverErosionInwards.Forms.PropertyClasses; + +namespace Ringtoets.GrassCoverErosionInwards.Plugin.Test.PropertyInfos +{ + [TestFixture] + public class GrassCoverErosionInwardsOutputContextPropertyInfoTest + { + private GrassCoverErosionInwardsPlugin plugin; + private PropertyInfo info; + + [SetUp] + public void SetUp() + { + plugin = new GrassCoverErosionInwardsPlugin(); + info = plugin.GetPropertyInfos().First(tni => tni.PropertyObjectType == typeof(GrassCoverErosionInwardsOutputProperties)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(GrassCoverErosionInwardsOutputContext), info.DataType); + Assert.AreEqual(typeof(GrassCoverErosionInwardsOutputProperties), info.PropertyObjectType); + } + + [Test] + public void CreateInstance_Always_NewPropertiesWithDataFromContext() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var output = new TestGrassCoverErosionInwardsOutput(); + var context = new GrassCoverErosionInwardsOutputContext(output, new GrassCoverErosionInwardsFailureMechanism(), assessmentSection); + + // Call + IObjectProperties objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(output, objectProperties.Data); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj =================================================================== diff -u -rcf2b3bf77b9af7560f00a7ba96596bed349a5cf1 -r027027b23d66d1372718b775d7f2626cfd025910 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj) (revision cf2b3bf77b9af7560f00a7ba96596bed349a5cf1) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj) (revision 027027b23d66d1372718b775d7f2626cfd025910) @@ -71,6 +71,7 @@ +