Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismSectionsContext.cs =================================================================== diff -u -r63fbdd5525927fbf9d63925eef9da8e17a0d7b44 -rfac9694977a32d8ce6ae3c1e994b3a13b8aa48fe --- Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismSectionsContext.cs (.../FailureMechanismSectionsContext.cs) (revision 63fbdd5525927fbf9d63925eef9da8e17a0d7b44) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismSectionsContext.cs (.../FailureMechanismSectionsContext.cs) (revision fac9694977a32d8ce6ae3c1e994b3a13b8aa48fe) @@ -20,8 +20,7 @@ // All rights reserved. using System; -using System.Collections.Generic; -using Core.Common.Base; +using Core.Common.Controls.PresentationObjects; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; @@ -30,99 +29,28 @@ /// /// This class is a presentation object for . /// - public class FailureMechanismSectionsContext : IObservable + public class FailureMechanismSectionsContext : ObservableWrappedObjectContextBase { /// /// Initializes a new instance of the class. /// - /// The failure mechanism whose sections to wrap. - /// The owning assessment section of . + /// The failure mechanism to wrap. + /// The owning assessment section of . /// When any input argument is null. - public FailureMechanismSectionsContext(IFailureMechanism failureMechanism, IAssessmentSection assessmentSection) + public FailureMechanismSectionsContext(IFailureMechanism wrappedFailureMechanism, IAssessmentSection assessmentSection) + : base(wrappedFailureMechanism) { - if (failureMechanism == null) - { - throw new ArgumentNullException("failureMechanism"); - } if (assessmentSection == null) { throw new ArgumentNullException("assessmentSection"); } - ParentFailureMechanism = failureMechanism; ParentAssessmentSection = assessmentSection; } /// - /// Gets the sequence of instances available - /// on the wrapped failure mechanism. + /// Gets the assessment section which the context belongs to. /// - public IEnumerable WrappedData - { - get - { - return ParentFailureMechanism.Sections; - } - } - - /// - /// Gets failure mechanism that owns the sequence exposed by . - /// - public IFailureMechanism ParentFailureMechanism { get; private set; } - - /// - /// Gets the assessment section that owns . - /// public IAssessmentSection ParentAssessmentSection { get; private set; } - - #region IObservable - - public void Attach(IObserver observer) - { - ParentFailureMechanism.Attach(observer); - } - - public void Detach(IObserver observer) - { - ParentFailureMechanism.Detach(observer); - } - - public void NotifyObservers() - { - ParentFailureMechanism.NotifyObservers(); - } - - #endregion - - #region Equatable - - private bool Equals(FailureMechanismSectionsContext other) - { - return Equals(ParentFailureMechanism, other.ParentFailureMechanism); - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) - { - return false; - } - if (ReferenceEquals(this, obj)) - { - return true; - } - if (obj.GetType() != GetType()) - { - return false; - } - return Equals((FailureMechanismSectionsContext) obj); - } - - public override int GetHashCode() - { - return ParentFailureMechanism.GetHashCode(); - } - - #endregion } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/FailureMechanismSectionsContextTest.cs =================================================================== diff -u -r507e30ebf13ba63fcedbe9a5b8457f302da26429 -rfac9694977a32d8ce6ae3c1e994b3a13b8aa48fe --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/FailureMechanismSectionsContextTest.cs (.../FailureMechanismSectionsContextTest.cs) (revision 507e30ebf13ba63fcedbe9a5b8457f302da26429) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/FailureMechanismSectionsContextTest.cs (.../FailureMechanismSectionsContextTest.cs) (revision fac9694977a32d8ce6ae3c1e994b3a13b8aa48fe) @@ -21,12 +21,9 @@ using System; using System.Collections.Generic; - -using Core.Common.Base; using Core.Common.Base.Geometry; - +using Core.Common.Controls.PresentationObjects; using NUnit.Framework; - using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; @@ -66,30 +63,13 @@ var context = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); // Assert - Assert.IsInstanceOf(context); - Assert.AreSame(sectionsSequence, context.WrappedData); - Assert.AreSame(failureMechanism, context.ParentFailureMechanism); + Assert.IsInstanceOf>(context); + Assert.AreSame(failureMechanism, context.WrappedData); Assert.AreSame(assessmentSection, context.ParentAssessmentSection); mocks.VerifyAll(); } [Test] - public void Constructor_FailureMechanismNull_ThrowArgumentNullException() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); - - // Call - TestDelegate call = () => new FailureMechanismSectionsContext(null, assessmentSection); - - // Assert - Assert.Throws(call); - mocks.VerifyAll(); - } - - [Test] public void Constructor_AssessmentSectionNull_ThrowArgumentNullException() { // Setup @@ -104,179 +84,5 @@ Assert.Throws(call); mocks.VerifyAll(); } - - [Test] - public void Attach_Observer_ObserverAttachedToFailureMechanism() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.StrictMock(); - var failureMechanism = mocks.StrictMock(); - var observer = mocks.StrictMock(); - - failureMechanism.Expect(fm => fm.Attach(observer)); - - mocks.ReplayAll(); - - var context = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); - - // Call - context.Attach(observer); - - // Assert - mocks.VerifyAll(); // Expected Attach on wrapped object - } - - [Test] - public void Detach_Observer_ObserverDetachedFromFailureMechanism() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.StrictMock(); - var failureMechanism = mocks.StrictMock(); - var observer = mocks.StrictMock(); - - failureMechanism.Expect(fm => fm.Detach(observer)); - - mocks.ReplayAll(); - - var context = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); - - // Call - context.Detach(observer); - - // Assert - mocks.VerifyAll(); // Expected Detach on wrapped object - } - - [Test] - public void NotifyObservers_ObserverAttachedToFailureMechanism_NotificationCorrectlyPropagated() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.StrictMock(); - var failureMechanism = mocks.StrictMock(); - - failureMechanism.Expect(fm => fm.NotifyObservers()); - - mocks.ReplayAll(); - - var context = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); - - // Call - context.NotifyObservers(); - - // Assert - mocks.VerifyAll(); // Expected NotifyObservers on wrapped object - } - - [Test] - public void Equals_ToItself_ReturnTrue() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.StrictMock(); - var failureMechanism = mocks.Stub(); - mocks.ReplayAll(); - - var context = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); - - // Call - bool isEqual = context.Equals(context); - - // Assert - Assert.IsTrue(isEqual); - mocks.VerifyAll(); - } - - [Test] - public void Equals_ToNull_ReturnFalse() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.StrictMock(); - var failureMechanism = mocks.Stub(); - mocks.ReplayAll(); - - var context = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); - - // Call - bool isEqual = context.Equals(null); - - // Assert - Assert.IsFalse(isEqual); - mocks.VerifyAll(); - } - - [Test] - public void Equals_ToEqualOtherInstance_ReturnTrue() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.StrictMock(); - var failureMechanism = mocks.Stub(); - mocks.ReplayAll(); - - var context = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); - - var otherContext = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); - - // Call - bool isEqual = context.Equals(otherContext); - bool isEqual2 = otherContext.Equals(context); - - // Assert - Assert.IsTrue(isEqual); - Assert.IsTrue(isEqual2); - mocks.VerifyAll(); - } - - [Test] - public void Equals_ToInequalOtherInstance_ReturnFalse() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.StrictMock(); - var failureMechanism = mocks.Stub(); - var otherFailureMechanism = mocks.Stub(); - mocks.ReplayAll(); - - var context = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); - - var otherContext = new FailureMechanismSectionsContext(otherFailureMechanism, assessmentSection); - - // Call - bool isEqual = context.Equals(otherContext); - bool isEqual2 = otherContext.Equals(context); - - // Assert - Assert.IsFalse(isEqual); - Assert.IsFalse(isEqual2); - mocks.VerifyAll(); - } - - [Test] - public void GetHashCode_TwoContextInstancesEqualToEachOther_ReturnIdenticalHashes() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.StrictMock(); - var failureMechanism = mocks.Stub(); - mocks.ReplayAll(); - - var context = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); - - var otherContext = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); - // Precondition - Assert.True(context.Equals(otherContext)); - - // Call - int contextHashCode = context.GetHashCode(); - int otherContextHashCode = otherContext.GetHashCode(); - - // Assert - Assert.AreEqual(contextHashCode, otherContextHashCode); - mocks.VerifyAll(); - } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r14185c4e29bcfc887fa656a681bdde704d250a9f -rfac9694977a32d8ce6ae3c1e994b3a13b8aa48fe --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision 14185c4e29bcfc887fa656a681bdde704d250a9f) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision fac9694977a32d8ce6ae3c1e994b3a13b8aa48fe) @@ -112,8 +112,7 @@ Assert.AreEqual(TreeFolderCategory.Input, inputsFolder.Category); Assert.AreEqual(2, inputsFolder.Contents.Count); var failureMechanismSectionsContext = (FailureMechanismSectionsContext) inputsFolder.Contents[0]; - CollectionAssert.AreEqual(failureMechanism.Sections, failureMechanismSectionsContext.WrappedData); - Assert.AreSame(failureMechanism, failureMechanismSectionsContext.ParentFailureMechanism); + Assert.AreSame(failureMechanism, failureMechanismSectionsContext.WrappedData); Assert.AreSame(assessmentSectionMock, failureMechanismSectionsContext.ParentAssessmentSection); var commentContext = (CommentContext) inputsFolder.Contents[1]; Assert.AreSame(failureMechanism, commentContext.WrappedData); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r14185c4e29bcfc887fa656a681bdde704d250a9f -rfac9694977a32d8ce6ae3c1e994b3a13b8aa48fe --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 14185c4e29bcfc887fa656a681bdde704d250a9f) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision fac9694977a32d8ce6ae3c1e994b3a13b8aa48fe) @@ -112,8 +112,7 @@ Assert.AreEqual(TreeFolderCategory.Input, inputsFolder.Category); Assert.AreEqual(2, inputsFolder.Contents.Count); var failureMechanismSectionsContext = (FailureMechanismSectionsContext) inputsFolder.Contents[0]; - CollectionAssert.AreEqual(failureMechanism.Sections, failureMechanismSectionsContext.WrappedData); - Assert.AreSame(failureMechanism, failureMechanismSectionsContext.ParentFailureMechanism); + Assert.AreSame(failureMechanism, failureMechanismSectionsContext.WrappedData); Assert.AreSame(assessmentSectionMock, failureMechanismSectionsContext.ParentAssessmentSection); var commentContext = (CommentContext) inputsFolder.Contents[1]; Assert.AreSame(failureMechanism, commentContext.WrappedData); Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/FailureMechanismSectionsImporter.cs =================================================================== diff -u -rbbe2a3488b33585ad13bebdaa7439f5c5bbfe079 -rfac9694977a32d8ce6ae3c1e994b3a13b8aa48fe --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/FailureMechanismSectionsImporter.cs (.../FailureMechanismSectionsImporter.cs) (revision bbe2a3488b33585ad13bebdaa7439f5c5bbfe079) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/FailureMechanismSectionsImporter.cs (.../FailureMechanismSectionsImporter.cs) (revision fac9694977a32d8ce6ae3c1e994b3a13b8aa48fe) @@ -122,7 +122,7 @@ } NotifyProgress(Resources.FailureMechanismSectionsImporter_ProgressText_Adding_imported_data_to_failureMechanism, 3, 3); - AddImportedDataToModel(readFailureMechanismSections, context.ParentFailureMechanism, referenceLine); + AddImportedDataToModel(readFailureMechanismSections, context.WrappedData, referenceLine); return true; } Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs =================================================================== diff -u -r63fbdd5525927fbf9d63925eef9da8e17a0d7b44 -rfac9694977a32d8ce6ae3c1e994b3a13b8aa48fe --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 63fbdd5525927fbf9d63925eef9da8e17a0d7b44) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision fac9694977a32d8ce6ae3c1e994b3a13b8aa48fe) @@ -249,7 +249,7 @@ { Text = context => RingtoetsCommonFormsResources.FailureMechanism_Sections_DisplayName, Image = context => RingtoetsCommonFormsResources.Sections, - ForeColor = context => context.WrappedData.Any() ? + ForeColor = context => context.WrappedData.Sections.Any() ? Color.FromKnownColor(KnownColor.ControlText) : Color.FromKnownColor(KnownColor.GrayText), ContextMenuStrip = FailureMechanismSectionsContextMenuStrip Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r14185c4e29bcfc887fa656a681bdde704d250a9f -rfac9694977a32d8ce6ae3c1e994b3a13b8aa48fe --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs (.../FailureMechanismContextTreeNodeInfoTest.cs) (revision 14185c4e29bcfc887fa656a681bdde704d250a9f) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContextTreeNodeInfoTest.cs (.../FailureMechanismContextTreeNodeInfoTest.cs) (revision fac9694977a32d8ce6ae3c1e994b3a13b8aa48fe) @@ -169,8 +169,7 @@ Assert.AreEqual(TreeFolderCategory.Input, inputFolder.Category); var failureMechanismSectionsContext = (FailureMechanismSectionsContext) inputFolder.Contents[0]; - CollectionAssert.AreEqual(failureMechanism.Sections, failureMechanismSectionsContext.WrappedData); - Assert.AreSame(failureMechanism, failureMechanismSectionsContext.ParentFailureMechanism); + Assert.AreSame(failureMechanism, failureMechanismSectionsContext.WrappedData); Assert.AreSame(assessmentSection, failureMechanismSectionsContext.ParentAssessmentSection); var commentContext = (CommentContext) inputFolder.Contents[1]; Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileImporters/FailureMechanismSectionsImporterTest.cs =================================================================== diff -u -r41fac7fff0a505c08945108d795dcb877f10b816 -rfac9694977a32d8ce6ae3c1e994b3a13b8aa48fe --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileImporters/FailureMechanismSectionsImporterTest.cs (.../FailureMechanismSectionsImporterTest.cs) (revision 41fac7fff0a505c08945108d795dcb877f10b816) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileImporters/FailureMechanismSectionsImporterTest.cs (.../FailureMechanismSectionsImporterTest.cs) (revision fac9694977a32d8ce6ae3c1e994b3a13b8aa48fe) @@ -236,7 +236,7 @@ { new ProgressNotification("Inlezen vakindeling.", 1, 3), new ProgressNotification("Valideren ingelezen vakindeling.", 2, 3), - new ProgressNotification("Geïmporteerde data toevoegen aan het toetsspoor.", 3, 3), + new ProgressNotification("Geïmporteerde data toevoegen aan het toetsspoor.", 3, 3) }; Assert.AreEqual(expectedProgressMessages.Length, progressChangeNotifications.Count); for (int i = 0; i < expectedProgressMessages.Length; i++) @@ -281,7 +281,6 @@ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); Assert.IsFalse(importSuccessful); CollectionAssert.IsEmpty(failureMechanism.Sections); - CollectionAssert.IsEmpty(failureMechanismSectionsContext.WrappedData); mocks.VerifyAll(); } @@ -316,7 +315,6 @@ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); Assert.IsFalse(importSuccessful); CollectionAssert.IsEmpty(failureMechanism.Sections); - CollectionAssert.IsEmpty(failureMechanismSectionsContext.WrappedData); mocks.VerifyAll(); } @@ -346,7 +344,6 @@ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); Assert.IsFalse(importSuccessful); CollectionAssert.IsEmpty(failureMechanism.Sections); - CollectionAssert.IsEmpty(failureMechanismSectionsContext.WrappedData); mocks.VerifyAll(); } @@ -381,7 +378,6 @@ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); Assert.IsFalse(importSuccessful); CollectionAssert.IsEmpty(failureMechanism.Sections); - CollectionAssert.IsEmpty(failureMechanismSectionsContext.WrappedData); mocks.VerifyAll(); } @@ -419,7 +415,6 @@ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); Assert.IsFalse(importSuccessful); CollectionAssert.IsEmpty(failureMechanism.Sections); - CollectionAssert.IsEmpty(failureMechanismSectionsContext.WrappedData); mocks.VerifyAll(); } @@ -457,7 +452,6 @@ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); Assert.IsFalse(importSuccessful); CollectionAssert.IsEmpty(failureMechanism.Sections); - CollectionAssert.IsEmpty(failureMechanismSectionsContext.WrappedData); mocks.VerifyAll(); } @@ -492,7 +486,6 @@ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); Assert.IsFalse(importSuccessful); CollectionAssert.IsEmpty(failureMechanism.Sections); - CollectionAssert.IsEmpty(failureMechanismSectionsContext.WrappedData); mocks.VerifyAll(); } @@ -527,7 +520,6 @@ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); Assert.IsFalse(importSuccessful); CollectionAssert.IsEmpty(failureMechanism.Sections); - CollectionAssert.IsEmpty(failureMechanismSectionsContext.WrappedData); mocks.VerifyAll(); } Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r63fbdd5525927fbf9d63925eef9da8e17a0d7b44 -rfac9694977a32d8ce6ae3c1e994b3a13b8aa48fe --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingFailureMechanismContextTreeNodeInfoTest.cs (.../PipingFailureMechanismContextTreeNodeInfoTest.cs) (revision 63fbdd5525927fbf9d63925eef9da8e17a0d7b44) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingFailureMechanismContextTreeNodeInfoTest.cs (.../PipingFailureMechanismContextTreeNodeInfoTest.cs) (revision fac9694977a32d8ce6ae3c1e994b3a13b8aa48fe) @@ -140,8 +140,7 @@ Assert.AreEqual(4, inputsFolder.Contents.Count); var failureMechanismSectionsContext = (FailureMechanismSectionsContext) inputsFolder.Contents[0]; - CollectionAssert.AreEqual(pipingFailureMechanism.Sections, failureMechanismSectionsContext.WrappedData); - Assert.AreSame(pipingFailureMechanism, failureMechanismSectionsContext.ParentFailureMechanism); + Assert.AreSame(pipingFailureMechanism, failureMechanismSectionsContext.WrappedData); Assert.AreSame(assessmentSection, failureMechanismSectionsContext.ParentAssessmentSection); var surfaceLinesContext = (RingtoetsPipingSurfaceLinesContext) inputsFolder.Contents[1];