Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/PropertyClasses/DuneLocationsContextPropertiesTest.cs =================================================================== diff -u -r3d1365e8ec250bc6e93c923736635a049a7facec -r1930dd0513dd2e649905034334d8896d36640c7b --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/PropertyClasses/DuneLocationsContextPropertiesTest.cs (.../DuneLocationsContextPropertiesTest.cs) (revision 3d1365e8ec250bc6e93c923736635a049a7facec) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/PropertyClasses/DuneLocationsContextPropertiesTest.cs (.../DuneLocationsContextPropertiesTest.cs) (revision 1930dd0513dd2e649905034334d8896d36640c7b) @@ -2,7 +2,7 @@ using System.Linq; using Core.Common.Base; using Core.Common.Gui.Converters; -using Core.Common.Gui.PropertyBag; +using Core.Common.TestUtil; using Core.Common.Utils; using Core.Common.Utils.Reflection; using NUnit.Framework; @@ -28,7 +28,7 @@ var mockRepository = new MockRepository(); var assessmentSection = mockRepository.Stub(); mockRepository.ReplayAll(); - + var location = new TestDuneLocation(); var items = new ObservableList { @@ -50,7 +50,7 @@ Assert.IsTrue(TypeUtils.HasTypeConverter(p => p.Locations)); - DuneLocationProperties duneLocationProperties= properties.Locations.First(); + DuneLocationProperties duneLocationProperties = properties.Locations.First(); Assert.AreEqual(location.Id, duneLocationProperties.Id); Assert.AreEqual(location.Name, duneLocationProperties.Name); Assert.AreEqual(location.CoastalAreaId, duneLocationProperties.CoastalAreaId); @@ -63,7 +63,6 @@ Assert.IsNaN(duneLocationProperties.TargetProbability); Assert.IsNaN(duneLocationProperties.TargetReliability); - Assert.IsNaN(duneLocationProperties.CalculatedProbability); Assert.IsNaN(duneLocationProperties.CalculatedReliability); @@ -80,13 +79,10 @@ var mockRepository = new MockRepository(); var assessmentSection = mockRepository.Stub(); mockRepository.ReplayAll(); - - var items = new ObservableList - { - new TestDuneLocation() - }; + var failureMechanism = new DuneErosionFailureMechanism(); - var context = new DuneLocationsContext(items, failureMechanism, assessmentSection); + failureMechanism.DuneLocations.Add(new TestDuneLocation()); + var context = new DuneLocationsContext(failureMechanism.DuneLocations, failureMechanism, assessmentSection); // Call var properties = new DuneLocationsContextProperties @@ -95,23 +91,19 @@ }; // Assert - var dynamicPropertyBag = new DynamicPropertyBag(properties); - const string expectedLocationsDisplayName = "Locaties"; - const string expectedLocationsDescription = "Locaties uit de hydraulische randvoorwaardendatabase."; - const string expectedLocationsCategory = "Algemeen"; - TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); Assert.IsInstanceOf(classTypeConverter); - PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(); + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(1, dynamicProperties.Count); + PropertyDescriptor locationsProperty = dynamicProperties[requiredLocationsPropertyIndex]; - Assert.IsNotNull(locationsProperty); Assert.IsInstanceOf(locationsProperty.Converter); - Assert.IsTrue(locationsProperty.IsReadOnly); - Assert.IsTrue(locationsProperty.IsBrowsable); - Assert.AreEqual(expectedLocationsDisplayName, locationsProperty.DisplayName); - Assert.AreEqual(expectedLocationsDescription, locationsProperty.Description); - Assert.AreEqual(expectedLocationsCategory, locationsProperty.Category); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(locationsProperty, + "Algemeen", + "Locaties", + "Locaties uit de hydraulische randvoorwaardendatabase.", + true); } } -} +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/DesignWaterLevelLocationsContextPropertiesTest.cs =================================================================== diff -u -r545b105a213ed85564861b4bcf6d2d6425dbde50 -r1930dd0513dd2e649905034334d8896d36640c7b --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/DesignWaterLevelLocationsContextPropertiesTest.cs (.../DesignWaterLevelLocationsContextPropertiesTest.cs) (revision 545b105a213ed85564861b4bcf6d2d6425dbde50) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/DesignWaterLevelLocationsContextPropertiesTest.cs (.../DesignWaterLevelLocationsContextPropertiesTest.cs) (revision 1930dd0513dd2e649905034334d8896d36640c7b) @@ -24,6 +24,7 @@ using System.Linq; using Core.Common.Gui.Converters; using Core.Common.Gui.PropertyBag; +using Core.Common.TestUtil; using Core.Common.Utils.Reflection; using NUnit.Framework; using Ringtoets.Common.Data.Hydraulics; @@ -35,6 +36,8 @@ [TestFixture] public class DesignWaterLevelLocationsContextPropertiesTest { + private const int requiredLocationsPropertyIndex = 0; + [Test] public void Constructor_WithoutDatabase_ExpectedValues() { @@ -45,6 +48,7 @@ string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("database", paramName); } + [Test] public void Constructor_WithDatabase_ExpectedValues() { @@ -95,22 +99,19 @@ var properties = new DesignWaterLevelLocationsContextProperties(new HydraulicBoundaryDatabase()); // Assert - var dynamicPropertyBag = new DynamicPropertyBag(properties); - const string expectedLocationsDisplayName = "Locaties"; - const string expectedLocationsDescription = "Locaties uit de hydraulische randvoorwaardendatabase."; - const string expectedLocationsCategory = "Algemeen"; TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); - PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(); - PropertyDescriptor locationsProperty = dynamicProperties.Find("Locations", false); - Assert.IsInstanceOf(classTypeConverter); - Assert.IsNotNull(locationsProperty); + + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(1, dynamicProperties.Count); + + PropertyDescriptor locationsProperty = dynamicProperties[requiredLocationsPropertyIndex]; Assert.IsInstanceOf(locationsProperty.Converter); - Assert.IsTrue(locationsProperty.IsReadOnly); - Assert.IsTrue(locationsProperty.IsBrowsable); - Assert.AreEqual(expectedLocationsDisplayName, locationsProperty.DisplayName); - Assert.AreEqual(expectedLocationsDescription, locationsProperty.Description); - Assert.AreEqual(expectedLocationsCategory, locationsProperty.Category); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(locationsProperty, + "Algemeen", + "Locaties", + "Locaties uit de hydraulische randvoorwaardendatabase.", + true); } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/WaveHeightLocationsContextPropertiesTest.cs =================================================================== diff -u -r545b105a213ed85564861b4bcf6d2d6425dbde50 -r1930dd0513dd2e649905034334d8896d36640c7b --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/WaveHeightLocationsContextPropertiesTest.cs (.../WaveHeightLocationsContextPropertiesTest.cs) (revision 545b105a213ed85564861b4bcf6d2d6425dbde50) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/WaveHeightLocationsContextPropertiesTest.cs (.../WaveHeightLocationsContextPropertiesTest.cs) (revision 1930dd0513dd2e649905034334d8896d36640c7b) @@ -24,6 +24,7 @@ using System.Linq; using Core.Common.Gui.Converters; using Core.Common.Gui.PropertyBag; +using Core.Common.TestUtil; using Core.Common.Utils.Reflection; using NUnit.Framework; using Ringtoets.Common.Data.Hydraulics; @@ -35,6 +36,8 @@ [TestFixture] public class WaveHeightLocationsContextPropertiesTest { + private const int requiredLocationsPropertyIndex = 0; + [Test] public void Constructor_WithoutDatabase_ExpectedValues() { @@ -45,6 +48,7 @@ string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("database", paramName); } + [Test] public void Constructor_WithDatabase_ExpectedValues() { @@ -95,22 +99,19 @@ var properties = new WaveHeightLocationsContextProperties(new HydraulicBoundaryDatabase()); // Assert - var dynamicPropertyBag = new DynamicPropertyBag(properties); - const string expectedLocationsDisplayName = "Locaties"; - const string expectedLocationsDescription = "Locaties uit de hydraulische randvoorwaardendatabase."; - const string expectedLocationsCategory = "Algemeen"; TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); - PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(); - PropertyDescriptor locationsProperty = dynamicProperties.Find("Locations", false); - Assert.IsInstanceOf(classTypeConverter); - Assert.IsNotNull(locationsProperty); + + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(1, dynamicProperties.Count); + + PropertyDescriptor locationsProperty = dynamicProperties[requiredLocationsPropertyIndex]; Assert.IsInstanceOf(locationsProperty.Converter); - Assert.IsTrue(locationsProperty.IsReadOnly); - Assert.IsTrue(locationsProperty.IsBrowsable); - Assert.AreEqual(expectedLocationsDisplayName, locationsProperty.DisplayName); - Assert.AreEqual(expectedLocationsDescription, locationsProperty.Description); - Assert.AreEqual(expectedLocationsCategory, locationsProperty.Category); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(locationsProperty, + "Algemeen", + "Locaties", + "Locaties uit de hydraulische randvoorwaardendatabase.", + true); } } } \ No newline at end of file