Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs =================================================================== diff -u -rdd72cf407b7d0e9284d101bb2e2854e569b1a29a -r7a0eb8b2709b5c13d4711701213826b9cbd5aafe --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs (.../HeightStructuresPluginTest.cs) (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs (.../HeightStructuresPluginTest.cs) (revision 7a0eb8b2709b5c13d4711701213826b9cbd5aafe) @@ -138,30 +138,6 @@ } [Test] - public void GetFileInfos_Always_ReturnsExpectedImportInfos() - { - // Setup - var mocks = new MockRepository(); - var guiStub = mocks.Stub(); - guiStub.Stub(g => g.ApplicationCommands).Return(mocks.Stub()); - mocks.ReplayAll(); - - using (var plugin = new HeightStructuresPlugin() - { - Gui = guiStub - }) - { - // Call - ImportInfo[] importInfos = plugin.GetImportInfos().ToArray(); - - // Assert - Assert.AreEqual(1, importInfos.Length); - Assert.AreEqual(1, importInfos.Count(i => i.DataType == typeof(HeightStructuresContext))); - } - mocks.VerifyAll(); - } - - [Test] public void GetImportInfos_ReturnsExpectedImportInfos() { // Setup Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresCalculationContext.cs =================================================================== diff -u -r04012135e8adf6a03ce2928e047603435c9a186f -r7a0eb8b2709b5c13d4711701213826b9cbd5aafe --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresCalculationContext.cs (.../StabilityPointStructuresCalculationContext.cs) (revision 04012135e8adf6a03ce2928e047603435c9a186f) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresCalculationContext.cs (.../StabilityPointStructuresCalculationContext.cs) (revision 7a0eb8b2709b5c13d4711701213826b9cbd5aafe) @@ -30,7 +30,7 @@ /// Presentation object for all data required to configure an instance of /// in order to prepare it for performing a calculation. /// - public class StabilityPointStructuresCalculationContext : StabilityPointStructuresContext, + public class StabilityPointStructuresCalculationContext : StabilityPointStructuresContextBase, ICalculationContext { Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresCalculationGroupContext.cs =================================================================== diff -u -rfe8e564d0114932ff274b9c4e3066639ae2f02f1 -r7a0eb8b2709b5c13d4711701213826b9cbd5aafe --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresCalculationGroupContext.cs (.../StabilityPointStructuresCalculationGroupContext.cs) (revision fe8e564d0114932ff274b9c4e3066639ae2f02f1) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresCalculationGroupContext.cs (.../StabilityPointStructuresCalculationGroupContext.cs) (revision 7a0eb8b2709b5c13d4711701213826b9cbd5aafe) @@ -31,7 +31,7 @@ /// Presentation object for all data required to configure an instance of /// in order be able to create configurable stability point structures calculations. /// - public class StabilityPointStructuresCalculationGroupContext : StabilityPointStructuresContext, + public class StabilityPointStructuresCalculationGroupContext : StabilityPointStructuresContextBase, ICalculationContext { Fisheye: Tag 7a0eb8b2709b5c13d4711701213826b9cbd5aafe refers to a dead (removed) revision in file `Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresContext.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresContextBase.cs =================================================================== diff -u --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresContextBase.cs (revision 0) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresContextBase.cs (revision 7a0eb8b2709b5c13d4711701213826b9cbd5aafe) @@ -0,0 +1,90 @@ +// 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.Common.Data.AssessmentSection; +using Ringtoets.HydraRing.Data; +using Ringtoets.StabilityPointStructures.Data; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.StabilityPointStructures.Forms.PresentationObjects +{ + /// + /// Presentation object representing all required stability point structures input knowledge to configure and create + /// related objects. It will delegate observable behavior to the wrapped data object. + /// + public abstract class StabilityPointStructuresContextBase : ObservableWrappedObjectContextBase where T : IObservable + { + /// + /// Initializes a new instance of the class. + /// + /// The concrete data instance wrapped by this context object. + /// The failure mechanism which the context belongs to. + /// The assessment section which belongs to. + /// When any input argument is null. + protected StabilityPointStructuresContextBase(T wrappedData, + StabilityPointStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + : base(wrappedData) + { + if (failureMechanism == null) + { + throw new ArgumentNullException("failureMechanism"); + } + + if (assessmentSection == null) + { + throw new ArgumentNullException("assessmentSection"); + } + + FailureMechanism = failureMechanism; + AssessmentSection = assessmentSection; + } + + /// + /// Gets the failure mechanism which the context belongs to. + /// + public StabilityPointStructuresFailureMechanism FailureMechanism { get; private set; } + + /// + /// Gets the assessment section which belongs to. + /// + public IAssessmentSection AssessmentSection { get; private set; } + + /// + /// Gets the available hydraulic boundary locations in order for the user to select one to + /// set . + /// + public IEnumerable AvailableHydraulicBoundaryLocations + { + get + { + return AssessmentSection.HydraulicBoundaryDatabase == null ? + Enumerable.Empty() : + AssessmentSection.HydraulicBoundaryDatabase.Locations; + } + } + } +} \ No newline at end of file Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresInputContext.cs =================================================================== diff -u -raba67f792ebf713b8efd82f090204253ac4ec358 -r7a0eb8b2709b5c13d4711701213826b9cbd5aafe --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresInputContext.cs (.../StabilityPointStructuresInputContext.cs) (revision aba67f792ebf713b8efd82f090204253ac4ec358) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresInputContext.cs (.../StabilityPointStructuresInputContext.cs) (revision 7a0eb8b2709b5c13d4711701213826b9cbd5aafe) @@ -29,7 +29,7 @@ /// Presentation object for all data required to configure an instance of /// in order to be able to configure stability point structures calculations. /// - public class StabilityPointStructuresInputContext : StabilityPointStructuresContext + public class StabilityPointStructuresInputContext : StabilityPointStructuresContextBase { /// /// Creates a new instance of . Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Ringtoets.StabilityPointStructures.Forms.csproj =================================================================== diff -u -r341ddc4bed3bbbae529c1c282d15cc9b593d1e6a -r7a0eb8b2709b5c13d4711701213826b9cbd5aafe --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Ringtoets.StabilityPointStructures.Forms.csproj (.../Ringtoets.StabilityPointStructures.Forms.csproj) (revision 341ddc4bed3bbbae529c1c282d15cc9b593d1e6a) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Ringtoets.StabilityPointStructures.Forms.csproj (.../Ringtoets.StabilityPointStructures.Forms.csproj) (revision 7a0eb8b2709b5c13d4711701213826b9cbd5aafe) @@ -43,7 +43,7 @@ - + Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresCalculationContextTest.cs =================================================================== diff -u -raba67f792ebf713b8efd82f090204253ac4ec358 -r7a0eb8b2709b5c13d4711701213826b9cbd5aafe --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresCalculationContextTest.cs (.../StabilityPointStructuresCalculationContextTest.cs) (revision aba67f792ebf713b8efd82f090204253ac4ec358) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresCalculationContextTest.cs (.../StabilityPointStructuresCalculationContextTest.cs) (revision 7a0eb8b2709b5c13d4711701213826b9cbd5aafe) @@ -46,7 +46,7 @@ var context = new StabilityPointStructuresCalculationContext(calculation, failureMechanism, assessmentSectionMock); // Assert - Assert.IsInstanceOf>(context); + Assert.IsInstanceOf>(context); Assert.IsInstanceOf>(context); Assert.AreSame(calculation, context.WrappedData); Assert.AreSame(failureMechanism, context.FailureMechanism); Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresCalculationGroupContextTest.cs =================================================================== diff -u -rfe8e564d0114932ff274b9c4e3066639ae2f02f1 -r7a0eb8b2709b5c13d4711701213826b9cbd5aafe --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresCalculationGroupContextTest.cs (.../StabilityPointStructuresCalculationGroupContextTest.cs) (revision fe8e564d0114932ff274b9c4e3066639ae2f02f1) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresCalculationGroupContextTest.cs (.../StabilityPointStructuresCalculationGroupContextTest.cs) (revision 7a0eb8b2709b5c13d4711701213826b9cbd5aafe) @@ -47,7 +47,7 @@ var groupContext = new StabilityPointStructuresCalculationGroupContext(calculationGroup, failureMechanism, assessmentSectionMock); // Assert - Assert.IsInstanceOf>(groupContext); + Assert.IsInstanceOf>(groupContext); Assert.IsInstanceOf>(groupContext); Assert.AreSame(calculationGroup, groupContext.WrappedData); Assert.AreSame(failureMechanism, groupContext.FailureMechanism); Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresContextBaseTest.cs =================================================================== diff -u --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresContextBaseTest.cs (revision 0) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresContextBaseTest.cs (revision 7a0eb8b2709b5c13d4711701213826b9cbd5aafe) @@ -0,0 +1,128 @@ +// 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 NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.HydraRing.Data; +using Ringtoets.StabilityPointStructures.Data; +using Ringtoets.StabilityPointStructures.Forms.PresentationObjects; + +namespace Ringtoets.StabilityPointStructures.Forms.Test.PresentationObjects +{ + [TestFixture] + public class StabilityPointStructuresContextBaseTest + { + [Test] + public void ParameteredConstructor_ExpectedValues() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSectionMock = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var target = new ObservableObject(); + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + // Call + var context = new SimpleStabilityPointStructuresContext(target, failureMechanism, assessmentSectionMock); + + // Assert + Assert.IsInstanceOf>(context); + Assert.AreSame(target, context.WrappedData); + Assert.AreSame(assessmentSectionMock, context.AssessmentSection); + Assert.AreSame(failureMechanism, context.FailureMechanism); + CollectionAssert.IsEmpty(context.AvailableHydraulicBoundaryLocations); + mockRepository.VerifyAll(); + } + + [Test] + public void ParameteredConstructor_FailureMechanismIsNull_ThrowsArgumentNullException() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSectionMock = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var observableObject = new ObservableObject(); + + // Call + TestDelegate call = () => new SimpleStabilityPointStructuresContext(observableObject, null, assessmentSectionMock); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("failureMechanism", paramName); + mockRepository.VerifyAll(); + } + + [Test] + public void ParameteredConstructor_AssessmentSectionIsNull_ThrowsArgumentNullException() + { + // Setup + var observableObject = new ObservableObject(); + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + + // Call + TestDelegate call = () => new SimpleStabilityPointStructuresContext(observableObject, failureMechanism, null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("assessmentSection", paramName); + } + + [Test] + public void AvailableHydraulicBoundaryLocations_HydraulicBoundaryDatabaseSet_ReturnsAllHydraulicBoundaryLocations() + { + // Setup + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + hydraulicBoundaryDatabase.Locations.Add(new HydraulicBoundaryLocation(1, "name", 1.1, 2.2)); + + var mockRepository = new MockRepository(); + var assessmentSectionMock = mockRepository.Stub(); + assessmentSectionMock.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + mockRepository.ReplayAll(); + + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + var target = new ObservableObject(); + var context = new SimpleStabilityPointStructuresContext(target, failureMechanism, assessmentSectionMock); + + // Call + var availableHydraulicBoundaryLocations = context.AvailableHydraulicBoundaryLocations; + + // Assert + Assert.AreEqual(1, availableHydraulicBoundaryLocations.Count()); + Assert.AreEqual(hydraulicBoundaryDatabase.Locations, availableHydraulicBoundaryLocations); + mockRepository.VerifyAll(); + } + + private class ObservableObject : Observable {} + + private class SimpleStabilityPointStructuresContext : StabilityPointStructuresContextBase where T : IObservable + { + public SimpleStabilityPointStructuresContext(T target, StabilityPointStructuresFailureMechanism failureMechanism, IAssessmentSection assessmentSection) + : base(target, failureMechanism, assessmentSection) {} + } + } +} \ No newline at end of file Fisheye: Tag 7a0eb8b2709b5c13d4711701213826b9cbd5aafe refers to a dead (removed) revision in file `Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresContextTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresInputContextTest.cs =================================================================== diff -u -raba67f792ebf713b8efd82f090204253ac4ec358 -r7a0eb8b2709b5c13d4711701213826b9cbd5aafe --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresInputContextTest.cs (.../StabilityPointStructuresInputContextTest.cs) (revision aba67f792ebf713b8efd82f090204253ac4ec358) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresInputContextTest.cs (.../StabilityPointStructuresInputContextTest.cs) (revision 7a0eb8b2709b5c13d4711701213826b9cbd5aafe) @@ -53,7 +53,7 @@ var context = new StabilityPointStructuresInputContext(input, calculation, failureMechanism, assessmentSectionMock); // Assert - Assert.IsInstanceOf>(context); + Assert.IsInstanceOf>(context); Assert.AreSame(input, context.WrappedData); Assert.AreSame(calculation, context.Calculation); Assert.AreSame(failureMechanism, context.FailureMechanism); Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Ringtoets.StabilityPointStructures.Forms.Test.csproj =================================================================== diff -u -r341ddc4bed3bbbae529c1c282d15cc9b593d1e6a -r7a0eb8b2709b5c13d4711701213826b9cbd5aafe --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Ringtoets.StabilityPointStructures.Forms.Test.csproj (.../Ringtoets.StabilityPointStructures.Forms.Test.csproj) (revision 341ddc4bed3bbbae529c1c282d15cc9b593d1e6a) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Ringtoets.StabilityPointStructures.Forms.Test.csproj (.../Ringtoets.StabilityPointStructures.Forms.Test.csproj) (revision 7a0eb8b2709b5c13d4711701213826b9cbd5aafe) @@ -60,7 +60,7 @@ - +