Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelLocationContextPropertyInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelLocationContextPropertyInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelLocationContextPropertyInfoTest.cs (revision 070acdcdc07854f93138da547e97dd7754a5ffc7) @@ -0,0 +1,87 @@ +// 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.Linq; +using Core.Common.Base.Data; +using Core.Common.Gui.Plugin; +using Core.Common.Gui.PropertyBag; +using NUnit.Framework; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Integration.Forms.PresentationObjects; +using Ringtoets.Integration.Forms.PropertyClasses; + +namespace Ringtoets.Integration.Plugin.Test.PropertyInfos +{ + [TestFixture] + public class DesignWaterLevelLocationContextPropertyInfoTest + { + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new RingtoetsPlugin()) + { + // Call + PropertyInfo info = GetInfo(plugin); + + // Assert + Assert.AreEqual(typeof(DesignWaterLevelLocationContext), info.DataType); + Assert.AreEqual(typeof(DesignWaterLevelLocationProperties), info.PropertyObjectType); + } + } + + [Test] + public void CreateInstance_WithContext_SetsDataCorrectly() + { + // Setup + double designWaterLevel = new Random().NextDouble(); + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation + { + Output = new TestHydraulicBoundaryLocationOutput(designWaterLevel) + }; + + var context = new DesignWaterLevelLocationContext(hydraulicBoundaryLocation, + hydraulicBoundaryLocationCalculation); + + using (var plugin = new RingtoetsPlugin()) + { + PropertyInfo info = GetInfo(plugin); + + // Call + IObjectProperties objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(hydraulicBoundaryLocation, objectProperties.Data); + RoundedDouble actualDesignWaterLevel = ((DesignWaterLevelLocationProperties) objectProperties).DesignWaterLevel; + Assert.AreEqual(designWaterLevel, actualDesignWaterLevel, actualDesignWaterLevel.GetAccuracy()); + } + } + + private static PropertyInfo GetInfo(RingtoetsPlugin plugin) + { + return plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(DesignWaterLevelLocationContext)); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelLocationsContextPropertyInfoTest.cs =================================================================== diff -u -ra5bf4f56dbf07e5cf48d0b874f5d46d7d02f0dba -r070acdcdc07854f93138da547e97dd7754a5ffc7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelLocationsContextPropertyInfoTest.cs (.../DesignWaterLevelLocationsContextPropertyInfoTest.cs) (revision a5bf4f56dbf07e5cf48d0b874f5d46d7d02f0dba) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelLocationsContextPropertyInfoTest.cs (.../DesignWaterLevelLocationsContextPropertyInfoTest.cs) (revision 070acdcdc07854f93138da547e97dd7754a5ffc7) @@ -19,13 +19,17 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using System.Collections.Generic; using System.Linq; +using Core.Common.Base; using Core.Common.Gui.Plugin; using Core.Common.Gui.PropertyBag; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Forms.PropertyClasses; @@ -50,18 +54,38 @@ } [Test] - public void CreateInstance_WithContext_SetsHydraulicBoundaryLocationsAsData() + public void CreateInstance_WithContext_SetsDataCorrectly() { // Setup - var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); - var mockRepository = new MockRepository(); var assessmentSection = mockRepository.Stub(); mockRepository.ReplayAll(); - var context = new DesignWaterLevelLocationsContext(hydraulicBoundaryDatabase.Locations, + var random = new Random(); + var hydraulicBoundaryLocations = new ObservableList(); + var locationsLookup = new Dictionary + { + { + new TestHydraulicBoundaryLocation(), + new HydraulicBoundaryLocationCalculation + { + Output = new TestHydraulicBoundaryLocationOutput(random.NextDouble()) + } + }, + { + new TestHydraulicBoundaryLocation(), + new HydraulicBoundaryLocationCalculation + { + Output = new TestHydraulicBoundaryLocationOutput(random.NextDouble()) + } + } + }; + + hydraulicBoundaryLocations.AddRange(locationsLookup.Keys); + + var context = new DesignWaterLevelLocationsContext(hydraulicBoundaryLocations, assessmentSection, - hbl => new HydraulicBoundaryLocationCalculation(), + hbl => locationsLookup[hbl], "Category"); using (var plugin = new RingtoetsPlugin()) @@ -73,7 +97,10 @@ // Assert Assert.IsInstanceOf(objectProperties); - Assert.AreSame(hydraulicBoundaryDatabase.Locations, objectProperties.Data); + Assert.AreSame(hydraulicBoundaryLocations, objectProperties.Data); + DesignWaterLevelLocationProperties[] locationProperties = ((DesignWaterLevelLocationsProperties) objectProperties).Locations; + CollectionAssert.AreEqual(locationsLookup.Keys, locationProperties.Select(p => p.Data)); + CollectionAssert.AreEqual(locationsLookup.Values.Select(c => c.Output.Result), locationProperties.Select(p => p.DesignWaterLevel)); } mockRepository.VerifyAll(); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightLocationContextPropertyInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightLocationContextPropertyInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightLocationContextPropertyInfoTest.cs (revision 070acdcdc07854f93138da547e97dd7754a5ffc7) @@ -0,0 +1,87 @@ +// 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.Linq; +using Core.Common.Base.Data; +using Core.Common.Gui.Plugin; +using Core.Common.Gui.PropertyBag; +using NUnit.Framework; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Integration.Forms.PresentationObjects; +using Ringtoets.Integration.Forms.PropertyClasses; + +namespace Ringtoets.Integration.Plugin.Test.PropertyInfos +{ + [TestFixture] + public class WaveHeightLocationContextPropertyInfoTest + { + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new RingtoetsPlugin()) + { + // Call + PropertyInfo info = GetInfo(plugin); + + // Assert + Assert.AreEqual(typeof(WaveHeightLocationContext), info.DataType); + Assert.AreEqual(typeof(WaveHeightLocationProperties), info.PropertyObjectType); + } + } + + [Test] + public void CreateInstance_WithContext_SetsDataCorrectly() + { + // Setup + double waveHeight = new Random().NextDouble(); + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation + { + Output = new TestHydraulicBoundaryLocationOutput(waveHeight) + }; + + var context = new WaveHeightLocationContext(hydraulicBoundaryLocation, + hydraulicBoundaryLocationCalculation); + + using (var plugin = new RingtoetsPlugin()) + { + PropertyInfo info = GetInfo(plugin); + + // Call + IObjectProperties objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(hydraulicBoundaryLocation, objectProperties.Data); + RoundedDouble actualWaveHeight = ((WaveHeightLocationProperties) objectProperties).WaveHeight; + Assert.AreEqual(waveHeight, actualWaveHeight, actualWaveHeight.GetAccuracy()); + } + } + + private static PropertyInfo GetInfo(RingtoetsPlugin plugin) + { + return plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(WaveHeightLocationContext)); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightLocationsContextPropertyInfoTest.cs =================================================================== diff -u -ra5bf4f56dbf07e5cf48d0b874f5d46d7d02f0dba -r070acdcdc07854f93138da547e97dd7754a5ffc7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightLocationsContextPropertyInfoTest.cs (.../WaveHeightLocationsContextPropertyInfoTest.cs) (revision a5bf4f56dbf07e5cf48d0b874f5d46d7d02f0dba) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightLocationsContextPropertyInfoTest.cs (.../WaveHeightLocationsContextPropertyInfoTest.cs) (revision 070acdcdc07854f93138da547e97dd7754a5ffc7) @@ -19,13 +19,17 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using System.Collections.Generic; using System.Linq; +using Core.Common.Base; using Core.Common.Gui.Plugin; using Core.Common.Gui.PropertyBag; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Forms.PropertyClasses; @@ -50,18 +54,38 @@ } [Test] - public void CreateInstance_WithContext_SetsHydraulicBoundaryLocationsAsData() + public void CreateInstance_WithContext_SetsDataCorrectly() { // Setup - var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); - var mockRepository = new MockRepository(); var assessmentSection = mockRepository.Stub(); mockRepository.ReplayAll(); - var context = new WaveHeightLocationsContext(hydraulicBoundaryDatabase.Locations, + var random = new Random(); + var hydraulicBoundaryLocations = new ObservableList(); + var locationsLookup = new Dictionary + { + { + new TestHydraulicBoundaryLocation(), + new HydraulicBoundaryLocationCalculation + { + Output = new TestHydraulicBoundaryLocationOutput(random.NextDouble()) + } + }, + { + new TestHydraulicBoundaryLocation(), + new HydraulicBoundaryLocationCalculation + { + Output = new TestHydraulicBoundaryLocationOutput(random.NextDouble()) + } + } + }; + + hydraulicBoundaryLocations.AddRange(locationsLookup.Keys); + + var context = new WaveHeightLocationsContext(hydraulicBoundaryLocations, assessmentSection, - hbl => new HydraulicBoundaryLocationCalculation(), + hbl => locationsLookup[hbl], "Category"); using (var plugin = new RingtoetsPlugin()) @@ -73,7 +97,10 @@ // Assert Assert.IsInstanceOf(objectProperties); - Assert.AreSame(hydraulicBoundaryDatabase.Locations, objectProperties.Data); + Assert.AreSame(hydraulicBoundaryLocations, objectProperties.Data); + WaveHeightLocationProperties[] locationProperties = ((WaveHeightLocationsProperties) objectProperties).Locations; + CollectionAssert.AreEqual(locationsLookup.Keys, locationProperties.Select(p => p.Data)); + CollectionAssert.AreEqual(locationsLookup.Values.Select(c => c.Output.Result), locationProperties.Select(p => p.WaveHeight)); } mockRepository.VerifyAll(); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj =================================================================== diff -u -r80cc77ed4382e822d305dbef5b8ac604d61ea02a -r070acdcdc07854f93138da547e97dd7754a5ffc7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 80cc77ed4382e822d305dbef5b8ac604d61ea02a) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 070acdcdc07854f93138da547e97dd7754a5ffc7) @@ -49,6 +49,8 @@ + +