Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionBaseTreeNodeInfoTest.cs =================================================================== diff -u -rb79e419a1fcdf3d80760ea4bc35ac354525911d2 -r3434a272cc8bfb25dae4bd7bd50afedb377343c0 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionBaseTreeNodeInfoTest.cs (.../AssessmentSectionBaseTreeNodeInfoTest.cs) (revision b79e419a1fcdf3d80760ea4bc35ac354525911d2) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionBaseTreeNodeInfoTest.cs (.../AssessmentSectionBaseTreeNodeInfoTest.cs) (revision 3434a272cc8bfb25dae4bd7bd50afedb377343c0) @@ -11,6 +11,7 @@ using Ringtoets.Common.Data; using Ringtoets.Common.Data.Contribution; using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Data.Placeholders; using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Plugin; @@ -33,7 +34,7 @@ { mocks = new MockRepository(); plugin = new RingtoetsGuiPlugin(); - info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(AssessmentSectionBase)); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(IAssessmentSection)); } [TearDown] @@ -46,7 +47,7 @@ public void Initialized_Always_ExpectedPropertiesSet() { // Assert - Assert.AreEqual(typeof(AssessmentSectionBase), info.TagType); + Assert.AreEqual(typeof(IAssessmentSection), info.TagType); Assert.IsNull(info.ForeColor); Assert.IsNull(info.CanCheck); Assert.IsNull(info.IsChecked); @@ -61,8 +62,9 @@ public void Text_Always_ReturnsName() { // Setup - var assessmentSection = mocks.StrictMock(); var testName = "ttt"; + + var assessmentSection = mocks.Stub(); assessmentSection.Name = testName; mocks.ReplayAll(); @@ -80,7 +82,7 @@ public void Image_Always_ReturnsSetImage() { // Setup - var assessmentSection = mocks.StrictMock(); + var assessmentSection = mocks.StrictMock(); mocks.ReplayAll(); @@ -97,7 +99,7 @@ public void EnsureVisibleOnCreate_Always_ReturnsTrue() { // Setup - var assessmentSection = mocks.StrictMock(); + var assessmentSection = mocks.StrictMock(); mocks.ReplayAll(); @@ -114,14 +116,19 @@ public void ChildNodeObjects_Always_ReturnsChildsOnData() { // Setup - var failureMechanismList = new List + var failureMechanisms = new IFailureMechanism[] { new PipingFailureMechanism(), new FailureMechanismPlaceholder("A") }; - var contribution = new FailureMechanismContribution(failureMechanismList, 10.0, 2); - var assessmentSection = new TestAssessmentSectionBase(contribution, failureMechanismList); + var contribution = new FailureMechanismContribution(failureMechanisms, 10.0, 2); + var assessmentSection = mocks.Stub(); + assessmentSection.Stub(section => section.FailureMechanismContribution).Return(contribution); + assessmentSection.Stub(section => section.GetFailureMechanisms()).Return(failureMechanisms); + mocks.ReplayAll(); + + // Call var objects = info.ChildNodeObjects(assessmentSection).ToArray(); @@ -138,11 +145,11 @@ Assert.AreSame(assessmentSection, context.Parent); var pipingFailureMechanismContext = (PipingFailureMechanismContext)objects[3]; - Assert.AreSame(failureMechanismList[0], pipingFailureMechanismContext.WrappedData); + Assert.AreSame(failureMechanisms[0], pipingFailureMechanismContext.WrappedData); Assert.AreSame(assessmentSection, pipingFailureMechanismContext.Parent); var placeholderFailureMechanismContext = (FailureMechanismPlaceholderContext)objects[4]; - Assert.AreSame(failureMechanismList[1], placeholderFailureMechanismContext.WrappedData); + Assert.AreSame(failureMechanisms[1], placeholderFailureMechanismContext.WrappedData); Assert.AreSame(assessmentSection, placeholderFailureMechanismContext.Parent); mocks.VerifyAll(); @@ -196,15 +203,11 @@ public void OnNodeRenamed_WithData_SetProjectNameWithNotification() { // Setup - var assessmentSectionObserver = mocks.StrictMock(); - var assessmentSection = mocks.Stub(); - - assessmentSectionObserver.Expect(o => o.UpdateObserver()); - + var assessmentSection = mocks.Stub(); + assessmentSection.Expect(section => section.NotifyObservers()); + mocks.ReplayAll(); - assessmentSection.Attach(assessmentSectionObserver); - // Call const string newName = "New Name"; info.OnNodeRenamed(assessmentSection, newName); @@ -229,7 +232,7 @@ { // Setup var observerMock = mocks.StrictMock(); - var assessmentSection = mocks.Stub(); + var assessmentSection = mocks.Stub(); observerMock.Expect(o => o.UpdateObserver()); @@ -248,20 +251,4 @@ mocks.VerifyAll(); } } - - public class TestAssessmentSectionBase : AssessmentSectionBase - { - private readonly IEnumerable failureMechanisms; - - public TestAssessmentSectionBase(FailureMechanismContribution contribution, IEnumerable failureMechanisms) - { - FailureMechanismContribution = contribution; - this.failureMechanisms = failureMechanisms; - } - - public override IEnumerable GetFailureMechanisms() - { - return failureMechanisms; - } - } } \ No newline at end of file