Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsContextTest.cs =================================================================== diff -u -r4539b4546747c257739b1695b9ebc9c29e393ffe -r29fc3cf43f0885270cca5b57c8bf17e347ae9609 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsContextTest.cs (.../GrassCoverErosionInwardsContextTest.cs) (revision 4539b4546747c257739b1695b9ebc9c29e393ffe) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsContextTest.cs (.../GrassCoverErosionInwardsContextTest.cs) (revision 29fc3cf43f0885270cca5b57c8bf17e347ae9609) @@ -22,6 +22,7 @@ using System; using System.Linq; using Core.Common.Base; +using Core.Common.Controls.PresentationObjects; using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; @@ -58,7 +59,7 @@ var context = new SimpleGrassCoverErosionInwardsContext(target, failureMechanismMock, assessmentSectionMock); // Assert - Assert.IsInstanceOf(context); + Assert.IsInstanceOf>(context); Assert.AreSame(target, context.WrappedData); Assert.AreSame(assessmentSectionMock, context.AssessmentSection); Assert.AreSame(failureMechanismMock, context.FailureMechanism); @@ -67,29 +68,6 @@ } [Test] - public void ParameteredConstructor_DataIsNull_ThrowArgumentNullException() - { - // Setup - var assessmentSectionMock = mockRepository.StrictMock(); - var failureMechanismMock = mockRepository.StrictMock(); - mockRepository.ReplayAll(); - - // Call - TestDelegate call = () => new SimpleGrassCoverErosionInwardsContext(null, - failureMechanismMock, - assessmentSectionMock); - - // Assert - var exception = Assert.Throws(call); - string customMessage = exception.Message.Split(new[] - { - Environment.NewLine - }, StringSplitOptions.None)[0]; - Assert.AreEqual("Wrapped data of context cannot be null.", customMessage); - mockRepository.VerifyAll(); - } - - [Test] public void ParameteredConstructor_FailureMechanismIsNull_ThrowArgumentNullException() { // Setup @@ -146,234 +124,6 @@ mockRepository.VerifyAll(); } - [Test] - public void Attach_Observer_ObserverAttachedToWrappedObject() - { - // Setup - var assessmentSectionMock = mockRepository.StrictMock(); - var failureMechanismMock = mockRepository.StrictMock(); - var observerMock = mockRepository.StrictMock(); - observerMock.Expect(o => o.UpdateObserver()); - mockRepository.ReplayAll(); - - var observableObject = new ObservableObject(); - - var context = new SimpleGrassCoverErosionInwardsContext(observableObject, - failureMechanismMock, - assessmentSectionMock); - - // Call - context.Attach(observerMock); - - // Assert - observableObject.NotifyObservers(); // Notification on wrapped object - mockRepository.VerifyAll(); // Expected UpdateObserver call - } - - [Test] - public void Detach_Observer_ObserverDetachedFromWrappedObject() - { - // Setup - var assessmentSectionMock = mockRepository.StrictMock(); - var failureMechanismMock = mockRepository.StrictMock(); - var observerMock = mockRepository.StrictMock(); - mockRepository.ReplayAll(); - - var observableObject = new ObservableObject(); - - var context = new SimpleGrassCoverErosionInwardsContext(observableObject, - failureMechanismMock, - assessmentSectionMock); - // Precondition - context.Attach(observerMock); - - // Call - context.Detach(observerMock); - - // Assert - observableObject.NotifyObservers(); // Notification on wrapped object - mockRepository.VerifyAll(); // Expected no UpdateObserver call - } - - [Test] - public void NotifyObservers_ObserverAttachedToWrappedObject_NotificationCorrectlyPropagated() - { - // Setup - var assessmentSectionMock = mockRepository.StrictMock(); - var failureMechanismMock = mockRepository.StrictMock(); - var observerMock = mockRepository.StrictMock(); - observerMock.Expect(o => o.UpdateObserver()); - mockRepository.ReplayAll(); - - var observableObject = new ObservableObject(); - - var context = new SimpleGrassCoverErosionInwardsContext(observableObject, - failureMechanismMock, - assessmentSectionMock); - - // Precondition - observableObject.Attach(observerMock); // Attach to wrapped object - - // Call - context.NotifyObservers(); // Notification on context - - // Assert - mockRepository.VerifyAll(); - } - - [Test] - public void Equals_ToItself_ReturnTrue() - { - // Setup - var assessmentSectionMock = mockRepository.StrictMock(); - var failureMechanismMock = mockRepository.StrictMock(); - mockRepository.ReplayAll(); - - var observableObject = new ObservableObject(); - var context = new SimpleGrassCoverErosionInwardsContext(observableObject, - failureMechanismMock, - assessmentSectionMock); - - // Call - bool isEqual = context.Equals(context); - - // Assert - Assert.IsTrue(isEqual); - mockRepository.VerifyAll(); - } - - [Test] - public void Equals_ToNull_ReturnFalse() - { - // Setup - var assessmentSectionMock = mockRepository.StrictMock(); - var failureMechanismMock = mockRepository.StrictMock(); - mockRepository.ReplayAll(); - - var observableObject = new ObservableObject(); - var context = new SimpleGrassCoverErosionInwardsContext(observableObject, - failureMechanismMock, - assessmentSectionMock); - - // Call - bool isEqual = context.Equals(null); - - // Assert - Assert.IsFalse(isEqual); - mockRepository.VerifyAll(); - } - - [Test] - public void Equals_ToEqualOtherInstance_ReturnTrue() - { - // Setup - var assessmentSectionMock = mockRepository.StrictMock(); - var failureMechanismMock = mockRepository.StrictMock(); - mockRepository.ReplayAll(); - - var observableObject = new ObservableObject(); - var context = new SimpleGrassCoverErosionInwardsContext(observableObject, - failureMechanismMock, - assessmentSectionMock); - - var otherContext = new SimpleGrassCoverErosionInwardsContext(observableObject, - failureMechanismMock, - assessmentSectionMock); - - // Call - bool isEqual = context.Equals(otherContext); - bool isEqual2 = otherContext.Equals(context); - - // Assert - Assert.IsTrue(isEqual); - Assert.IsTrue(isEqual2); - mockRepository.VerifyAll(); - } - - [Test] - public void Equals_ToInequalOtherInstance_ReturnFalse() - { - // Setup - var assessmentSectionMock = mockRepository.StrictMock(); - var failureMechanismMock = mockRepository.StrictMock(); - mockRepository.ReplayAll(); - - var observableObject = new ObservableObject(); - var otherObservableObject = new ObservableObject(); - var context = new SimpleGrassCoverErosionInwardsContext(observableObject, - failureMechanismMock, - assessmentSectionMock); - - var otherContext = new SimpleGrassCoverErosionInwardsContext(otherObservableObject, - failureMechanismMock, - assessmentSectionMock); - - // Call - bool isEqual = context.Equals(otherContext); - bool isEqual2 = otherContext.Equals(context); - - // Assert - Assert.IsFalse(isEqual); - Assert.IsFalse(isEqual2); - mockRepository.VerifyAll(); - } - - [Test] - public void Equals_ToOtherGenericType_ReturnFalse() - { - // Setup - var assessmentSectionMock = mockRepository.StrictMock(); - var failureMechanismMock = mockRepository.StrictMock(); - var observableStub = mockRepository.Stub(); - mockRepository.ReplayAll(); - - var observableObject = new ObservableObject(); - var context = new SimpleGrassCoverErosionInwardsContext(observableObject, - failureMechanismMock, - assessmentSectionMock); - - var otherContext = new SimpleGrassCoverErosionInwardsContext(observableStub, - failureMechanismMock, - assessmentSectionMock); - - // Call - bool isEqual = context.Equals(otherContext); - bool isEqual2 = otherContext.Equals(context); - - // Assert - Assert.IsFalse(isEqual); - Assert.IsFalse(isEqual2); - mockRepository.VerifyAll(); - } - - [Test] - public void GetHashCode_TwoContextInstancesEqualToEachOther_ReturnIdenticalHashes() - { - // Setup - var assessmentSectionMock = mockRepository.StrictMock(); - var failureMechanismMock = mockRepository.StrictMock(); - mockRepository.ReplayAll(); - - var observableObject = new ObservableObject(); - var context = new SimpleGrassCoverErosionInwardsContext(observableObject, - failureMechanismMock, - assessmentSectionMock); - - var otherContext = new SimpleGrassCoverErosionInwardsContext(observableObject, - failureMechanismMock, - assessmentSectionMock); - // Precondition - Assert.True(context.Equals(otherContext)); - - // Call - int contextHashCode = context.GetHashCode(); - int otherContextHashCode = otherContext.GetHashCode(); - - // Assert - Assert.AreEqual(contextHashCode, otherContextHashCode); - mockRepository.VerifyAll(); - } - private class ObservableObject : Observable {} private class SimpleGrassCoverErosionInwardsContext : GrassCoverErosionInwardsContext where T : IObservable Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r00f13c6362323400cc61fa99d6b197b7085088e3 -r29fc3cf43f0885270cca5b57c8bf17e347ae9609 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 00f13c6362323400cc61fa99d6b197b7085088e3) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 29fc3cf43f0885270cca5b57c8bf17e347ae9609) @@ -22,7 +22,7 @@ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - public class Resources { + internal class Resources { private static global::System.Resources.ResourceManager resourceMan; @@ -36,7 +36,7 @@ /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { + internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Ringtoets.HeightStructures.Forms.Properties.Resources", typeof(Resources).Assembly); @@ -51,7 +51,7 @@ /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { + internal static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -63,7 +63,7 @@ /// /// Looks up a localized string similar to {0} mag niet 'null' zijn.. /// - public static string HeightStructuresContext_AssertInputsAreNotNull_DataDescription_0_cannot_be_null { + internal static string HeightStructuresContext_AssertInputsAreNotNull_DataDescription_0_cannot_be_null { get { return ResourceManager.GetString("HeightStructuresContext_AssertInputsAreNotNull_DataDescription_0_cannot_be_null", resourceCulture); } @@ -72,7 +72,7 @@ /// /// Looks up a localized string similar to Het traject. /// - public static string HeightStructuresContext_DataDescription_AssessmentSection { + internal static string HeightStructuresContext_DataDescription_AssessmentSection { get { return ResourceManager.GetString("HeightStructuresContext_DataDescription_AssessmentSection", resourceCulture); } @@ -81,7 +81,7 @@ /// /// Looks up a localized string similar to Het hoogte kunstwerk toetsspoor. /// - public static string HeightStructuresContext_DataDescription_HeightStructuresFailureMechanism { + internal static string HeightStructuresContext_DataDescription_HeightStructuresFailureMechanism { get { return ResourceManager.GetString("HeightStructuresContext_DataDescription_HeightStructuresFailureMechanism", resourceCulture); } Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj =================================================================== diff -u -r00f13c6362323400cc61fa99d6b197b7085088e3 -r29fc3cf43f0885270cca5b57c8bf17e347ae9609 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj (.../Ringtoets.HeightStructures.Forms.csproj) (revision 00f13c6362323400cc61fa99d6b197b7085088e3) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj (.../Ringtoets.HeightStructures.Forms.csproj) (revision 29fc3cf43f0885270cca5b57c8bf17e347ae9609) @@ -86,7 +86,7 @@ - PublicResXFileCodeGenerator + ResXFileCodeGenerator Resources.Designer.cs Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresContextTest.cs =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresContextTest.cs (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresContextTest.cs (revision 29fc3cf43f0885270cca5b57c8bf17e347ae9609) @@ -0,0 +1,108 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base; +using Core.Common.Controls.PresentationObjects; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.HeightStructures.Data; +using Ringtoets.HeightStructures.Forms.PresentationObjects; + +namespace Ringtoets.HeightStructures.Forms.Test.PresentationObjects +{ + [TestFixture] + public class HeightStructuresContextTest + { + private MockRepository mockRepository; + + [SetUp] + public void SetUp() + { + mockRepository = new MockRepository(); + } + + [Test] + public void ParameteredConstructor_ExpectedValues() + { + // Setup + var assessmentSectionMock = mockRepository.StrictMock(); + var failureMechanismMock = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + + var target = new ObservableObject(); + + // Call + var context = new SimpleHeightStructuresContext(target, failureMechanismMock, assessmentSectionMock); + + // Assert + Assert.IsInstanceOf>(context); + Assert.AreSame(target, context.WrappedData); + Assert.AreSame(assessmentSectionMock, context.AssessmentSection); + Assert.AreSame(failureMechanismMock, context.FailureMechanism); + mockRepository.VerifyAll(); + } + + [Test] + public void ParameteredConstructor_FailureMechanismIsNull_ThrowArgumentNullException() + { + // Setup + var assessmentSectionMock = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + + var observableObject = new ObservableObject(); + + // Call + TestDelegate call = () => new SimpleHeightStructuresContext(observableObject, null, assessmentSectionMock); + + // Assert + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Het hoogte kunstwerk toetsspoor mag niet 'null' zijn."); + mockRepository.VerifyAll(); + } + + [Test] + public void ParameteredConstructor_AssessmentSectionIsNull_ThrowArgumentNullException() + { + // Setup + var failureMechanismMock = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + + var observableObject = new ObservableObject(); + + // Call + TestDelegate call = () => new SimpleHeightStructuresContext(observableObject, failureMechanismMock, null); + + // Assert + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Het traject mag niet 'null' zijn."); + mockRepository.VerifyAll(); + } + + private class ObservableObject : Observable { } + + private class SimpleHeightStructuresContext : HeightStructuresContext where T : IObservable + { + public SimpleHeightStructuresContext(T target, HeightStructuresFailureMechanism failureMechanism, IAssessmentSection assessmentSection) + : base(target, failureMechanism, assessmentSection) {} + } + } +} Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj =================================================================== diff -u -r213b20e92891887167ab4b031ca4a4b6250a4c2a -r29fc3cf43f0885270cca5b57c8bf17e347ae9609 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision 213b20e92891887167ab4b031ca4a4b6250a4c2a) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision 29fc3cf43f0885270cca5b57c8bf17e347ae9609) @@ -49,6 +49,7 @@ + @@ -67,6 +68,10 @@ {9a2d67e6-26ac-4d17-b11a-2b4372f2f572} Core.Common.Controls + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + {D4200F43-3F72-4F42-AF0A-8CED416A38EC} Ringtoets.Common.Data