Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/FailureMechanismContributionContextPropertiesTest.cs =================================================================== diff -u -r6960c6d71475e60772aaaf95b0690793c18f775c -r04a75d409f31056c8a55a8a97dc3f511c25ff212 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/FailureMechanismContributionContextPropertiesTest.cs (.../FailureMechanismContributionContextPropertiesTest.cs) (revision 6960c6d71475e60772aaaf95b0690793c18f775c) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/FailureMechanismContributionContextPropertiesTest.cs (.../FailureMechanismContributionContextPropertiesTest.cs) (revision 04a75d409f31056c8a55a8a97dc3f511c25ff212) @@ -234,7 +234,6 @@ observer.Expect(o => o.UpdateObserver()).Repeat.Never(); } mocks.ReplayAll(); - var properties = new FailureMechanismContributionContextProperties() { @@ -267,5 +266,85 @@ Assert.AreEqual(confirmChange ? newComposition : originalComposition, assessmentSection.Composition); mocks.VerifyAll(); } + + [Test] + public void ReturnPeriod_ValueChangedAndConfirmed_NotifiesChangedObjects() + { + // Setup + const int returnPeriod = 200; + const double norm = 1.0/returnPeriod; + + AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + + var observable1 = mocks.StrictMock(); + observable1.Expect(o => o.NotifyObservers()); + var observable2 = mocks.StrictMock(); + observable2.Expect(o => o.NotifyObservers()); + + var normChangeHandler = mocks.StrictMock(); + normChangeHandler.Expect(h => h.ConfirmNormChange()).Return(true); + normChangeHandler.Expect(h => h.ChangeNorm(assessmentSection, norm)) + .Return(new[] + { + observable1, + observable2 + }); + mocks.ReplayAll(); + + var properties = new FailureMechanismContributionContextProperties() + { + AssessmentSection = assessmentSection, + NormChangeHandler = normChangeHandler, + Data = assessmentSection.FailureMechanismContribution + }; + + // Call + properties.ReturnPeriod = returnPeriod; + + // Assert + mocks.VerifyAll(); + } + + [Test] + [TestCase(AssessmentSectionComposition.Dike, AssessmentSectionComposition.Dune)] + [TestCase(AssessmentSectionComposition.Dike, AssessmentSectionComposition.DikeAndDune)] + [TestCase(AssessmentSectionComposition.Dune, AssessmentSectionComposition.Dike)] + [TestCase(AssessmentSectionComposition.Dune, AssessmentSectionComposition.DikeAndDune)] + [TestCase(AssessmentSectionComposition.DikeAndDune, AssessmentSectionComposition.Dike)] + [TestCase(AssessmentSectionComposition.DikeAndDune, AssessmentSectionComposition.Dune)] + public void AssessmentSectionComposition_WhenConfirmingChanges_NotifiesChangedObjects(AssessmentSectionComposition initialComposition, AssessmentSectionComposition newComposition) + { + // Setup + var assessmentSection = new AssessmentSection(initialComposition); + + var observable1 = mocks.StrictMock(); + observable1.Expect(o => o.NotifyObservers()); + var observable2 = mocks.StrictMock(); + observable2.Expect(o => o.NotifyObservers()); + + var compositionChangeHandler = mocks.StrictMock(); + compositionChangeHandler.Expect(h => h.ConfirmCompositionChange()) + .Return(true); + compositionChangeHandler.Expect(h => h.ChangeComposition(assessmentSection, newComposition)) + .Return(new[] + { + observable1, + observable2 + }); + mocks.ReplayAll(); + + var properties = new FailureMechanismContributionContextProperties() + { + AssessmentSection = assessmentSection, + CompositionChangeHandler = compositionChangeHandler, + Data = assessmentSection.FailureMechanismContribution + }; + + // Call + properties.AssessmentSectionComposition = newComposition; + + // Assert + mocks.VerifyAll(); + } } } \ No newline at end of file