Index: Core/Common/src/Core.Common.Controls/DataGrid/DataGridViewControl.cs =================================================================== diff -u -rf315a60102e1e51f109af228aaf7054f88f0ef81 -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Core/Common/src/Core.Common.Controls/DataGrid/DataGridViewControl.cs (.../DataGridViewControl.cs) (revision f315a60102e1e51f109af228aaf7054f88f0ef81) +++ Core/Common/src/Core.Common.Controls/DataGrid/DataGridViewControl.cs (.../DataGridViewControl.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -402,6 +402,8 @@ /// /// The index of the column. /// The visibility of the column. + /// Thrown when the + /// index of the column does not exist. public void SetColumnVisibility(int columnIndex, bool isVisible) { GetColumnFromIndex(columnIndex).Visible = isVisible; Index: Core/Common/src/Core.Common.Controls/Views/ISelectionProvider.cs =================================================================== diff -u -r67e77262b9f0f183db81f8c95d7b12aa5fcdb8e9 -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Core/Common/src/Core.Common.Controls/Views/ISelectionProvider.cs (.../ISelectionProvider.cs) (revision 67e77262b9f0f183db81f8c95d7b12aa5fcdb8e9) +++ Core/Common/src/Core.Common.Controls/Views/ISelectionProvider.cs (.../ISelectionProvider.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -24,7 +24,7 @@ namespace Core.Common.Controls.Views { /// - /// Interface for views which can influence the selection on an application level. + /// Interface for views and controls which can influence the selection on an application level. /// public interface ISelectionProvider { Index: Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewControlTest.cs =================================================================== diff -u -rf315a60102e1e51f109af228aaf7054f88f0ef81 -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewControlTest.cs (.../DataGridViewControlTest.cs) (revision f315a60102e1e51f109af228aaf7054f88f0ef81) +++ Core/Common/test/Core.Common.Controls.Test/DataGrid/DataGridViewControlTest.cs (.../DataGridViewControlTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -1249,14 +1249,14 @@ [Test] [TestCase(true)] [TestCase(false)] - public void SetColumnVisibility_Always_SetColumnToGivenVisibility(bool isVisible) + public void SetColumnVisibility_IsVisible_SetColumnToGivenVisibility(bool isVisible) { // Setup using (var form = new Form()) using (var control = new DataGridViewControl()) { form.Controls.Add(control); - form.Show(); + control.AddTextBoxColumn("Test property", "Test header"); DataGridViewColumn dataGridViewColumn = control.GetColumnFromIndex(0); Index: Core/Plugins/test/Core.Plugins.Chart.Test/Legend/ChartLegendViewTest.cs =================================================================== diff -u -r75f679b341a9a7b82f35a623e6409ed28c74632f -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Core/Plugins/test/Core.Plugins.Chart.Test/Legend/ChartLegendViewTest.cs (.../ChartLegendViewTest.cs) (revision 75f679b341a9a7b82f35a623e6409ed28c74632f) +++ Core/Plugins/test/Core.Plugins.Chart.Test/Legend/ChartLegendViewTest.cs (.../ChartLegendViewTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -66,6 +66,7 @@ // Assert Assert.IsInstanceOf(view); Assert.IsInstanceOf(view); + Assert.IsInstanceOf(view); Assert.IsNull(view.Data); Assert.AreEqual(Resources.General_Chart, view.Text); } Index: Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapLegendViewTest.cs =================================================================== diff -u -r75f679b341a9a7b82f35a623e6409ed28c74632f -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapLegendViewTest.cs (.../MapLegendViewTest.cs) (revision 75f679b341a9a7b82f35a623e6409ed28c74632f) +++ Core/Plugins/test/Core.Plugins.Map.Test/Legend/MapLegendViewTest.cs (.../MapLegendViewTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -71,6 +71,7 @@ // Assert Assert.IsInstanceOf(view); Assert.IsInstanceOf(view); + Assert.IsInstanceOf(view); Assert.IsNull(view.Data); Assert.AreEqual(Resources.General_Map, view.Text); Assert.IsNotNull(treeViewControl); Index: Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/GeneralResultSubMechanismIllustrationPointExtensions.cs =================================================================== diff -u -rb7988d7a5616c8c305dac4419a15d5eda07e88bc -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/GeneralResultSubMechanismIllustrationPointExtensions.cs (.../GeneralResultSubMechanismIllustrationPointExtensions.cs) (revision b7988d7a5616c8c305dac4419a15d5eda07e88bc) +++ Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/GeneralResultSubMechanismIllustrationPointExtensions.cs (.../GeneralResultSubMechanismIllustrationPointExtensions.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -36,15 +36,15 @@ /// true when all closing situations are the same; false otherwise. /// Thrown when /// is null. - public static bool AllClosingSituationsSame(this GeneralResultSubMechanismIllustrationPoint illustrationPoint) + public static bool AreAllClosingSituationsSame(this GeneralResultSubMechanismIllustrationPoint illustrationPoint) { if (illustrationPoint == null) { throw new ArgumentNullException(nameof(illustrationPoint)); } return illustrationPoint.TopLevelSubMechanismIllustrationPoints - .Any(ip => ip.ClosingSituation != illustrationPoint.TopLevelSubMechanismIllustrationPoints + .All(ip => ip.ClosingSituation == illustrationPoint.TopLevelSubMechanismIllustrationPoints .First().ClosingSituation); } } Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsStackChartDataFactory.cs =================================================================== diff -u -rb7988d7a5616c8c305dac4419a15d5eda07e88bc -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsStackChartDataFactory.cs (.../RingtoetsStackChartDataFactory.cs) (revision b7988d7a5616c8c305dac4419a15d5eda07e88bc) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Factories/RingtoetsStackChartDataFactory.cs (.../RingtoetsStackChartDataFactory.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -68,7 +68,7 @@ illustrationPoint.ClosingSituation)) .ToArray(); - bool showClosingSituation = generalResultSubMechanismIllustrationPoint.AllClosingSituationsSame(); + bool showClosingSituation = !generalResultSubMechanismIllustrationPoint.AreAllClosingSituationsSame(); foreach (Tuple label in labels) { Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/TopLevelSubMechanismIllustrationPointProperties.cs =================================================================== diff -u -rb7988d7a5616c8c305dac4419a15d5eda07e88bc -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/TopLevelSubMechanismIllustrationPointProperties.cs (.../TopLevelSubMechanismIllustrationPointProperties.cs) (revision b7988d7a5616c8c305dac4419a15d5eda07e88bc) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/TopLevelSubMechanismIllustrationPointProperties.cs (.../TopLevelSubMechanismIllustrationPointProperties.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -28,8 +28,8 @@ using Core.Common.Utils; using Core.Common.Utils.Attributes; using Ringtoets.Common.Data.IllustrationPoints; +using Ringtoets.Common.Forms.Properties; using Ringtoets.Common.Forms.TypeConverters; -using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.Common.Forms.PropertyClasses { @@ -40,8 +40,9 @@ public class TopLevelSubMechanismIllustrationPointProperties : ObjectProperties { [PropertyOrder(1)] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.CalculationOutput_CalculatedProbability_DisplayName))] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.CalculationOutput_CalculatedProbability_Description))] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.CalculationOutput_CalculatedProbability_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.CalculationOutput_CalculatedProbability_Description))] [TypeConverter(typeof(NoProbabilityValueDoubleConverter))] public double CalculatedProbability { @@ -53,8 +54,9 @@ } [PropertyOrder(2)] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.CalculationOutput_CalculatedReliability_DisplayName))] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.CalculationOutput_CalculatedReliability_Description))] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.CalculationOutput_CalculatedReliability_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.CalculationOutput_CalculatedReliability_Description))] [TypeConverter(typeof(NoValueRoundedDoubleConverter))] public RoundedDouble CalculatedReliability { @@ -65,8 +67,9 @@ } [PropertyOrder(3)] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.IllustrationPoint_WindDirection_DisplayName))] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.IllustrationPoint_WindDirection_Description))] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.IllustrationPoint_WindDirection_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.IllustrationPoint_WindDirection_Description))] public string WindDirection { get @@ -76,8 +79,9 @@ } [PropertyOrder(4)] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.IllustrationPoint_ClosingSituation_DisplayName))] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.IllustrationPoint_ClosingSituation_Description))] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.IllustrationPoint_ClosingSituation_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.IllustrationPoint_ClosingSituation_Description))] public string ClosingSituation { get @@ -87,8 +91,9 @@ } [PropertyOrder(5)] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_AlphaValues_DisplayName))] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_AlphaValues_Description))] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.HydraulicBoundaryDatabase_AlphaValues_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.HydraulicBoundaryDatabase_AlphaValues_Description))] [TypeConverter(typeof(KeyValueExpandableArrayConverter))] [KeyValueElement(nameof(SubMechanismIllustrationPointStochast.Name), nameof(SubMechanismIllustrationPointStochast.Alpha))] public SubMechanismIllustrationPointStochast[] AlphaValues @@ -100,8 +105,9 @@ } [PropertyOrder(6)] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Durations_DisplayName))] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Durations_Description))] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.HydraulicBoundaryDatabase_Durations_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.HydraulicBoundaryDatabase_Durations_Description))] [TypeConverter(typeof(KeyValueExpandableArrayConverter))] [KeyValueElement(nameof(SubMechanismIllustrationPointStochast.Name), nameof(SubMechanismIllustrationPointStochast.Duration))] public SubMechanismIllustrationPointStochast[] Durations @@ -113,8 +119,9 @@ } [PropertyOrder(7)] - [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.IllustrationPoint_Values_DisplayName))] - [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.IllustrationPoint_Values_Description))] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.IllustrationPoint_Values_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.IllustrationPoint_Values_Description))] [TypeConverter(typeof(KeyValueExpandableArrayConverter))] [KeyValueElement(nameof(IllustrationPointResult.Description), nameof(IllustrationPointResult.Value))] public IllustrationPointResult[] IllustrationPointResults Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointRow.cs =================================================================== diff -u -rb7988d7a5616c8c305dac4419a15d5eda07e88bc -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointRow.cs (.../IllustrationPointRow.cs) (revision b7988d7a5616c8c305dac4419a15d5eda07e88bc) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointRow.cs (.../IllustrationPointRow.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -21,6 +21,8 @@ using System; using System.ComponentModel; +using Core.Common.Base.Data; +using Core.Common.Base.TypeConverters; using Core.Common.Utils; using Ringtoets.Common.Data.IllustrationPoints; using Ringtoets.Common.Forms.TypeConverters; @@ -35,7 +37,7 @@ /// /// Creates a new instance of . /// - /// + /// The illustration point to create the row for. /// Thrown when /// is null. public IllustrationPointRow(TopLevelSubMechanismIllustrationPoint illustrationPoint) @@ -84,14 +86,18 @@ /// /// Gets the calculated reliability. /// - public double Reliability + [TypeConverter(typeof(NoValueRoundedDoubleConverter))] + public RoundedDouble Reliability { get { return IllustrationPoint.SubMechanismIllustrationPoint.Beta; } } + /// + /// Gets the wrapped illustration point. + /// public TopLevelSubMechanismIllustrationPoint IllustrationPoint { get; } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsTableControl.cs =================================================================== diff -u -rb7988d7a5616c8c305dac4419a15d5eda07e88bc -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsTableControl.cs (.../IllustrationPointsTableControl.cs) (revision b7988d7a5616c8c305dac4419a15d5eda07e88bc) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/IllustrationPointsTableControl.cs (.../IllustrationPointsTableControl.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -100,7 +100,7 @@ { if (data != null) { - if (data.AllClosingSituationsSame()) + if (!data.AreAllClosingSituationsSame()) { illustrationPointsDataGridViewControl.SetColumnVisibility(closingSituationColumnIndex, true); return; Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/GeneralResultSubMechanismIllustrationPointExtensionsTest.cs =================================================================== diff -u -rb7988d7a5616c8c305dac4419a15d5eda07e88bc -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/GeneralResultSubMechanismIllustrationPointExtensionsTest.cs (.../GeneralResultSubMechanismIllustrationPointExtensionsTest.cs) (revision b7988d7a5616c8c305dac4419a15d5eda07e88bc) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/GeneralResultSubMechanismIllustrationPointExtensionsTest.cs (.../GeneralResultSubMechanismIllustrationPointExtensionsTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -31,21 +31,21 @@ public class GeneralResultSubMechanismIllustrationPointExtensionsTest { [Test] - public void AllClosingSituationsSame_IllustrationPointNull_ThrowsArgumentNullException() + public void AreAllClosingSituationsSame_IllustrationPointNull_ThrowsArgumentNullException() { // Setup GeneralResultSubMechanismIllustrationPoint illustrationPoint = null; // Call - TestDelegate test = () => illustrationPoint.AllClosingSituationsSame(); + TestDelegate test = () => illustrationPoint.AreAllClosingSituationsSame(); // Assert var exception = Assert.Throws(test); Assert.AreEqual("illustrationPoint", exception.ParamName); } [Test] - public void AllClosingSituationsSame_SituationsSame_ReturnTrue() + public void AreAllClosingSituationsSame_SituationsNotSame_ReturnFalse() { // Setup var illustrationPoint = new GeneralResultSubMechanismIllustrationPoint( @@ -62,14 +62,14 @@ }); // Call - bool situationsSame = illustrationPoint.AllClosingSituationsSame(); + bool situationsSame = illustrationPoint.AreAllClosingSituationsSame(); // Assert - Assert.IsTrue(situationsSame); + Assert.IsFalse(situationsSame); } [Test] - public void AllClosingSituationsSame_SituationsNotSame_ReturnFalse() + public void AreAllClosingSituationsSame_SituationsSame_ReturnTrue() { // Setup var illustrationPoint = new GeneralResultSubMechanismIllustrationPoint( @@ -86,10 +86,26 @@ }); // Call - bool situationsSame = illustrationPoint.AllClosingSituationsSame(); + bool situationsSame = illustrationPoint.AreAllClosingSituationsSame(); // Assert - Assert.IsFalse(situationsSame); + Assert.IsTrue(situationsSame); } + + [Test] + public void AreAllClosingSituationsSame_TopLevelSubMechanismIllustrationPointsEmpty_ReturnTrue() + { + // Setup + var illustrationPoint = new GeneralResultSubMechanismIllustrationPoint( + WindDirectionTestFactory.CreateTestWindDirection(), + Enumerable.Empty(), + Enumerable.Empty()); + + // Call + bool situationsSame = illustrationPoint.AreAllClosingSituationsSame(); + + // Assert + Assert.IsTrue(situationsSame); + } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/TestSubMechanismIllustrationPointTest.cs =================================================================== diff -u -rb7988d7a5616c8c305dac4419a15d5eda07e88bc -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/TestSubMechanismIllustrationPointTest.cs (.../TestSubMechanismIllustrationPointTest.cs) (revision b7988d7a5616c8c305dac4419a15d5eda07e88bc) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/TestSubMechanismIllustrationPointTest.cs (.../TestSubMechanismIllustrationPointTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -29,7 +29,7 @@ public class TestSubMechanismIllustrationPointTest { [Test] - public void DefaultConstructor_Test() + public void DefaultConstructor_ExpectedValues() { // Call var illustrationPoint = new TestSubMechanismIllustrationPoint(); @@ -42,5 +42,23 @@ CollectionAssert.IsEmpty(illustrationPoint.IllustrationPointResults); Assert.AreEqual(3.14, illustrationPoint.Beta, illustrationPoint.Beta.GetAccuracy()); } + + [Test] + public void ParameterdConstructor_ExpectedValues() + { + // Setup + const double beta = 1.23; + + // Call + var illustrationPoint = new TestSubMechanismIllustrationPoint(beta); + + // Assert + Assert.IsInstanceOf(illustrationPoint); + + Assert.AreEqual("Illustration Point", illustrationPoint.Name); + CollectionAssert.IsEmpty(illustrationPoint.Stochasts); + CollectionAssert.IsEmpty(illustrationPoint.IllustrationPointResults); + Assert.AreEqual(beta, illustrationPoint.Beta, illustrationPoint.Beta.GetAccuracy()); + } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/IllustrationPoints/TestSubMechanismIllustrationPoint.cs =================================================================== diff -u -r1f8455066f5be4241f587c34283f1d7f8a85f78e -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/IllustrationPoints/TestSubMechanismIllustrationPoint.cs (.../TestSubMechanismIllustrationPoint.cs) (revision 1f8455066f5be4241f587c34283f1d7f8a85f78e) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/IllustrationPoints/TestSubMechanismIllustrationPoint.cs (.../TestSubMechanismIllustrationPoint.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -33,8 +33,15 @@ /// Creates a new instance of . /// public TestSubMechanismIllustrationPoint() + : this(3.14) {} + + /// + /// Creates a new instance of . + /// + /// The beta of the illustration point. + public TestSubMechanismIllustrationPoint(double beta) : base("Illustration Point", - 3.14, + beta, Enumerable.Empty(), Enumerable.Empty()) {} } Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/TopLevelSubMechanismIllustrationPointPropertiesTest.cs =================================================================== diff -u -r1f8455066f5be4241f587c34283f1d7f8a85f78e -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/TopLevelSubMechanismIllustrationPointPropertiesTest.cs (.../TopLevelSubMechanismIllustrationPointPropertiesTest.cs) (revision 1f8455066f5be4241f587c34283f1d7f8a85f78e) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/TopLevelSubMechanismIllustrationPointPropertiesTest.cs (.../TopLevelSubMechanismIllustrationPointPropertiesTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -108,27 +108,27 @@ PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(7, dynamicProperties.Count); - const string miscCategory = "Misc"; + const string generalCategory = "Algemeen"; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[0], - miscCategory, + generalCategory, "Berekende kans [1/jaar]", "De berekende kans van voorkomen van het berekende resultaat.", true); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[1], - miscCategory, + generalCategory, "Betrouwbaarheidsindex berekende kans [-]", "Betrouwbaarheidsindex van de berekende kans van voorkomen van het berekende resultaat.", true); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[2], - miscCategory, + generalCategory, "Windrichting", "De windrichting waarvoor dit illlustratiepunt is berekend.", true); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[3], - miscCategory, + generalCategory, "Sluitscenario", "Het sluitscenario waarvoor dit illustratiepunt is berekend.", true); @@ -137,7 +137,7 @@ PropertyDescriptor alphaValuesProperty = dynamicProperties[4]; Assert.NotNull(alphaValuesProperty.Attributes[typeof(KeyValueElementAttribute)]); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(alphaValuesProperty, - miscCategory, + generalCategory, "Alfa's", "Berekende invloedscoëfficiënten voor alle beschouwde stochasten.", true); @@ -146,7 +146,7 @@ PropertyDescriptor durationsProperty = dynamicProperties[5]; Assert.NotNull(durationsProperty.Attributes[typeof(KeyValueElementAttribute)]); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(durationsProperty, - miscCategory, + generalCategory, "Tijdsduren", "Tijdsduren waarop de stochasten betrekking hebben.", true); @@ -155,7 +155,7 @@ PropertyDescriptor illustrationPointResultsProperty = dynamicProperties[6]; Assert.NotNull(illustrationPointResultsProperty.Attributes[typeof(KeyValueElementAttribute)]); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(illustrationPointResultsProperty, - miscCategory, + generalCategory, "Waarden in het illustratiepunt", "Realisaties van de stochasten in het illustratiepunt.", true); Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/HydraulicBoundaryLocationsViewTest.cs =================================================================== diff -u -rb7988d7a5616c8c305dac4419a15d5eda07e88bc -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/HydraulicBoundaryLocationsViewTest.cs (.../HydraulicBoundaryLocationsViewTest.cs) (revision b7988d7a5616c8c305dac4419a15d5eda07e88bc) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/HydraulicBoundaryLocationsViewTest.cs (.../HydraulicBoundaryLocationsViewTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -26,10 +26,10 @@ using Core.Common.Base.Geometry; using NUnit.Extensions.Forms; using NUnit.Framework; -using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.IllustrationPoints; using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.TestUtil; using Ringtoets.Common.Forms.Views; namespace Ringtoets.Common.Forms.Test.Views @@ -72,10 +72,10 @@ public void Constructor_DataGridViewCorrectlyInitialized() { // Setup & Call - TestHydraulicBoundaryLocationsView view = ShowTestHydraulicBoundaryLocationsView(); + ShowTestHydraulicBoundaryLocationsView(); // Assert - var dataGridView = (DataGridView)view.Controls.Find("dataGridView", true).First(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "dataGridView"); Assert.AreEqual(5, dataGridView.ColumnCount); var locationCalculateColumn = (DataGridViewCheckBoxColumn) dataGridView.Columns[locationCalculateColumnIndex]; @@ -98,7 +98,7 @@ } [Test] - public void Data_IAssessmentSection_DataSet() + public void Data_HydraulicBoundaryLocations_DataSet() { // Setup using (var view = new TestHydraulicBoundaryLocationsView()) @@ -114,7 +114,7 @@ } [Test] - public void Data_OtherThanIAssessmentSection_DataNull() + public void Data_OtherThanHydraulicBoundaryLocations_DataNull() { // Setup using (var view = new TestHydraulicBoundaryLocationsView()) @@ -136,7 +136,7 @@ ShowFullyConfiguredTestHydraulicBoundaryLocationsView(); // Assert - var dataGridView = (DataGridView) testForm.Controls.Find("dataGridView", true).First(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "dataGridView"); DataGridViewRowCollection rows = dataGridView.Rows; Assert.AreEqual(4, rows.Count); @@ -177,9 +177,9 @@ public void CalculateForSelectedButton_OneSelectedButCalculationGuiServiceNotSet_DoesNotThrowException() { // Setup - TestHydraulicBoundaryLocationsView view = ShowFullyConfiguredTestHydraulicBoundaryLocationsView(); + ShowFullyConfiguredTestHydraulicBoundaryLocationsView(); - var dataGridView = (DataGridView) view.Controls.Find("dataGridView", true).First(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "dataGridView"); DataGridViewRowCollection rows = dataGridView.Rows; rows[0].Cells[locationCalculateColumnIndex].Value = true; @@ -202,7 +202,7 @@ return view; } - private TestHydraulicBoundaryLocationsView ShowFullyConfiguredTestHydraulicBoundaryLocationsView() + private void ShowFullyConfiguredTestHydraulicBoundaryLocationsView() { TestHydraulicBoundaryLocationsView view = ShowTestHydraulicBoundaryLocationsView(); @@ -212,8 +212,6 @@ }; view.Data = assessmentSection.HydraulicBoundaryDatabase.Locations; - - return view; } private class TestHydraulicBoundaryDatabase : HydraulicBoundaryDatabase Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointRowTest.cs =================================================================== diff -u -rb7988d7a5616c8c305dac4419a15d5eda07e88bc -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointRowTest.cs (.../IllustrationPointRowTest.cs) (revision b7988d7a5616c8c305dac4419a15d5eda07e88bc) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointRowTest.cs (.../IllustrationPointRowTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -48,10 +48,12 @@ public void Constructor_ExpectedValues() { // Setup + const double beta = 123.789; + var illustrationPoint = new TopLevelSubMechanismIllustrationPoint( WindDirectionTestFactory.CreateTestWindDirection(), "Regular", - new TestSubMechanismIllustrationPoint()); + new TestSubMechanismIllustrationPoint(beta)); // Call var row = new IllustrationPointRow(illustrationPoint); @@ -60,11 +62,16 @@ TestHelper.AssertTypeConverter( nameof(IllustrationPointRow.Probability)); + TestHelper.AssertTypeConverter( + nameof(IllustrationPointRow.Reliability)); + + double expectedProbability = StatisticsConverter.ReliabilityToProbability(illustrationPoint.SubMechanismIllustrationPoint.Beta); + Assert.AreSame(illustrationPoint, row.IllustrationPoint); Assert.AreEqual(illustrationPoint.WindDirection.Name, row.WindDirection); Assert.AreEqual(illustrationPoint.ClosingSituation, row.ClosingSituation); - Assert.AreEqual(StatisticsConverter.ReliabilityToProbability(illustrationPoint.SubMechanismIllustrationPoint.Beta), row.Probability); - Assert.AreEqual(illustrationPoint.SubMechanismIllustrationPoint.Beta, row.Reliability); + Assert.AreEqual(expectedProbability, row.Probability); + Assert.AreEqual(beta, row.Reliability); } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsControlTest.cs =================================================================== diff -u -r1f8455066f5be4241f587c34283f1d7f8a85f78e -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsControlTest.cs (.../IllustrationPointsControlTest.cs) (revision 1f8455066f5be4241f587c34283f1d7f8a85f78e) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsControlTest.cs (.../IllustrationPointsControlTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -19,21 +19,23 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; using System.Linq; using NUnit.Framework; using Ringtoets.Common.Forms.Views; using System.Windows.Forms; +using Core.Common.Controls.DataGrid; using Core.Common.Controls.Views; using NUnit.Extensions.Forms; using Ringtoets.Common.Data.IllustrationPoints; using Ringtoets.Common.Data.TestUtil.IllustrationPoints; +using Ringtoets.Common.Forms.TestUtil; namespace Ringtoets.Common.Forms.Test.Views { [TestFixture] public class IllustrationPointsControlTest { + [Test] public void Constructor_ExpectedValues() { @@ -63,14 +65,13 @@ { // Setup using (var form = new Form()) + using (var control = new IllustrationPointsControl()) { - var control = new IllustrationPointsControl(); - form.Controls.Add(control); form.Show(); - var chartControl = (IllustrationPointsChartControl) control.Controls.Find("IllustrationPointsChartControl", true).Single(); - var tableControl = (IllustrationPointsTableControl) control.Controls.Find("IllustrationPointsTableControl", true).Single(); + IllustrationPointsChartControl chartControl = ControlTestHelper.GetControls(form, "IllustrationPointsChartControl").First(); + IllustrationPointsTableControl tableControl = ControlTestHelper.GetControls(form, "IllustrationPointsTableControl").First(); var data = new TestGeneralResultSubMechanismIllustrationPoint(); @@ -89,9 +90,8 @@ { // Given using (var form = new Form()) + using (var control = new IllustrationPointsControl()) { - var control = new IllustrationPointsControl(); - form.Controls.Add(control); form.Show(); @@ -100,7 +100,7 @@ var selectionChangedCount = 0; control.SelectionChanged += (sender, args) => selectionChangedCount++; - var tableControl = (IllustrationPointsTableControl) control.Controls.Find("IllustrationPointsTableControl", true).Single(); + IllustrationPointsTableControl tableControl = ControlTestHelper.GetControls(form, "IllustrationPointsTableControl").First(); // When EventHelper.RaiseEvent(tableControl, "SelectionChanged"); @@ -111,13 +111,12 @@ } [Test] - public void Selection_Always_SameAsTableControlSelection() + public void Selection_ValidRowSelected_SameAsTableControlSelection() { - // Call + // Setup using (var form = new Form()) + using (var control = new IllustrationPointsControl()) { - var control = new IllustrationPointsControl(); - form.Controls.Add(control); form.Show(); @@ -128,18 +127,19 @@ { new TopLevelSubMechanismIllustrationPoint( WindDirectionTestFactory.CreateTestWindDirection(), "Regular", - new SubMechanismIllustrationPoint("Point 1", 0.9, - Enumerable.Empty(), - Enumerable.Empty())) + new TestSubMechanismIllustrationPoint()) }); - var tableControl = (IllustrationPointsTableControl) control.Controls.Find("IllustrationPointsTableControl", true).Single(); - var dataGridView = (DataGridView) tableControl.Controls.Find("dataGridView", true).Single(); + IllustrationPointsTableControl tableControl = ControlTestHelper.GetControls(form, "IllustrationPointsTableControl").First(); + DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(form, "illustrationPointsDataGridViewControl"); DataGridViewRow selectedLocationRow = dataGridView.Rows[0]; selectedLocationRow.Cells[0].Value = true; + // Call + object selection = tableControl.Selection; + // Assert - Assert.AreSame(tableControl.Selection, control.Selection); + Assert.AreSame(selection, control.Selection); } } } Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsTableControlTest.cs =================================================================== diff -u -r1f8455066f5be4241f587c34283f1d7f8a85f78e -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsTableControlTest.cs (.../IllustrationPointsTableControlTest.cs) (revision 1f8455066f5be4241f587c34283f1d7f8a85f78e) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/IllustrationPointsTableControlTest.cs (.../IllustrationPointsTableControlTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -28,6 +28,7 @@ using NUnit.Framework; using Ringtoets.Common.Data.IllustrationPoints; using Ringtoets.Common.Data.TestUtil.IllustrationPoints; +using Ringtoets.Common.Forms.TestUtil; using Ringtoets.Common.Forms.Views; namespace Ringtoets.Common.Forms.Test.Views @@ -72,10 +73,10 @@ public void OnLoad_DataGridViewCorrectlyInitialized() { // Setup & Call - IllustrationPointsTableControl control = ShowControl(); + ShowControl(); // Assert - var dataGridView = (DataGridView) control.Controls.Find("DataGridView", true).Single(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); Assert.AreEqual(4, dataGridView.ColumnCount); DataGridViewColumn windDirectionColumn = dataGridView.Columns[windDirectionColumnIndex]; Assert.AreEqual("Windrichting", windDirectionColumn.HeaderText); @@ -106,7 +107,7 @@ control.Data = data; // Assert - var dataGridView = (DataGridView) control.Controls.Find("DataGridView", true).Single(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); DataGridViewRowCollection rows = dataGridView.Rows; Assert.AreEqual(2, rows.Count); @@ -116,14 +117,14 @@ Assert.AreEqual("SSE", cells[windDirectionColumnIndex].FormattedValue); Assert.AreEqual("Regular", cells[closingScenarioColumnIndex].FormattedValue); Assert.AreEqual("1/5", cells[calculatedProbabilityColumnIndex].FormattedValue); - Assert.AreEqual(0.9.ToString(CultureInfo.CurrentCulture), cells[calculatedReliabilityColumnIndex].FormattedValue); + Assert.AreEqual("0.90000", cells[calculatedReliabilityColumnIndex].FormattedValue); cells = rows[1].Cells; Assert.AreEqual(4, cells.Count); Assert.AreEqual("SSE", cells[windDirectionColumnIndex].FormattedValue); Assert.AreEqual("Open", cells[closingScenarioColumnIndex].FormattedValue); Assert.AreEqual("1/4", cells[calculatedProbabilityColumnIndex].FormattedValue); - Assert.AreEqual(0.7.ToString(CultureInfo.CurrentCulture), cells[calculatedReliabilityColumnIndex].FormattedValue); + Assert.AreEqual("0.70000", cells[calculatedReliabilityColumnIndex].FormattedValue); Assert.IsTrue(dataGridView.Columns[closingScenarioColumnIndex].Visible); } @@ -139,22 +140,18 @@ { new TopLevelSubMechanismIllustrationPoint( WindDirectionTestFactory.CreateTestWindDirection(), "Regular", - new SubMechanismIllustrationPoint("Point 1", 0.9, - Enumerable.Empty(), - Enumerable.Empty())), + new TestSubMechanismIllustrationPoint(0.9)), new TopLevelSubMechanismIllustrationPoint( WindDirectionTestFactory.CreateTestWindDirection(), "Regular", - new SubMechanismIllustrationPoint("Point 2", 0.7, - Enumerable.Empty(), - Enumerable.Empty())) + new TestSubMechanismIllustrationPoint(0.7)) }); IllustrationPointsTableControl control = ShowControl(); // Call control.Data = data; // Assert - var dataGridView = (DataGridView) control.Controls.Find("DataGridView", true).Single(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); DataGridViewRowCollection rows = dataGridView.Rows; Assert.AreEqual(2, rows.Count); @@ -164,14 +161,14 @@ Assert.AreEqual("SSE", cells[windDirectionColumnIndex].FormattedValue); Assert.AreEqual("Regular", cells[closingScenarioColumnIndex].FormattedValue); Assert.AreEqual("1/5", cells[calculatedProbabilityColumnIndex].FormattedValue); - Assert.AreEqual(0.9.ToString(CultureInfo.CurrentCulture), cells[calculatedReliabilityColumnIndex].FormattedValue); + Assert.AreEqual("0.90000", cells[calculatedReliabilityColumnIndex].FormattedValue); cells = rows[1].Cells; Assert.AreEqual(4, cells.Count); Assert.AreEqual("SSE", cells[windDirectionColumnIndex].FormattedValue); Assert.AreEqual("Regular", cells[closingScenarioColumnIndex].FormattedValue); Assert.AreEqual("1/4", cells[calculatedProbabilityColumnIndex].FormattedValue); - Assert.AreEqual(0.7.ToString(CultureInfo.CurrentCulture), cells[calculatedReliabilityColumnIndex].FormattedValue); + Assert.AreEqual("0.70000", cells[calculatedReliabilityColumnIndex].FormattedValue); Assert.IsFalse(dataGridView.Columns[closingScenarioColumnIndex].Visible); } @@ -184,7 +181,7 @@ IllustrationPointsTableControl control = ShowControl(); control.Data = data; - var dataGridView = (DataGridView) control.Controls.Find("DataGridView", true).Single(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); DataGridViewRowCollection rows = dataGridView.Rows; // Precondition @@ -209,7 +206,7 @@ var selectionChangedCount = 0; control.SelectionChanged += (sender, args) => selectionChangedCount++; - var dataGridView = (DataGridView) control.Controls.Find("DataGridView", true)[0]; + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); // When dataGridView.CurrentCell = dataGridView.Rows[1].Cells[calculatedProbabilityColumnIndex]; @@ -237,7 +234,7 @@ IllustrationPointsTableControl control = ShowControl(); control.Data = GetGeneralResult(); - var dataGridView = (DataGridView) testForm.Controls.Find("dataGridView", true).First(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); DataGridViewRow selectedLocationRow = dataGridView.Rows[0]; selectedLocationRow.Cells[0].Value = true; @@ -269,14 +266,10 @@ { new TopLevelSubMechanismIllustrationPoint( WindDirectionTestFactory.CreateTestWindDirection(), "Regular", - new SubMechanismIllustrationPoint("Point 1", 0.9, - Enumerable.Empty(), - Enumerable.Empty())), + new TestSubMechanismIllustrationPoint(0.9)), new TopLevelSubMechanismIllustrationPoint( WindDirectionTestFactory.CreateTestWindDirection(), "Open", - new SubMechanismIllustrationPoint("Point 2", 0.7, - Enumerable.Empty(), - Enumerable.Empty())) + new TestSubMechanismIllustrationPoint(0.7)) }); } } Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/LocationsViewTest.cs =================================================================== diff -u -r1f8455066f5be4241f587c34283f1d7f8a85f78e -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/LocationsViewTest.cs (.../LocationsViewTest.cs) (revision 1f8455066f5be4241f587c34283f1d7f8a85f78e) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/LocationsViewTest.cs (.../LocationsViewTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -30,6 +30,7 @@ using NUnit.Framework; using Ringtoets.Common.Data.IllustrationPoints; using Ringtoets.Common.Data.TestUtil.IllustrationPoints; +using Ringtoets.Common.Forms.TestUtil; using Ringtoets.Common.Forms.Views; namespace Ringtoets.Common.Forms.Test.Views @@ -62,6 +63,7 @@ // Assert Assert.IsInstanceOf(view); Assert.IsInstanceOf(view); + Assert.IsInstanceOf(view); Assert.IsNull(view.Data); Assert.AreEqual(1, view.Controls.Count); @@ -97,7 +99,7 @@ TestLocationsView view = ShowTestCalculatableView(); // Assert - DataGridView dataGridView = GetDataGridView(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); Assert.AreEqual(1, dataGridView.ColumnCount); var calculateColumn = (DataGridViewCheckBoxColumn) dataGridView.Columns[calculateColumnIndex]; @@ -117,7 +119,7 @@ var selectionChangedCount = 0; view.SelectionChanged += (sender, args) => selectionChangedCount++; - DataGridView dataGridView = GetDataGridView(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); // When dataGridView.CurrentCell = dataGridView.Rows[1].Cells[calculateColumnIndex]; @@ -133,7 +135,7 @@ // Given ShowFullyConfiguredTestCalculatableView(); - DataGridView dataGridView = GetDataGridView(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); DataGridView illustrationPointDataGridView = GetIllustrationPointDataGridView(); // Precondition @@ -153,7 +155,7 @@ // Given TestLocationsView view = ShowFullyConfiguredTestCalculatableView(); - DataGridView dataGridView = GetDataGridView(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); DataGridViewRow currentRow = dataGridView.Rows[1]; TestCalculatableObject calculatableObject = ((TestCalculatableRow) currentRow.DataBoundItem).CalculatableObject; @@ -173,7 +175,7 @@ // Given TestLocationsView view = ShowFullyConfiguredTestCalculatableView(); - DataGridView dataGridView = GetDataGridView(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); DataGridView illustrationPointDataGridView = GetIllustrationPointDataGridView(); DataGridViewRow currentRow = illustrationPointDataGridView.Rows[1]; @@ -195,7 +197,7 @@ // Setup ShowFullyConfiguredTestCalculatableView(); - DataGridView dataGridView = GetDataGridView(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); DataGridViewRowCollection rows = dataGridView.Rows; var button = new ButtonTester("SelectAllButton", testForm); @@ -217,7 +219,7 @@ // Setup ShowFullyConfiguredTestCalculatableView(); - DataGridView dataGridView = GetDataGridView(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); var button = new ButtonTester("DeselectAllButton", testForm); DataGridViewRowCollection rows = dataGridView.Rows; @@ -256,7 +258,7 @@ { // Given TestLocationsView view = ShowFullyConfiguredTestCalculatableView(); - DataGridView dataGridView = GetDataGridView(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); // When dataGridView.Rows[0].Cells[calculateColumnIndex].Value = true; @@ -274,7 +276,7 @@ // Setup TestLocationsView view = ShowFullyConfiguredTestCalculatableView(); - DataGridView dataGridView = GetDataGridView(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); DataGridViewRowCollection rows = dataGridView.Rows; rows[0].Cells[calculateColumnIndex].Value = true; @@ -290,27 +292,12 @@ Assert.AreEqual(expectedObject, view.ObjectsToCalculate.First()); } - private DataGridView GetDataGridView() - { - return GetControls("DataGridView").First(); - } - private DataGridView GetIllustrationPointDataGridView() { - return GetControls("DataGridView").Last(); + DataGridViewControl dataGridViewControl = ControlTestHelper.GetDataGridViewControl(testForm, "illustrationPointsDataGridViewControl"); + return ControlTestHelper.GetDataGridView(dataGridViewControl, "DataGridView"); } - /// - /// Gets the controls by name. - /// - /// The name of the controls. - /// The found control. - /// Thrown when is null or empty. - private IEnumerable GetControls(string controlName) where TView : Control - { - return testForm.Controls.Find(controlName, true).Cast(); - } - private TestLocationsView ShowTestCalculatableView() { var view = new TestLocationsView(); Index: Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil.Test/ControlTestHelperTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil.Test/ControlTestHelperTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil.Test/ControlTestHelperTest.cs (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -0,0 +1,194 @@ +// 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.Collections.Generic; +using System.Windows.Forms; +using Core.Common.Controls.DataGrid; +using NUnit.Framework; + +namespace Ringtoets.Common.Forms.TestUtil.Test +{ + [TestFixture] + public class ControlTestHelperTest + { + [Test] + [TestCase(null)] + [TestCase("")] + public void GetDataGridViewControl_InvalidName_ThrowsArgumentNullException(string name) + { + // Call + TestDelegate test = () => ControlTestHelper.GetDataGridViewControl(new Form(), name); + + // Assert + Assert.Throws(test); + } + + [Test] + public void GetDataGridViewControl_NoControlOnForm_ReturnNull() + { + // Call + DataGridViewControl control = ControlTestHelper.GetDataGridViewControl(new Form(), "name"); + + // Assert + Assert.IsNull(control); + } + + [Test] + public void GetDataGridViewControl_ControlOnForm_ReturnControl() + { + // Setup + using (var form = new Form()) + using (var dataGridViewControl = new DataGridViewControl()) + { + form.Controls.Add(dataGridViewControl); + + // Call + DataGridViewControl control = ControlTestHelper.GetDataGridViewControl(form, dataGridViewControl.Name); + + // Assert + Assert.AreSame(dataGridViewControl, control); + } + } + + [Test] + [TestCase(null)] + [TestCase("")] + public void GetDataGridView_InvalidName_ThrowsArgumentNullException(string name) + { + // Call + TestDelegate test = () => ControlTestHelper.GetDataGridView(new Form(), name); + + // Assert + Assert.Throws(test); + } + + [Test] + public void GetDataGridView_NoControlOnForm_ReturnNull() + { + // Call + DataGridView control = ControlTestHelper.GetDataGridView(new Form(), "name"); + + // Assert + Assert.IsNull(control); + } + + [Test] + public void GetDataGridView_ControlOnForm_ReturnControl() + { + // Setup + using (var form = new Form()) + using (var dataGridView = new DataGridView + { + Name = "dataGridView" + }) + { + form.Controls.Add(dataGridView); + + // Call + DataGridView control = ControlTestHelper.GetDataGridView(form, dataGridView.Name); + + // Assert + Assert.AreSame(dataGridView, control); + } + } + + [Test] + [TestCase(null)] + [TestCase("")] + public void GetControls_InvalidName_ThrowsArgumentNullException(string name) + { + // Call + TestDelegate test = () => ControlTestHelper.GetControls(new Form(), name); + + // Assert + Assert.Throws(test); + } + + [Test] + public void GetControl_NoControlsOnForm_ReturnEmptyList() + { + // Call + IEnumerable controls = ControlTestHelper.GetControls(new Form(), "name"); + + // Assert + CollectionAssert.IsEmpty(controls); + } + + [Test] + public void GetControl_ControlsOnFormWithSameName_ReturnControls() + { + // Setup + const string controlName = "control"; + using (var form = new Form()) + using (var control1 = new Control + { + Name = controlName + }) + using (var control2 = new Control + { + Name = controlName + }) + { + form.Controls.Add(control1); + form.Controls.Add(control2); + + // Call + IEnumerable controls = ControlTestHelper.GetControls(form, controlName); + + // Assert + CollectionAssert.AreEqual(new[] + { + control1, + control2 + }, controls); + } + } + + [Test] + public void GetControl_ControlOnForm_ReturnControl() + { + // Setup + using (var form = new Form()) + using (var control1 = new Control + { + Name = "control1" + }) + using (var control2 = new Control + { + Name = "control2" + }) + { + form.Controls.Add(control1); + form.Controls.Add(control2); + + // Call + IEnumerable controls = ControlTestHelper.GetControls(form, "control1"); + + // Assert + CollectionAssert.AreEqual(new[] + { + control1 + }, controls); + } + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil.Test/Ringtoets.Common.Forms.TestUtil.Test.csproj =================================================================== diff -u -r635652c6ff055cbc6d3215a89f7b1207c67ded95 -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil.Test/Ringtoets.Common.Forms.TestUtil.Test.csproj (.../Ringtoets.Common.Forms.TestUtil.Test.csproj) (revision 635652c6ff055cbc6d3215a89f7b1207c67ded95) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil.Test/Ringtoets.Common.Forms.TestUtil.Test.csproj (.../Ringtoets.Common.Forms.TestUtil.Test.csproj) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -44,13 +44,15 @@ + Properties\GlobalAssembly.cs + @@ -69,10 +71,18 @@ {3bbfd65b-b277-4e50-ae6d-bd24c3434609} Core.Common.Base + + {9a2d67e6-26ac-4d17-b11a-2b4372f2f572} + Core.Common.Controls + {30e4c2ae-719e-4d70-9fa9-668a9767fbfa} Core.Common.Gui + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + {318BA582-88C9-4816-A54A-A7E431461DE3} Core.Components.Gis Index: Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/ControlTestHelper.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/ControlTestHelper.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/ControlTestHelper.cs (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -0,0 +1,71 @@ +// 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.Collections.Generic; +using System.Linq; +using System.Windows.Forms; +using Core.Common.Controls.DataGrid; + +namespace Ringtoets.Common.Forms.TestUtil +{ + /// + /// Helper class to get controls. + /// + public static class ControlTestHelper + { + /// + /// Gets the from the given form. + /// + /// The form to get the control from. + /// The name of the control. + /// The found control. + /// Thrown when is null or empty. + public static DataGridViewControl GetDataGridViewControl(Form form, string controlName) + { + return GetControls(form, controlName).FirstOrDefault(); + } + + /// + /// Gets the from the given form. + /// + /// The control to get the nested control from. + /// The name of the control. + /// The found control. + /// Thrown when is null or empty. + public static DataGridView GetDataGridView(Control control, string controlName) + { + return GetControls(control, controlName).FirstOrDefault(); + } + + /// + /// Gets the controls by name. + /// + /// The control to get the nested control from. + /// The name of the controls. + /// The found controls. + /// Thrown when is null or empty. + public static IEnumerable GetControls(Control control, string controlName) where TView : Control + { + return control.Controls.Find(controlName, true).Cast(); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/Ringtoets.Common.Forms.TestUtil.csproj =================================================================== diff -u -r4e302afb0d3eadcc21b8204f021b185dc738d5c2 -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/Ringtoets.Common.Forms.TestUtil.csproj (.../Ringtoets.Common.Forms.TestUtil.csproj) (revision 4e302afb0d3eadcc21b8204f021b185dc738d5c2) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/Ringtoets.Common.Forms.TestUtil.csproj (.../Ringtoets.Common.Forms.TestUtil.csproj) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -44,13 +44,15 @@ + Properties\GlobalAssembly.cs + @@ -69,6 +71,10 @@ {3bbfd65b-b277-4e50-ae6d-bd24c3434609} Core.Common.Base + + {9A2D67E6-26AC-4D17-B11A-2B4372F2F572} + Core.Common.Controls + {88665510-CE20-4EF5-BE4A-39800720AA2C} Core.Common.Geometry Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs =================================================================== diff -u -r0ce4c68a5285d7596b108dc1b42693970961bd50 -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (.../DesignWaterLevelLocationsViewTest.cs) (revision 0ce4c68a5285d7596b108dc1b42693970961bd50) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (.../DesignWaterLevelLocationsViewTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -19,7 +19,6 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; using System.Collections.Generic; using System.Globalization; using System.Linq; @@ -35,14 +34,13 @@ using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Data.TestUtil.IllustrationPoints; using Ringtoets.Common.Forms.GuiServices; +using Ringtoets.Common.Forms.TestUtil; using Ringtoets.Common.Forms.Views; using Ringtoets.Common.Service.MessageProviders; -using Ringtoets.Integration.Data; using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Forms.Views; using Ringtoets.Integration.Service.MessageProviders; using Button = System.Windows.Forms.Button; -using Control = System.Windows.Forms.Control; namespace Ringtoets.Integration.Forms.Test.Views { @@ -70,10 +68,10 @@ } [Test] - public void DefaultConstructor_DefaultValues() + public void Constructor_ExpectedValues() { // Call - using (var view = new DesignWaterLevelLocationsView(new AssessmentSection(AssessmentSectionComposition.Dike))) + using (var view = new DesignWaterLevelLocationsView(new ObservableTestAssessmentSectionStub())) { // Assert Assert.IsInstanceOf(view); @@ -87,7 +85,7 @@ // Given DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView(); - DataGridView dataGridView = GetDataGridView(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); DataGridViewRow currentRow = dataGridView.Rows[1]; HydraulicBoundaryLocation location = ((HydraulicBoundaryLocationRow)currentRow.DataBoundItem).CalculatableObject; @@ -105,7 +103,7 @@ public void Selection_WithoutLocations_ReturnsNull() { // Call - using (var view = new DesignWaterLevelLocationsView(new AssessmentSection(AssessmentSectionComposition.Dike))) + using (var view = new DesignWaterLevelLocationsView(new ObservableTestAssessmentSectionStub())) { // Assert Assert.IsNull(view.Selection); @@ -117,8 +115,8 @@ { // Setup ShowFullyConfiguredDesignWaterLevelLocationsView(); - IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(); - DataGridViewControl dataGridView = GetDataGridViewControl(); + IllustrationPointsControl illustrationPointsControl = ControlTestHelper.GetControls(testForm, "IllustrationPointsControl").First(); + DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); // Call dataGridView.SetCurrentCell(dataGridView.GetCell(0, 1)); @@ -132,8 +130,8 @@ { // Setup ShowFullyConfiguredDesignWaterLevelLocationsView(); - IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(); - DataGridViewControl dataGridView = GetDataGridViewControl(); + IllustrationPointsControl illustrationPointsControl = ControlTestHelper.GetControls(testForm, "IllustrationPointsControl").First(); + DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); // Call dataGridView.SetCurrentCell(dataGridView.GetCell(1, 0)); @@ -147,9 +145,9 @@ { // Setup ShowFullyConfiguredDesignWaterLevelLocationsView(); - IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(); + IllustrationPointsControl illustrationPointsControl = ControlTestHelper.GetControls(testForm, "IllustrationPointsControl").First(); - DataGridViewControl dataGridView = GetDataGridViewControl(); + DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); // Call dataGridView.SetCurrentCell(dataGridView.GetCell(4, 0)); @@ -162,10 +160,10 @@ public void Constructor_DataGridViewCorrectlyInitialized() { // Setup & Call - ShowDesignWaterLevelLocationsView(new AssessmentSection(AssessmentSectionComposition.Dike)); + ShowDesignWaterLevelLocationsView(new ObservableTestAssessmentSectionStub()); // Assert - DataGridView dataGridView = GetDataGridView(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); Assert.AreEqual(6, dataGridView.ColumnCount); var locationCalculateColumn = (DataGridViewCheckBoxColumn) dataGridView.Columns[locationCalculateColumnIndex]; @@ -197,7 +195,7 @@ ShowFullyConfiguredDesignWaterLevelLocationsView(); // Assert - DataGridViewControl dataGridView = GetDataGridViewControl(); + DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); DataGridViewRowCollection rows = dataGridView.Rows; Assert.AreEqual(5, rows.Count); @@ -268,7 +266,7 @@ newHydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryLocation); // Precondition - DataGridViewControl dataGridView = GetDataGridViewControl(); + DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); DataGridViewRowCollection rows = dataGridView.Rows; Assert.AreEqual(5, rows.Count); @@ -297,7 +295,7 @@ IAssessmentSection assessmentSection = view.AssessmentSection; // Precondition - DataGridView dataGridView = GetDataGridView(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); DataGridViewRowCollection rows = dataGridView.Rows; Assert.AreEqual(5, rows.Count); Assert.AreEqual("-", rows[0].Cells[locationDesignWaterlevelColumnIndex].FormattedValue); @@ -332,7 +330,7 @@ // Setup DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView(); IAssessmentSection assessmentSection = view.AssessmentSection; - DataGridViewControl dataGridView = GetDataGridViewControl(); + DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); DataGridViewRowCollection rows = dataGridView.Rows; rows[0].Cells[locationCalculateColumnIndex].Value = true; @@ -379,7 +377,7 @@ // Setup ShowFullyConfiguredDesignWaterLevelLocationsView(); - DataGridViewControl dataGridView = GetDataGridViewControl(); + DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); DataGridViewRowCollection rows = dataGridView.Rows; rows[0].Cells[locationCalculateColumnIndex].Value = true; @@ -397,8 +395,8 @@ { // Setup DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView(); - IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(); - DataGridViewControl dataGridView = GetDataGridViewControl(); + IllustrationPointsControl illustrationPointsControl = ControlTestHelper.GetControls(testForm, "IllustrationPointsControl").First(); + DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); dataGridView.SetCurrentCell(dataGridView.GetCell(3, 0)); @@ -417,32 +415,6 @@ Assert.AreSame(result, illustrationPointsControl.Data); } - private DataGridViewControl GetDataGridViewControl() - { - return GetControls("DataGridViewControl").Single(); - } - - private DataGridView GetDataGridView() - { - return GetControls("DataGridView").First(); - } - - private IllustrationPointsControl GetIllustrationPointsControl() - { - return GetControls("IllustrationPointsControl").Single(); - } - - /// - /// Gets the controls by name. - /// - /// The name of the controls to find. - /// The found control. - /// Thrown when is null or empty. - private IEnumerable GetControls(string controlName) where TView : Control - { - return testForm.Controls.Find(controlName, true).OfType(); - } - private DesignWaterLevelLocationsView ShowDesignWaterLevelLocationsView(IAssessmentSection assessmentSection) { var view = new DesignWaterLevelLocationsView(assessmentSection); Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs =================================================================== diff -u -r0ce4c68a5285d7596b108dc1b42693970961bd50 -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs (.../WaveHeightLocationsViewTest.cs) (revision 0ce4c68a5285d7596b108dc1b42693970961bd50) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs (.../WaveHeightLocationsViewTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -19,7 +19,6 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; using System.Collections.Generic; using System.Globalization; using System.Linq; @@ -35,8 +34,8 @@ using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Data.TestUtil.IllustrationPoints; using Ringtoets.Common.Forms.GuiServices; +using Ringtoets.Common.Forms.TestUtil; using Ringtoets.Common.Forms.Views; -using Ringtoets.Integration.Data; using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Forms.Views; @@ -66,10 +65,10 @@ } [Test] - public void DefaultConstructor_DefaultValues() + public void Constructor_ExpectedValues() { // Call - using (var view = new WaveHeightLocationsView(new AssessmentSection(AssessmentSectionComposition.Dike))) + using (var view = new WaveHeightLocationsView(new ObservableTestAssessmentSectionStub())) { // Assert Assert.IsInstanceOf(view); @@ -83,7 +82,7 @@ // Given WaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(); - DataGridView dataGridView = GetDataGridView(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); DataGridViewRow currentRow = dataGridView.Rows[1]; HydraulicBoundaryLocation location = ((HydraulicBoundaryLocationRow) currentRow.DataBoundItem).CalculatableObject; @@ -101,7 +100,7 @@ public void Selection_WithoutLocations_ReturnsNull() { // Call - using (var view = new WaveHeightLocationsView(new AssessmentSection(AssessmentSectionComposition.Dike))) + using (var view = new WaveHeightLocationsView(new ObservableTestAssessmentSectionStub())) { // Assert Assert.IsNull(view.Selection); @@ -113,9 +112,10 @@ { // Setup ShowFullyConfiguredWaveHeightLocationsView(); - IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(); + IllustrationPointsControl illustrationPointsControl = ControlTestHelper.GetControls(testForm, + "IllustrationPointsControl").First(); - DataGridViewControl dataGridView = GetDataGridViewControl(); + DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); // Call dataGridView.SetCurrentCell(dataGridView.GetCell(0, 1)); @@ -129,9 +129,10 @@ { // Setup ShowFullyConfiguredWaveHeightLocationsView(); - IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(); + IllustrationPointsControl illustrationPointsControl = ControlTestHelper.GetControls(testForm, + "IllustrationPointsControl").First(); - DataGridViewControl dataGridView = GetDataGridViewControl(); + DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); // Call dataGridView.SetCurrentCell(dataGridView.GetCell(1, 0)); @@ -145,9 +146,10 @@ { // Setup ShowFullyConfiguredWaveHeightLocationsView(); - IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(); + IllustrationPointsControl illustrationPointsControl = ControlTestHelper.GetControls(testForm, + "IllustrationPointsControl").First(); - DataGridViewControl dataGridView = GetDataGridViewControl(); + DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); // Call dataGridView.SetCurrentCell(dataGridView.GetCell(4, 0)); @@ -160,10 +162,10 @@ public void Constructor_DataGridViewCorrectlyInitialized() { // Setup & Call - ShowWaveHeightLocationsView(new AssessmentSection(AssessmentSectionComposition.Dike)); + ShowWaveHeightLocationsView(new ObservableTestAssessmentSectionStub()); // Assert - DataGridView dataGridView = GetDataGridView(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); Assert.AreEqual(6, dataGridView.ColumnCount); var locationCalculateColumn = (DataGridViewCheckBoxColumn) dataGridView.Columns[locationCalculateColumnIndex]; @@ -195,7 +197,7 @@ ShowFullyConfiguredWaveHeightLocationsView(); // Assert - DataGridViewControl dataGridView = GetDataGridViewControl(); + DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); DataGridViewRowCollection rows = dataGridView.Rows; Assert.AreEqual(5, rows.Count); @@ -266,7 +268,7 @@ newHydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryLocation); // Precondition - DataGridViewControl dataGridView = GetDataGridViewControl(); + DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); DataGridViewRowCollection rows = dataGridView.Rows; Assert.AreEqual(5, rows.Count); @@ -294,7 +296,7 @@ IAssessmentSection assessmentSection = view.AssessmentSection; // Precondition - DataGridView dataGridView = GetDataGridView(); + DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView"); DataGridViewRowCollection rows = dataGridView.Rows; Assert.AreEqual(5, rows.Count); Assert.AreEqual("-", rows[0].Cells[locationWaveHeightColumnIndex].FormattedValue); @@ -329,7 +331,7 @@ // Setup WaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(); IAssessmentSection assessmentSection = view.AssessmentSection; - DataGridViewControl dataGridView = GetDataGridViewControl(); + DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); DataGridViewRowCollection rows = dataGridView.Rows; rows[0].Cells[locationCalculateColumnIndex].Value = true; @@ -369,7 +371,7 @@ // Setup ShowFullyConfiguredWaveHeightLocationsView(); - DataGridViewControl dataGridView = GetDataGridViewControl(); + DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); DataGridViewRowCollection rows = dataGridView.Rows; rows[0].Cells[locationCalculateColumnIndex].Value = true; @@ -387,9 +389,10 @@ { // Setup WaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(); - IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(); + IllustrationPointsControl illustrationPointsControl = ControlTestHelper.GetControls(testForm, + "IllustrationPointsControl").First(); - DataGridViewControl dataGridView = GetDataGridViewControl(); + DataGridViewControl dataGridView = ControlTestHelper.GetDataGridViewControl(testForm, "DataGridViewControl"); dataGridView.SetCurrentCell(dataGridView.GetCell(3, 0)); @@ -408,32 +411,6 @@ Assert.AreSame(result, illustrationPointsControl.Data); } - private DataGridViewControl GetDataGridViewControl() - { - return GetControls("DataGridViewControl").Single(); - } - - private DataGridView GetDataGridView() - { - return GetControls("DataGridView").First(); - } - - private IllustrationPointsControl GetIllustrationPointsControl() - { - return GetControls("IllustrationPointsControl").Single(); - } - - /// - /// Gets the controls by name. - /// - /// The name of the controls to find. - /// The found control. - /// Thrown when is null or empty. - private IEnumerable GetControls(string controlName) where TView : Control - { - return testForm.Controls.Find(controlName, true).OfType(); - } - private WaveHeightLocationsView ShowWaveHeightLocationsView(IAssessmentSection assessmentSection) { var view = new WaveHeightLocationsView(assessmentSection); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs =================================================================== diff -u -r0ce4c68a5285d7596b108dc1b42693970961bd50 -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs (.../DesignWaterLevelLocationsViewInfoTest.cs) (revision 0ce4c68a5285d7596b108dc1b42693970961bd50) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs (.../DesignWaterLevelLocationsViewInfoTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -34,8 +34,8 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.GuiServices; -using Ringtoets.Integration.Data; using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Forms.Views; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -65,7 +65,7 @@ public void GetViewName_Always_ReturnsViewName() { // Setup - using (var view = new DesignWaterLevelLocationsView(new AssessmentSection(AssessmentSectionComposition.Dike))) + using (var view = new DesignWaterLevelLocationsView(new ObservableTestAssessmentSectionStub())) { // Call string viewName = info.GetViewName(view, Enumerable.Empty()); @@ -110,7 +110,7 @@ { // Setup var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + var assessmentSection = new ObservableTestAssessmentSectionStub { HydraulicBoundaryDatabase = hydraulicBoundaryDatabase }; @@ -127,7 +127,7 @@ public void CreateInstance_Always_SetExpectedProperties() { // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + var assessmentSection = new ObservableTestAssessmentSectionStub { HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase() }; @@ -165,7 +165,7 @@ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - using (var view = new DesignWaterLevelLocationsView(new AssessmentSection(AssessmentSectionComposition.Dike))) + using (var view = new DesignWaterLevelLocationsView(new ObservableTestAssessmentSectionStub())) using (var ringtoetsPlugin = new RingtoetsPlugin()) { info = ringtoetsPlugin.GetViewInfos().First(tni => tni.ViewType == typeof(DesignWaterLevelLocationsView)); @@ -186,7 +186,7 @@ public void CloseViewForData_ForMatchingAssessmentSection_ReturnsTrue() { // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + var assessmentSection = new ObservableTestAssessmentSectionStub(); using (var view = new DesignWaterLevelLocationsView(assessmentSection)) { @@ -202,8 +202,8 @@ public void CloseViewForData_ForNonMatchingAssessmentSection_ReturnsFalse() { // Setup - var assessmentSectionA = new AssessmentSection(AssessmentSectionComposition.Dike); - var assessmentSectionB = new AssessmentSection(AssessmentSectionComposition.Dike); + var assessmentSectionA = new ObservableTestAssessmentSectionStub(); + var assessmentSectionB = new ObservableTestAssessmentSectionStub(); using (var view = new DesignWaterLevelLocationsView(assessmentSectionA)) { @@ -219,7 +219,7 @@ public void CloseViewForData_ForOtherObjectType_ReturnsFalse() { // Setup - var assessmentSectionA = new AssessmentSection(AssessmentSectionComposition.Dike); + var assessmentSectionA = new ObservableTestAssessmentSectionStub(); using (var view = new DesignWaterLevelLocationsView(assessmentSectionA)) { @@ -237,7 +237,7 @@ public void CloseViewForData_ViewDataNull_ReturnsFalse() { // Setup - using (var view = new DesignWaterLevelLocationsView(new AssessmentSection(AssessmentSectionComposition.Dike))) + using (var view = new DesignWaterLevelLocationsView(new ObservableTestAssessmentSectionStub())) { // Call bool closeForData = info.CloseForData(view, new object()); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs =================================================================== diff -u -r0ce4c68a5285d7596b108dc1b42693970961bd50 -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs (.../WaveHeightLocationsViewInfoTest.cs) (revision 0ce4c68a5285d7596b108dc1b42693970961bd50) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs (.../WaveHeightLocationsViewInfoTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -32,10 +32,9 @@ using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; -using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.GuiServices; -using Ringtoets.Integration.Data; using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Forms.Views; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -65,7 +64,7 @@ public void GetViewName_Always_ReturnsViewName() { // Setup - using (var view = new WaveHeightLocationsView(new AssessmentSection(AssessmentSectionComposition.Dike))) + using (var view = new WaveHeightLocationsView(new ObservableTestAssessmentSectionStub())) { // Call string viewName = info.GetViewName(view, Enumerable.Empty()); @@ -109,11 +108,11 @@ public void GetViewData_Always_ReturnsHydraulicBoundaryDatabase() { // Setup - var mocks = new MockRepository(); var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); - var assessmentSection = mocks.Stub(); - assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - mocks.ReplayAll(); + var assessmentSection = new ObservableTestAssessmentSectionStub + { + HydraulicBoundaryDatabase = hydraulicBoundaryDatabase + }; var context = new WaveHeightLocationsContext(assessmentSection); @@ -122,15 +121,13 @@ // Assert Assert.AreSame(hydraulicBoundaryDatabase.Locations, viewData); - mocks.VerifyAll(); } [Test] public void CreateInstance_Always_SetExpectedProperties() { // Setup - - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + var assessmentSection = new ObservableTestAssessmentSectionStub { HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase() }; @@ -163,7 +160,7 @@ mocks.ReplayAll(); - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + var assessmentSection = new ObservableTestAssessmentSectionStub { HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase() }; @@ -189,7 +186,7 @@ public void CloseViewForData_ForMatchingAssessmentSection_ReturnsTrue() { // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + var assessmentSection = new ObservableTestAssessmentSectionStub(); using (var view = new WaveHeightLocationsView(assessmentSection)) { @@ -205,8 +202,8 @@ public void CloseViewForData_ForNonMatchingAssessmentSection_ReturnsFalse() { // Setup - var assessmentSectionA = new AssessmentSection(AssessmentSectionComposition.Dike); - var assessmentSectionB = new AssessmentSection(AssessmentSectionComposition.Dike); + var assessmentSectionA = new ObservableTestAssessmentSectionStub(); + var assessmentSectionB = new ObservableTestAssessmentSectionStub(); using (var view = new WaveHeightLocationsView(assessmentSectionA)) { @@ -222,7 +219,7 @@ public void CloseViewForData_ForOtherObjectType_ReturnsFalse() { // Setup - var assessmentSectionA = new AssessmentSection(AssessmentSectionComposition.Dike); + var assessmentSectionA = new ObservableTestAssessmentSectionStub(); using (var view = new WaveHeightLocationsView(assessmentSectionA)) { @@ -240,7 +237,7 @@ public void CloseViewForData_ViewDataNull_ReturnsFalse() { // Setup - using (var view = new WaveHeightLocationsView(new AssessmentSection(AssessmentSectionComposition.Dike))) + using (var view = new WaveHeightLocationsView(new ObservableTestAssessmentSectionStub())) { // Call bool closeForData = info.CloseForData(view, new object()); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsCalculationsViewTest.cs =================================================================== diff -u -r75f679b341a9a7b82f35a623e6409ed28c74632f -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsCalculationsViewTest.cs (.../MacroStabilityInwardsCalculationsViewTest.cs) (revision 75f679b341a9a7b82f35a623e6409ed28c74632f) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsCalculationsViewTest.cs (.../MacroStabilityInwardsCalculationsViewTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -76,6 +76,7 @@ // Assert Assert.IsInstanceOf(calculationsView); Assert.IsInstanceOf(calculationsView); + Assert.IsInstanceOf(calculationsView); Assert.IsNull(calculationsView.Data); Assert.IsNull(calculationsView.MacroStabilityInwardsFailureMechanism); Assert.IsNull(calculationsView.AssessmentSection); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs =================================================================== diff -u -r75f679b341a9a7b82f35a623e6409ed28c74632f -r2d014f7589947c4c9e34140b42687e496ee04c5f --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision 75f679b341a9a7b82f35a623e6409ed28c74632f) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision 2d014f7589947c4c9e34140b42687e496ee04c5f) @@ -81,6 +81,7 @@ // Assert Assert.IsInstanceOf(pipingCalculationsView); Assert.IsInstanceOf(pipingCalculationsView); + Assert.IsInstanceOf(pipingCalculationsView); Assert.IsNull(pipingCalculationsView.Data); Assert.IsNull(pipingCalculationsView.PipingFailureMechanism); Assert.IsNull(pipingCalculationsView.AssessmentSection);