Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PresentationObjects/ClosingStructuresCalculationGroupContext.cs =================================================================== diff -u --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PresentationObjects/ClosingStructuresCalculationGroupContext.cs (revision 0) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PresentationObjects/ClosingStructuresCalculationGroupContext.cs (revision f02ecc2ee4949596335f3c9792dd77d4120a14bd) @@ -0,0 +1,34 @@ +// 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 Ringtoets.ClosingStructures.Data; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Forms.PresentationObjects; + +namespace Ringtoets.ClosingStructures.Forms.PresentationObjects +{ + public class ClosingStructuresCalculationGroupContext : ClosingStructuresContext, ICalculationContext + { + public ClosingStructuresCalculationGroupContext(CalculationGroup calculationGroup, ClosingStructuresFailureMechanism failureMechanism, IAssessmentSection assessmentSection) : + base(calculationGroup, failureMechanism, assessmentSection) {} + } +} \ No newline at end of file Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PresentationObjects/ClosingStructuresContext.cs =================================================================== diff -u --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PresentationObjects/ClosingStructuresContext.cs (revision 0) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PresentationObjects/ClosingStructuresContext.cs (revision f02ecc2ee4949596335f3c9792dd77d4120a14bd) @@ -0,0 +1,81 @@ +// 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 System.Collections.Generic; +using System.Linq; +using Core.Common.Base; +using Core.Common.Controls.PresentationObjects; +using Ringtoets.ClosingStructures.Data; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.HydraRing.Data; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.ClosingStructures.Forms.PresentationObjects +{ + /// + /// Presentation object representing all required closing structures input knowledge to configure and create + /// related objects. It will delegate observable behaviour to the wrapped data object. + /// + public abstract class ClosingStructuresContext : ObservableWrappedObjectContextBase where T:IObservable + { + /// + /// Initializes a new instance of + /// + /// The concrete data instance wrapped by the context object + /// The failure mechanism which the context belongs to + /// The assessment section which the context belongs to + /// When any of the input parameters are null + protected ClosingStructuresContext(T wrappedData, + ClosingStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + : base(wrappedData) + { + if (failureMechanism == null) + { + string message = string.Format(RingtoetsCommonFormsResources.AssertInputsAreNotNull_DataDescription_0_cannot_be_null, + "Het sluitings kunstwerk toetsspoor"); + throw new ArgumentNullException("failureMechanism", message); + } + + if (assessmentSection == null) + { + string message = string.Format(RingtoetsCommonFormsResources.AssertInputsAreNotNull_DataDescription_0_cannot_be_null, + RingtoetsCommonFormsResources.FailureMechanismContext_DataDescription_AssessmentSection); + + throw new ArgumentNullException("assessmentSection", message); + } + + FailureMechanism = failureMechanism; + AssessmentSection = assessmentSection; + } + + /// + /// Gets the assessment section belonging to the context + /// + public IAssessmentSection AssessmentSection { get; private set; } + + /// + /// Gets the failure mechanism belonging to the context + /// + public ClosingStructuresFailureMechanism FailureMechanism { get; private set; } + } +} Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Ringtoets.ClosingStructures.Forms.csproj =================================================================== diff -u -rfbf9eca188c20c352a702ee20c183e5dc3c7acf1 -rf02ecc2ee4949596335f3c9792dd77d4120a14bd --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Ringtoets.ClosingStructures.Forms.csproj (.../Ringtoets.ClosingStructures.Forms.csproj) (revision fbf9eca188c20c352a702ee20c183e5dc3c7acf1) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Ringtoets.ClosingStructures.Forms.csproj (.../Ringtoets.ClosingStructures.Forms.csproj) (revision f02ecc2ee4949596335f3c9792dd77d4120a14bd) @@ -41,6 +41,8 @@ Properties\GlobalAssembly.cs + + @@ -79,6 +81,10 @@ Ringtoets.Common.Forms False + + {70F8CC9C-5BC8-4FB2-B201-EAE7FA8088C2} + Ringtoets.HydraRing.Data + {C6309704-D67B-434C-BC98-9F8910BC1D10} Ringtoets.ClosingStructures.Data Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PresentationObjects/ClosingStructuresCalculationGroupContextTest.cs =================================================================== diff -u --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PresentationObjects/ClosingStructuresCalculationGroupContextTest.cs (revision 0) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PresentationObjects/ClosingStructuresCalculationGroupContextTest.cs (revision f02ecc2ee4949596335f3c9792dd77d4120a14bd) @@ -0,0 +1,58 @@ +// 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 NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.ClosingStructures.Data; +using Ringtoets.ClosingStructures.Forms.PresentationObjects; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Forms.PresentationObjects; + +namespace Ringtoets.ClosingStructures.Forms.Test.PresentationObjects +{ + [TestFixture] + public class ClosingStructuresCalculationGroupContextTest + { + [Test] + public void ParameteredConstructor_ExpectedValues() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSectionMock = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + + var calculationGroup = new CalculationGroup(); + var failureMechanism = new ClosingStructuresFailureMechanism(); + + // Call + var groupContext = new ClosingStructuresCalculationGroupContext(calculationGroup, failureMechanism, assessmentSectionMock); + + // Assert + Assert.IsInstanceOf>(groupContext); + Assert.IsInstanceOf>(groupContext); + Assert.AreSame(calculationGroup, groupContext.WrappedData); + Assert.AreSame(failureMechanism, groupContext.FailureMechanism); + Assert.AreSame(assessmentSectionMock, groupContext.AssessmentSection); + mockRepository.VerifyAll(); + } + } +} Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PresentationObjects/ClosingStructuresContextTest.cs =================================================================== diff -u --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PresentationObjects/ClosingStructuresContextTest.cs (revision 0) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PresentationObjects/ClosingStructuresContextTest.cs (revision f02ecc2ee4949596335f3c9792dd77d4120a14bd) @@ -0,0 +1,103 @@ +// 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 System.Linq; +using Core.Common.Base; +using Core.Common.Controls.PresentationObjects; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.ClosingStructures.Data; +using Ringtoets.ClosingStructures.Forms.PresentationObjects; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.HydraRing.Data; + +namespace Ringtoets.ClosingStructures.Forms.Test.PresentationObjects +{ + [TestFixture] + public class ClosingStructuresContextTest + { + [Test] + public void ParameteredConstructor_ExpectedValues() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSectionMock = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + + var target = new ObservableObject(); + var failureMechanism = new ClosingStructuresFailureMechanism(); + + // Call + var context = new SimpleClosingStructuresContext(target, failureMechanism, assessmentSectionMock); + + // Assert + Assert.IsInstanceOf>(context); + Assert.AreSame(target, context.WrappedData); + Assert.AreSame(assessmentSectionMock, context.AssessmentSection); + Assert.AreSame(failureMechanism, context.FailureMechanism); + mockRepository.VerifyAll(); + } + + [Test] + public void ParameteredConstructor_FailureMechanismIsNull_ThrowsArgumentNullException() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSectionMock = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + + var observableObject = new ObservableObject(); + + // Call + TestDelegate call = () => new SimpleClosingStructuresContext(observableObject, null, assessmentSectionMock); + + // Assert + const string expectedMessage = "Het sluitings kunstwerk toetsspoor mag niet 'null' zijn."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + mockRepository.VerifyAll(); + } + + [Test] + public void ParameteredConstructor_AssessmentSectionIsNull_ThrowsArgumentNullException() + { + // Setup + var observableObject = new ObservableObject(); + var failureMechanism = new ClosingStructuresFailureMechanism(); + + // Call + TestDelegate call = () => new SimpleClosingStructuresContext(observableObject, failureMechanism, null); + + // Assert + const string expectedMessage = "Het traject mag niet 'null' zijn."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + private class ObservableObject : Observable { } + + private class SimpleClosingStructuresContext : ClosingStructuresContext where T : IObservable + { + public SimpleClosingStructuresContext(T target, ClosingStructuresFailureMechanism failureMechanism, IAssessmentSection assessmentSection) + : base(target, failureMechanism, assessmentSection) { } + } + } +} Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Ringtoets.ClosingStructures.Forms.Test.csproj =================================================================== diff -u -rfbf9eca188c20c352a702ee20c183e5dc3c7acf1 -rf02ecc2ee4949596335f3c9792dd77d4120a14bd --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Ringtoets.ClosingStructures.Forms.Test.csproj (.../Ringtoets.ClosingStructures.Forms.Test.csproj) (revision fbf9eca188c20c352a702ee20c183e5dc3c7acf1) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Ringtoets.ClosingStructures.Forms.Test.csproj (.../Ringtoets.ClosingStructures.Forms.Test.csproj) (revision f02ecc2ee4949596335f3c9792dd77d4120a14bd) @@ -58,6 +58,8 @@ Properties\GlobalAssembly.cs + + @@ -113,6 +115,11 @@ {4843D6E5-066F-4795-94F5-1D53932DD03C} Ringtoets.Common.Data.TestUtil + + {70F8CC9C-5BC8-4FB2-B201-EAE7FA8088C2} + Ringtoets.HydraRing.Data + True + {C6309704-D67B-434C-BC98-9F8910BC1D10} Ringtoets.ClosingStructures.Data