Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PresentationObjects/GrassCoverErosionOutwardsContext.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PresentationObjects/GrassCoverErosionOutwardsContext.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PresentationObjects/GrassCoverErosionOutwardsContext.cs (revision 5387346fe4a7aa93e72d71f86c1e4d0a22a73f91) @@ -0,0 +1,59 @@ +// 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 Ringtoets.GrassCoverErosionOutwards.Data; + +namespace Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects +{ + /// + /// Presentation object representing all required grass cover erosion outwards input knowledge + /// to configure and create related calculation objects. + /// + /// The observable object type of the wrapped instance. + public abstract class GrassCoverErosionOutwardsContext : ObservableWrappedObjectContextBase where T : IObservable + { + /// + /// Creates a new instance of . + /// + /// The concrete data instance wrapped by this context object. + /// The failure mechanism which the context belongs to. + /// Thrown when any paramater is null. + protected GrassCoverErosionOutwardsContext(T wrappedData, + GrassCoverErosionOutwardsFailureMechanism failureMechanism) + : base(wrappedData) + { + if (failureMechanism == null) + { + throw new ArgumentNullException("failureMechanism"); + } + + FailureMechanism = failureMechanism; + } + + /// + /// Gets the failure mechanism which the context belongs to. + /// + public GrassCoverErosionOutwardsFailureMechanism FailureMechanism { get; private set; } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj =================================================================== diff -u -r61a95ca656c72706f706099cfd00e9d57d7e45a1 -r5387346fe4a7aa93e72d71f86c1e4d0a22a73f91 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.csproj) (revision 61a95ca656c72706f706099cfd00e9d57d7e45a1) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.csproj) (revision 5387346fe4a7aa93e72d71f86c1e4d0a22a73f91) @@ -44,6 +44,7 @@ Properties\GlobalAssembly.cs + Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PresentationObjects/GrassCoverErosionOutwardsContextTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PresentationObjects/GrassCoverErosionOutwardsContextTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PresentationObjects/GrassCoverErosionOutwardsContextTest.cs (revision 5387346fe4a7aa93e72d71f86c1e4d0a22a73f91) @@ -0,0 +1,93 @@ +// 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 NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.GrassCoverErosionOutwards.Data; +using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; + +namespace Ringtoets.GrassCoverErosionOutwards.Forms.Test.PresentationObjects +{ + [TestFixture] + public class GrassCoverErosionOutwardsContextTest + { + [Test] + public void Constructor_WrappedDataNull_ThrowArgumentNullException() + { + // Setup + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + // Call + TestDelegate call = () => new SimpleGrassCoverErosionOutwardsContext(null, failureMechanism); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("wrappedData", paramName); + } + + [Test] + public void Constructor_FailureMechanismNull_ThrowArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var observable = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => new SimpleGrassCoverErosionOutwardsContext(observable, null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("failureMechanism", paramName); + mocks.VerifyAll(); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var observable = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + // Call + var context = new SimpleGrassCoverErosionOutwardsContext(observable, failureMechanism); + + // Assert + Assert.IsInstanceOf>(context); + Assert.AreSame(observable, context.WrappedData); + Assert.AreSame(failureMechanism, context.FailureMechanism); + mocks.VerifyAll(); + } + + private class SimpleGrassCoverErosionOutwardsContext : GrassCoverErosionOutwardsContext + { + public SimpleGrassCoverErosionOutwardsContext(IObservable wrappedData, + GrassCoverErosionOutwardsFailureMechanism failureMechanism) + : base(wrappedData, failureMechanism) {} + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj =================================================================== diff -u -r61a95ca656c72706f706099cfd00e9d57d7e45a1 -r5387346fe4a7aa93e72d71f86c1e4d0a22a73f91 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj) (revision 61a95ca656c72706f706099cfd00e9d57d7e45a1) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj) (revision 5387346fe4a7aa93e72d71f86c1e4d0a22a73f91) @@ -62,6 +62,7 @@ Properties\GlobalAssembly.cs + Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/PresentationObjects/StabilityStoneCoverContextTest.cs =================================================================== diff -u -r6c3a074511922fb175a1aa7f20168bbb6d63a688 -r5387346fe4a7aa93e72d71f86c1e4d0a22a73f91 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/PresentationObjects/StabilityStoneCoverContextTest.cs (.../StabilityStoneCoverContextTest.cs) (revision 6c3a074511922fb175a1aa7f20168bbb6d63a688) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/PresentationObjects/StabilityStoneCoverContextTest.cs (.../StabilityStoneCoverContextTest.cs) (revision 5387346fe4a7aa93e72d71f86c1e4d0a22a73f91) @@ -21,6 +21,7 @@ using System; using Core.Common.Base; +using Core.Common.Controls.PresentationObjects; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; @@ -103,6 +104,7 @@ var context = new SimpleStabilityStoneCoverContext(observable, failureMechanism, assessmentSection); // Assert + Assert.IsInstanceOf>(context); Assert.AreSame(observable, context.WrappedData); Assert.AreSame(assessmentSection, context.AssessmentSection); Assert.AreSame(failureMechanism, context.FailureMechanism);