Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/Views/HeightStructuresCalculationRowTest.cs =================================================================== diff -u -r91fffe9a6b4c099c55ff96d1322e30e9dc7bacf3 -r0bcd62a225911822cffd8cad75f7680bfc2199cf --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/Views/HeightStructuresCalculationRowTest.cs (.../HeightStructuresCalculationRowTest.cs) (revision 91fffe9a6b4c099c55ff96d1322e30e9dc7bacf3) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/Views/HeightStructuresCalculationRowTest.cs (.../HeightStructuresCalculationRowTest.cs) (revision 0bcd62a225911822cffd8cad75f7680bfc2199cf) @@ -45,7 +45,7 @@ [TestFixture] public class HeightStructuresCalculationRowTest { - private const int useBreakWaterTypeColumnIndex = 3; + private const int useBreakWaterColumnIndex = 3; private const int breakWaterTypeColumnIndex = 4; private const int breakWaterHeightColumnIndex = 5; private const int useForeshoreColumnIndex = 6; @@ -63,7 +63,7 @@ // Call var row = new HeightStructuresCalculationRow(calculationScenario, handler); - // Asserts + // Assert Assert.IsInstanceOf>>(row); Assert.IsInstanceOf(row); @@ -72,7 +72,7 @@ IDictionary columnStateDefinitions = row.ColumnStateDefinitions; Assert.AreEqual(4, columnStateDefinitions.Count); - DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnStateDefinition(columnStateDefinitions, useBreakWaterTypeColumnIndex); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnStateDefinition(columnStateDefinitions, useBreakWaterColumnIndex); DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnStateDefinition(columnStateDefinitions, breakWaterTypeColumnIndex); DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnStateDefinition(columnStateDefinitions, breakWaterHeightColumnIndex); DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnStateDefinition(columnStateDefinitions, useForeshoreColumnIndex); @@ -107,7 +107,7 @@ } [Test] - public void ForeshoreProfile_ChangeToEqualValue_NoNotificationsOutputNotCleared() + public void ForeshoreProfile_ChangeToEqualValue_NoNotificationsAndOutputNotCleared() { // Setup DataGridViewComboBoxItemWrapper oldValue = null; @@ -140,7 +140,7 @@ [Test] [TestCase(true)] [TestCase(false)] - public void UseBreakWater_ChangeToEqualValue_NoNotificationsOutputNotCleared(bool useBreakWater) + public void UseBreakWater_ChangeToEqualValue_NoNotificationsAndOutputNotCleared(bool useBreakWater) { // Setup bool oldValue = useBreakWater; @@ -161,33 +161,6 @@ } [Test] - [TestCase(true, true)] - [TestCase(false, false)] - public void UseBreakWaterState_AlwaysOnChange_CorrectColumnStates(bool useBreakWaterState, bool columnIsEnabled) - { - // Setup - var calculation = new StructuresCalculationScenario - { - InputParameters = - { - ForeshoreProfile = new TestForeshoreProfile() - } - }; - - // Call - var row = new HeightStructuresCalculationRow(calculation, new ObservablePropertyChangeHandler(calculation, new HeightStructuresInput())) - { - UseBreakWater = useBreakWaterState - }; - - // Asserts - IDictionary columnStateDefinitions = row.ColumnStateDefinitions; - - DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterTypeColumnIndex], columnIsEnabled); - DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterHeightColumnIndex], columnIsEnabled); - } - - [Test] [TestCase(BreakWaterType.Wall, BreakWaterType.Dam)] [TestCase(BreakWaterType.Caisson, BreakWaterType.Wall)] [TestCase(BreakWaterType.Dam, BreakWaterType.Caisson)] @@ -213,7 +186,7 @@ [TestCase(BreakWaterType.Wall)] [TestCase(BreakWaterType.Caisson)] [TestCase(BreakWaterType.Dam)] - public void BreakWaterType_ChangeToEqualValue_NoNotificationsOutputNotCleared(BreakWaterType breakWaterType) + public void BreakWaterType_ChangeToEqualValue_NoNotificationsAndOutputNotCleared(BreakWaterType breakWaterType) { // Call AssertPropertyNotChanged( @@ -243,7 +216,7 @@ } [Test] - public void BreakWaterHeight_ChangeToEqualValue_NoNotificationsOutputNotCleared() + public void BreakWaterHeight_ChangeToEqualValue_NoNotificationsAndOutputNotCleared() { // Setup var oldValue = new RoundedDouble(4, 16); @@ -274,7 +247,7 @@ } [Test] - public void UseForeShoreGeometry_ChangeToEqualValue_NoNotificationsOutputNotCleared() + public void UseForeShoreGeometry_ChangeToEqualValue_NoNotificationsAndOutputNotCleared() { // Setup var oldValue = true; @@ -295,66 +268,6 @@ } [Test] - public void UseForeshoreState_DikeProfileHasForeshoreGeometry_CorrectColumnState() - { - // Setup - var calculation = new StructuresCalculationScenario - { - InputParameters = - { - UseForeshore = true, - ForeshoreProfile = new TestForeshoreProfile(new[] - { - new Point2D(0.0, 0.0) - }) - } - }; - - // Call - var row = new HeightStructuresCalculationRow(calculation, new ObservablePropertyChangeHandler(calculation, new HeightStructuresInput())); - - // Asserts - IDictionary columnStateDefinitions = row.ColumnStateDefinitions; - DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useForeshoreColumnIndex], true); - } - - [Test] - public void UseForeshoreState_CalculationWithoutDikeProfile_CorrectColumnState() - { - // Setup - var calculation = new StructuresCalculationScenario(); - - // Call - var row = new HeightStructuresCalculationRow(calculation, new ObservablePropertyChangeHandler(calculation, new HeightStructuresInput())); - - // Asserts - IDictionary columnStateDefinitions = row.ColumnStateDefinitions; - - DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnStateIsDisabled(columnStateDefinitions[useForeshoreColumnIndex]); - } - - [Test] - public void UseForeshoreState_CalculationWithDikeProfileWithoutForeshoreGeometry_CorrectColumnState() - { - // Setup - var calculation = new StructuresCalculationScenario - { - InputParameters = - { - ForeshoreProfile = new TestForeshoreProfile() - } - }; - - // Call - var row = new HeightStructuresCalculationRow(calculation, new ObservablePropertyChangeHandler(calculation, new HeightStructuresInput())); - - // Asserts - IDictionary columnStateDefinitions = row.ColumnStateDefinitions; - - DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnStateIsDisabled(columnStateDefinitions[useForeshoreColumnIndex]); - } - - [Test] public void LevelCrestStructure_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged() { // Setup @@ -367,7 +280,7 @@ } [Test] - public void LevelCrestStructure_ChangeToEqualValue_NoNotificationsOutputNotCleared() + public void LevelCrestStructure_ChangeToEqualValue_NoNotificationsAndOutputNotCleared() { // Setup var oldValue = new RoundedDouble(4, 0.03); @@ -400,7 +313,7 @@ } [Test] - public void CriticalOvertoppingDischarge_ChangeToEqualValue_NoNotificationsOutputNotCleared() + public void CriticalOvertoppingDischarge_ChangeToEqualValue_NoNotificationsAndOutputNotCleared() { // Setup var oldValue = new RoundedDouble(4, 0.03); @@ -433,7 +346,7 @@ } [Test] - public void AllowedLevelIncreaseStorage_ChangeToEqualValue_NoNotificationsOutputNotCleared() + public void AllowedLevelIncreaseStorage_ChangeToEqualValue_NoNotificationsAndOutputNotCleared() { // Setup var oldValue = new RoundedDouble(4, 0.03); @@ -551,5 +464,176 @@ Assert.AreSame(assignedOutput, calculation.Output); } } + + #region Column states + + [Test] + public void Constructor_ForeshoreProfileNull_CorrectColumnStates() + { + // Setup + var calculation = new StructuresCalculationScenario(); + + // Call + var row = new HeightStructuresCalculationRow(calculation, new ObservablePropertyChangeHandler(calculation, new HeightStructuresInput())); + + // Assert + IDictionary columnStateDefinitions = row.ColumnStateDefinitions; + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useBreakWaterColumnIndex], false); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterTypeColumnIndex], false); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterHeightColumnIndex], false); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useForeshoreColumnIndex], false); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Constructor_ForeshoreProfileWithoutGeometry_CorrectColumnStates(bool useBreakWater) + { + // Setup + var calculation = new StructuresCalculationScenario + { + InputParameters = + { + ForeshoreProfile = new TestForeshoreProfile(), + UseBreakWater = useBreakWater + } + }; + + // Call + var row = new HeightStructuresCalculationRow(calculation, new ObservablePropertyChangeHandler(calculation, new HeightStructuresInput())); + + // Assert + IDictionary columnStateDefinitions = row.ColumnStateDefinitions; + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useBreakWaterColumnIndex], true); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterTypeColumnIndex], useBreakWater); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterHeightColumnIndex], useBreakWater); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useForeshoreColumnIndex], false); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Constructor_ForeshoreProfileWithGeometry_CorrectColumnStates(bool useBreakWater) + { + // Setup + var calculation = new StructuresCalculationScenario + { + InputParameters = + { + ForeshoreProfile = new TestForeshoreProfile(new[] + { + new Point2D(0.0, 0.0) + }), + UseBreakWater = useBreakWater + } + }; + + // Call + var row = new HeightStructuresCalculationRow(calculation, new ObservablePropertyChangeHandler(calculation, new HeightStructuresInput())); + + // Assert + IDictionary columnStateDefinitions = row.ColumnStateDefinitions; + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useBreakWaterColumnIndex], true); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterTypeColumnIndex], useBreakWater); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterHeightColumnIndex], useBreakWater); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useForeshoreColumnIndex], true); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void UseBreakWater_AlwaysOnChange_CorrectColumnStates(bool useBreakWater) + { + // Setup + var calculation = new StructuresCalculationScenario + { + InputParameters = + { + ForeshoreProfile = new TestForeshoreProfile() + } + }; + + // Call + var row = new HeightStructuresCalculationRow(calculation, new ObservablePropertyChangeHandler(calculation, new HeightStructuresInput())) + { + UseBreakWater = useBreakWater + }; + + // Assert + IDictionary columnStateDefinitions = row.ColumnStateDefinitions; + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterTypeColumnIndex], useBreakWater); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterHeightColumnIndex], useBreakWater); + } + + [Test] + public void ForeshoreProfile_OnChangeToNull_CorrectColumnStates() + { + // Setup + var calculation = new StructuresCalculationScenario + { + InputParameters = + { + ForeshoreProfile = new TestForeshoreProfile() + } + }; + + // Call + var row = new HeightStructuresCalculationRow(calculation, new ObservablePropertyChangeHandler(calculation, new HeightStructuresInput())) + { + ForeshoreProfile = new DataGridViewComboBoxItemWrapper(null) + }; + + // Assert + IDictionary columnStateDefinitions = row.ColumnStateDefinitions; + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useBreakWaterColumnIndex], false); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterTypeColumnIndex], false); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterHeightColumnIndex], false); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useForeshoreColumnIndex], false); + } + + [Test] + public void ForeshoreProfile_OnChangeToProfileWithoutGeometry_CorrectColumnStates() + { + // Setup + var calculation = new StructuresCalculationScenario(); + + // Call + var row = new HeightStructuresCalculationRow(calculation, new ObservablePropertyChangeHandler(calculation, new HeightStructuresInput())) + { + ForeshoreProfile = new DataGridViewComboBoxItemWrapper(new TestForeshoreProfile()) + }; + + // Assert + IDictionary columnStateDefinitions = row.ColumnStateDefinitions; + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useBreakWaterColumnIndex], true); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterTypeColumnIndex], false); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterHeightColumnIndex], false); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useForeshoreColumnIndex], false); + } + + [Test] + public void ForeshoreProfile_OnChangeToProfileWithGeometry_CorrectColumnStates() + { + // Setup + var calculation = new StructuresCalculationScenario(); + + // Call + var row = new HeightStructuresCalculationRow(calculation, new ObservablePropertyChangeHandler(calculation, new HeightStructuresInput())) + { + ForeshoreProfile = new DataGridViewComboBoxItemWrapper(new TestForeshoreProfile(new[] + { + new Point2D(0.0, 0.0) + })) + }; + + // Assert + IDictionary columnStateDefinitions = row.ColumnStateDefinitions; + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useBreakWaterColumnIndex], true); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterTypeColumnIndex], false); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[breakWaterHeightColumnIndex], false); + DataGridViewControlColumnStateDefinitionTestHelper.AssertColumnState(columnStateDefinitions[useForeshoreColumnIndex], true); + } + + #endregion } } \ No newline at end of file