Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsFailureMechanismTest.cs =================================================================== diff -u -r006d96ecb9e7d838d7682912270c7d43e0ad67e1 -r5546343f650bb277b3c1937f1abf3ee0b7a7dc89 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsFailureMechanismTest.cs (.../GrassCoverErosionInwardsFailureMechanismTest.cs) (revision 006d96ecb9e7d838d7682912270c7d43e0ad67e1) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsFailureMechanismTest.cs (.../GrassCoverErosionInwardsFailureMechanismTest.cs) (revision 5546343f650bb277b3c1937f1abf3ee0b7a7dc89) @@ -20,6 +20,8 @@ // All rights reserved. using System.Linq; + +using Core.Common.Base; using Core.Common.Base.Geometry; using NUnit.Framework; using Rhino.Mocks; @@ -41,12 +43,18 @@ // assert Assert.IsInstanceOf(failureMechanism); Assert.IsInstanceOf(failureMechanism); + Assert.AreEqual(Resources.GrassCoverErosionInwardsFailureMechanism_DisplayName, failureMechanism.Name); Assert.AreEqual(Resources.GrassCoverErosionInwardsFailureMechanism_DisplayCode, failureMechanism.Code); - CollectionAssert.IsEmpty(failureMechanism.Calculations); + Assert.IsInstanceOf(failureMechanism.GeneralInput); + + CollectionAssert.IsEmpty(failureMechanism.Calculations); Assert.AreEqual("Berekeningen", failureMechanism.CalculationsGroup.Name); Assert.IsEmpty(failureMechanism.CalculationsGroup.Children); + + Assert.IsInstanceOf>(failureMechanism.DikeProfiles); + CollectionAssert.IsEmpty(failureMechanism.DikeProfiles); } [Test] @@ -122,5 +130,50 @@ Assert.IsTrue(calculations.All(c => c is GrassCoverErosionInwardsCalculation)); mocks.VerifyAll(); } + + [Test] + public void GivenFailureMechanismWithDikeProfiles_WhenAddingAndRemovingElements_ThenCollectionIsUpdated() + { + // Scenario + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var dikeProfile1 = new DikeProfile(new Point2D(0, 0)); + var dikeProfile2 = new DikeProfile(new Point2D(1, 1)); + var dikeProfile3 = new DikeProfile(new Point2D(2, 2)); + + failureMechanism.DikeProfiles.Add(dikeProfile1); + + // Event + failureMechanism.DikeProfiles.Add(dikeProfile2); + failureMechanism.DikeProfiles.Insert(0, dikeProfile3); + failureMechanism.DikeProfiles.Remove(dikeProfile1); + + // Result + var expectedDikeProfiles = new[] + { + dikeProfile3, + dikeProfile2 + }; + CollectionAssert.AreEqual(expectedDikeProfiles, failureMechanism.DikeProfiles); + } + + [Test] + public void GivenObserverAttachedToDikeProfiles_WhenNotifyObservers_ThenObserverIsNotified() + { + // Scenario + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + failureMechanism.DikeProfiles.Attach(observer); + + // Event + failureMechanism.DikeProfiles.NotifyObservers(); + + // Result + mocks.VerifyAll(); // Expect observer to be notified. + } } } \ No newline at end of file