Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs =================================================================== diff -u -re7b22b417acc51a88beb210ba39fef0f75e2760e -rb92f4dc3b0947596b614c4a193f27e95697c474f --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs (.../StabilityPointStructuresInputContextProperties.cs) (revision e7b22b417acc51a88beb210ba39fef0f75e2760e) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs (.../StabilityPointStructuresInputContextProperties.cs) (revision b92f4dc3b0947596b614c4a193f27e95697c474f) @@ -196,7 +196,7 @@ set { data.WrappedData.VolumicWeightWater = value; - data.WrappedData.NotifyObservers(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -275,7 +275,7 @@ set { data.WrappedData.FactorStormDurationOpenStructure = value; - data.WrappedData.NotifyObservers(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -322,7 +322,7 @@ set { data.WrappedData.InflowModelType = value; - data.WrappedData.NotifyObservers(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -340,7 +340,7 @@ set { data.WrappedData.LoadSchematizationType = value; - data.WrappedData.NotifyObservers(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -486,7 +486,7 @@ set { SetProbabilityValue(value, data.WrappedData, (wrappedData, parsedValue) => wrappedData.FailureProbabilityRepairClosure = parsedValue); - data.WrappedData.NotifyObservers(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -560,7 +560,7 @@ set { data.WrappedData.LevellingCount = value; - data.WrappedData.NotifyObservers(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -577,7 +577,7 @@ set { SetProbabilityValue(value, data.WrappedData, (wrappedData, parsedValue) => wrappedData.ProbabilityCollisionSecondaryStructure = parsedValue); - data.WrappedData.NotifyObservers(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -610,7 +610,7 @@ set { data.WrappedData.EvaluationLevel = value; - data.WrappedData.NotifyObservers(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -627,7 +627,7 @@ set { data.WrappedData.VerticalDistance = value; - data.WrappedData.NotifyObservers(); + ClearOutputAndNotifyPropertyChanged(); } } Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresInputContextPropertiesTest.cs =================================================================== diff -u -re7b22b417acc51a88beb210ba39fef0f75e2760e -rb92f4dc3b0947596b614c4a193f27e95697c474f --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresInputContextPropertiesTest.cs (.../StabilityPointStructuresInputContextPropertiesTest.cs) (revision e7b22b417acc51a88beb210ba39fef0f75e2760e) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresInputContextPropertiesTest.cs (.../StabilityPointStructuresInputContextPropertiesTest.cs) (revision b92f4dc3b0947596b614c4a193f27e95697c474f) @@ -971,6 +971,96 @@ } [Test] + [TestCase(true, TestName = "VolumicWeightWater_WithOutput_InputAndCalculationNotified")] + [TestCase(false, TestName = "VolumicWeightWater_WithoutOutput_InputNotified")] + public void VolumicWeightWater_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.VolumicWeightWater = new Random(21).NextRoundedDouble()); + } + + [Test] + [TestCase(true, TestName = "FactorStormDurationOpenStructure_WithOutput_InputAndCalculationNotified")] + [TestCase(false, TestName = "FactorStormDurationOpenStructure_WithoutOutput_InputNotified")] + public void FactorStormDurationOpenStructure_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.FactorStormDurationOpenStructure = new Random(21).NextRoundedDouble()); + } + + [Test] + [TestCase(true, TestName = "InflowModelType_WithOutput_InputAndCalculationNotified")] + [TestCase(false, TestName = "InflowModelType_WithoutOutput_InputNotified")] + public void InflowModelType_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.InflowModelType = new Random(21).NextEnumValue()); + } + + [Test] + [TestCase(true, TestName = "LoadSchematizationType_WithOutput_InputAndCalculationNotified")] + [TestCase(false, TestName = "LoadSchematizationType_WithoutOutput_InputNotified")] + public void FailureProbabilityOpenStructure_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.LoadSchematizationType = new Random(21).NextEnumValue()); + } + + [Test] + [TestCase(true, TestName = "FailureProbabilityRepairClosure_WithOutput_InputAndCalculationNotified")] + [TestCase(false, TestName = "FailureProbabilityRepairClosure_WithoutOutput_InputNotified")] + public void FailureProbabilityRepairClosure_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.FailureProbabilityRepairClosure = new Random(21).NextDouble().ToString(CultureInfo.CurrentCulture)); + } + + [Test] + [TestCase(true, TestName = "LevellingCount_WithOutput_InputAndCalculationNotified")] + [TestCase(false, TestName = "LevellingCount_WithoutOutput_InputNotified")] + public void LevellingCount_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.LevellingCount = new Random(21).Next()); + } + + [Test] + [TestCase(true, TestName = "ProbabilityCollisionSecondaryStructure_WithOutput_InputAndCalculationNotified")] + [TestCase(false, TestName = "ProbabilityCollisionSecondaryStructure_WithoutOutput_InputNotified")] + public void ProbabilityCollisionSecondaryStructure_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.ProbabilityCollisionSecondaryStructure = new Random(21).NextDouble().ToString(CultureInfo.CurrentCulture)); + } + + [Test] + [TestCase(true, TestName = "EvaluationLevel_WithOutput_InputAndCalculationNotified")] + [TestCase(false, TestName = "EvaluationLevel_WithoutOutput_InputNotified")] + public void EvaluationLevel_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.EvaluationLevel = new Random(21).NextRoundedDouble()); + } + + [Test] + [TestCase(true, TestName = "VerticalDistance_WithOutput_InputAndCalculationNotified")] + [TestCase(false, TestName = "VerticalDistance_WithoutOutput_InputNotified")] + public void VerticalDistance_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.VerticalDistance = new Random(21).NextRoundedDouble()); + } + + [Test] [TestCase(double.MinValue)] [TestCase(double.MaxValue)] public void SetFailureProbabilityRepairClosure_InvalidValues_ThrowsArgumentException(double newValue) @@ -1485,5 +1575,50 @@ private const int quadraticFloodedCulvertUseForeshorePropertyIndex = 34; #endregion + + private void SetPropertyAndVerifyNotifcationsAndOutput( + bool hasOutput, + Action setProperty) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + + var calculationObserver = mocks.StrictMock(); + int numberOfChangedProperties = hasOutput ? 1 : 0; + calculationObserver.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties); + + var inputObserver = mocks.StrictMock(); + inputObserver.Expect(o => o.UpdateObserver()); + + mocks.ReplayAll(); + + var calculation = new StructuresCalculation(); + + if (hasOutput) + { + calculation.Output = new TestStructuresOutput(); + } + calculation.Attach(calculationObserver); + + StabilityPointStructuresInput inputParameters = calculation.InputParameters; + inputParameters.Attach(inputObserver); + + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + var properties = new StabilityPointStructuresInputContextProperties(new StabilityPointStructuresInputContext(inputParameters, + calculation, + failureMechanism, + assessmentSection) + ); + + // Call + setProperty(properties); + + // Assert + Assert.IsFalse(calculation.HasOutput); + + mocks.VerifyAll(); + } } } \ No newline at end of file