Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresCalculationContext.cs =================================================================== diff -u -rdd95a590c807772d742ebe1b7e28611fa4931863 -rdd72cf407b7d0e9284d101bb2e2854e569b1a29a --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresCalculationContext.cs (.../HeightStructuresCalculationContext.cs) (revision dd95a590c807772d742ebe1b7e28611fa4931863) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresCalculationContext.cs (.../HeightStructuresCalculationContext.cs) (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -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 HeightStructuresCalculationContext : HeightStructuresContext, ICalculationContext + public class HeightStructuresCalculationContext : HeightStructuresContextBase, ICalculationContext { /// /// Creates a new instance of . Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresCalculationGroupContext.cs =================================================================== diff -u -rdd95a590c807772d742ebe1b7e28611fa4931863 -rdd72cf407b7d0e9284d101bb2e2854e569b1a29a --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresCalculationGroupContext.cs (.../HeightStructuresCalculationGroupContext.cs) (revision dd95a590c807772d742ebe1b7e28611fa4931863) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresCalculationGroupContext.cs (.../HeightStructuresCalculationGroupContext.cs) (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -31,7 +31,7 @@ /// Presentation object for all data required to configure an instance of /// in order be able to create configurable height structures calculations. /// - public class HeightStructuresCalculationGroupContext : HeightStructuresContext, ICalculationContext + public class HeightStructuresCalculationGroupContext : HeightStructuresContextBase, ICalculationContext { /// /// Creates a new instance of . Fisheye: Tag dd72cf407b7d0e9284d101bb2e2854e569b1a29a refers to a dead (removed) revision in file `Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresCollectionContext.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresContext.cs =================================================================== diff -u -rd689ea05c1014eb4d51b927e11eb6c48255f0a47 -rdd72cf407b7d0e9284d101bb2e2854e569b1a29a --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresContext.cs (.../HeightStructuresContext.cs) (revision d689ea05c1014eb4d51b927e11eb6c48255f0a47) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresContext.cs (.../HeightStructuresContext.cs) (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -20,78 +20,41 @@ // 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.HeightStructures.Data; -using Ringtoets.HeightStructures.Forms.Properties; -using Ringtoets.HydraRing.Data; -using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.HeightStructures.Forms.PresentationObjects { /// - /// Presentation object representing all required height structures input knowledge to configure and create - /// related objects. It'll delegate observable behavior to the wrapped data object. + /// The presentation object for an of . /// - public abstract class HeightStructuresContext : ObservableWrappedObjectContextBase where T : IObservable + public class HeightStructuresContext : ObservableWrappedObjectContextBase> { /// - /// Initializes a new instance of the class. + /// Creates an instance of . /// - /// The concrete data instance wrapped by this context object. - /// The failure mechanism which the context belongs to. - /// The assessment section which the context belongs to. - /// When any input argument is null. - protected HeightStructuresContext( - T wrappedData, - HeightStructuresFailureMechanism failureMechanism, - IAssessmentSection assessmentSection) - : base(wrappedData) + /// The wrapped + /// containing . + /// The assessment section which the height structures + /// belong to. + /// Thrown when any of the input arguments + /// are null. + public HeightStructuresContext(ObservableList heightStructures, IAssessmentSection assessmentSection) + : base(heightStructures) { - if (failureMechanism == null) - { - var message = string.Format(RingtoetsCommonFormsResources.AssertInputsAreNotNull_DataDescription_0_cannot_be_null, - Resources.HeightStructuresContext_DataDescription_HeightStructuresFailureMechanism); - - throw new ArgumentNullException("failureMechanism", message); - } - if (assessmentSection == null) { - var message = string.Format(RingtoetsCommonFormsResources.AssertInputsAreNotNull_DataDescription_0_cannot_be_null, - RingtoetsCommonFormsResources.FailureMechanismContext_DataDescription_AssessmentSection); - throw new ArgumentNullException("assessmentSection", message); + throw new ArgumentNullException("assessmentSection"); } - FailureMechanism = failureMechanism; AssessmentSection = assessmentSection; } /// - /// Gets the failure mechanism which the context belongs to. + /// Gets the assessment section of this instance. /// - public HeightStructuresFailureMechanism FailureMechanism { get; private set; } - - /// - /// Gets the assessment section which the context 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/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresContextBase.cs =================================================================== diff -u --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresContextBase.cs (revision 0) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresContextBase.cs (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -0,0 +1,96 @@ +// 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.HeightStructures.Data; +using Ringtoets.HeightStructures.Forms.Properties; +using Ringtoets.HydraRing.Data; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.HeightStructures.Forms.PresentationObjects +{ + /// + /// Presentation object representing all required height structures input knowledge to configure and create + /// related objects. It'll delegate observable behavior to the wrapped data object. + /// + public abstract class HeightStructuresContextBase : 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 the context belongs to. + /// When any input argument is null. + protected HeightStructuresContextBase(T wrappedData, + HeightStructuresFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + : base(wrappedData) + { + if (failureMechanism == null) + { + var message = string.Format(RingtoetsCommonFormsResources.AssertInputsAreNotNull_DataDescription_0_cannot_be_null, + Resources.HeightStructuresContextBase_DataDescription_HeightStructuresFailureMechanism); + + throw new ArgumentNullException("failureMechanism", message); + } + + if (assessmentSection == null) + { + var 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 failure mechanism which the context belongs to. + /// + public HeightStructuresFailureMechanism FailureMechanism { get; private set; } + + /// + /// Gets the assessment section which the context 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/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresInputContext.cs =================================================================== diff -u -rd689ea05c1014eb4d51b927e11eb6c48255f0a47 -rdd72cf407b7d0e9284d101bb2e2854e569b1a29a --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresInputContext.cs (.../HeightStructuresInputContext.cs) (revision d689ea05c1014eb4d51b927e11eb6c48255f0a47) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PresentationObjects/HeightStructuresInputContext.cs (.../HeightStructuresInputContext.cs) (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -31,7 +31,7 @@ /// Presentation object for all data required to configure an instance of /// in order to be able to configure height structures calculations. /// - public class HeightStructuresInputContext : HeightStructuresContext + public class HeightStructuresInputContext : HeightStructuresContextBase { /// /// Creates a new instance of . Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -rfbf9eca188c20c352a702ee20c183e5dc3c7acf1 -rdd72cf407b7d0e9284d101bb2e2854e569b1a29a --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision fbf9eca188c20c352a702ee20c183e5dc3c7acf1) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -183,9 +183,9 @@ /// /// Looks up a localized string similar to Het hoogte kunstwerk toetsspoor. /// - public static string HeightStructuresContext_DataDescription_HeightStructuresFailureMechanism { + public static string HeightStructuresContextBase_DataDescription_HeightStructuresFailureMechanism { get { - return ResourceManager.GetString("HeightStructuresContext_DataDescription_HeightStructuresFailureMechanism", resourceCulture); + return ResourceManager.GetString("HeightStructuresContextBase_DataDescription_HeightStructuresFailureMechanism", resourceCulture); } } Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.resx =================================================================== diff -u -rfbf9eca188c20c352a702ee20c183e5dc3c7acf1 -rdd72cf407b7d0e9284d101bb2e2854e569b1a29a --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.resx (.../Resources.resx) (revision fbf9eca188c20c352a702ee20c183e5dc3c7acf1) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.resx (.../Resources.resx) (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -117,7 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + Het hoogte kunstwerk toetsspoor Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj =================================================================== diff -u -r15ba2de00ab1dd0df317409a272ef686ee688297 -rdd72cf407b7d0e9284d101bb2e2854e569b1a29a --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj (.../Ringtoets.HeightStructures.Forms.csproj) (revision 15ba2de00ab1dd0df317409a272ef686ee688297) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj (.../Ringtoets.HeightStructures.Forms.csproj) (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -41,10 +41,10 @@ Properties\GlobalAssembly.cs - + - + Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs =================================================================== diff -u -r240fbc1c83da30eae57a9dace4f4a136c8213437 -rdd72cf407b7d0e9284d101bb2e2854e569b1a29a --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 240fbc1c83da30eae57a9dace4f4a136c8213437) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -64,7 +64,7 @@ public override IEnumerable GetImportInfos() { - yield return new ImportInfo + yield return new ImportInfo { CreateFileImporter = (context, filePath) => new HeightStructuresImporter(context.WrappedData, context.AssessmentSection.ReferenceLine, @@ -119,7 +119,7 @@ .Build() }; - yield return new TreeNodeInfo + yield return new TreeNodeInfo { Text = context => RingtoetsCommonFormsResources.StructuresCollection_DisplayName, Image = context => RingtoetsCommonFormsResources.GeneralFolderIcon, @@ -262,7 +262,7 @@ { new FailureMechanismSectionsContext(failureMechanism, assessmentSection), new ForeshoreProfilesContext(failureMechanism.ForeshoreProfiles, assessmentSection), - new HeightStructuresCollectionContext(failureMechanism.HeightStructures, assessmentSection), + new HeightStructuresContext(failureMechanism.HeightStructures, assessmentSection), new CommentContext(failureMechanism) }; } Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresCalculationContextTest.cs =================================================================== diff -u -re775448bfb8290e43d62340a53a08723bbc035c6 -rdd72cf407b7d0e9284d101bb2e2854e569b1a29a --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresCalculationContextTest.cs (.../HeightStructuresCalculationContextTest.cs) (revision e775448bfb8290e43d62340a53a08723bbc035c6) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresCalculationContextTest.cs (.../HeightStructuresCalculationContextTest.cs) (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -46,7 +46,7 @@ var context = new HeightStructuresCalculationContext(calculation, failureMechanism, assessmentSectionMock); // Assert - Assert.IsInstanceOf>(context); + Assert.IsInstanceOf>(context); Assert.IsInstanceOf>(context); Assert.AreEqual(calculation, context.WrappedData); Assert.AreEqual(failureMechanism, context.FailureMechanism); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresCalculationGroupContextTest.cs =================================================================== diff -u -r219bf641fa81657e9d154c9cb50245af9b2ebe27 -rdd72cf407b7d0e9284d101bb2e2854e569b1a29a --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresCalculationGroupContextTest.cs (.../HeightStructuresCalculationGroupContextTest.cs) (revision 219bf641fa81657e9d154c9cb50245af9b2ebe27) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresCalculationGroupContextTest.cs (.../HeightStructuresCalculationGroupContextTest.cs) (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -47,7 +47,7 @@ var groupContext = new HeightStructuresCalculationGroupContext(calculationGroup, failureMechanism, assessmentSectionMock); // Assert - Assert.IsInstanceOf>(groupContext); + Assert.IsInstanceOf>(groupContext); Assert.IsInstanceOf>(groupContext); Assert.AreSame(calculationGroup, groupContext.WrappedData); Assert.AreSame(failureMechanism, groupContext.FailureMechanism); Fisheye: Tag dd72cf407b7d0e9284d101bb2e2854e569b1a29a refers to a dead (removed) revision in file `Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresCollectionContextTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresContextBaseTest.cs =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresContextBaseTest.cs (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresContextBaseTest.cs (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -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 Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.HeightStructures.Data; +using Ringtoets.HeightStructures.Forms.PresentationObjects; +using Ringtoets.HydraRing.Data; + +namespace Ringtoets.HeightStructures.Forms.Test.PresentationObjects +{ + [TestFixture] + public class HeightStructuresContextBaseTest + { + [Test] + public void ParameteredConstructor_ExpectedValues() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSectionMock = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + + var target = new ObservableObject(); + var failureMechanism = new HeightStructuresFailureMechanism(); + + // Call + var context = new SimpleHeightStructuresContext(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 SimpleHeightStructuresContext(observableObject, null, assessmentSectionMock); + + // Assert + const string expectedMessage = "Het hoogte 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 HeightStructuresFailureMechanism(); + + // Call + TestDelegate call = () => new SimpleHeightStructuresContext(observableObject, failureMechanism, null); + + // Assert + const string expectedMessage = "Het traject mag niet 'null' zijn."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + } + + [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 assessmentSectionStub = mockRepository.Stub(); + assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + mockRepository.ReplayAll(); + + var target = new ObservableObject(); + var failureMechanism = new HeightStructuresFailureMechanism(); + var context = new SimpleHeightStructuresContext(target, failureMechanism, assessmentSectionStub); + + // Call + var availableHydraulicBoundaryLocations = context.AvailableHydraulicBoundaryLocations; + + // Assert + Assert.AreEqual(1, availableHydraulicBoundaryLocations.Count()); + Assert.AreEqual(hydraulicBoundaryDatabase.Locations, availableHydraulicBoundaryLocations); + mockRepository.VerifyAll(); + } + + private class ObservableObject : Observable {} + + private class SimpleHeightStructuresContext : HeightStructuresContextBase where T : IObservable + { + public SimpleHeightStructuresContext(T target, HeightStructuresFailureMechanism failureMechanism, IAssessmentSection assessmentSection) + : base(target, failureMechanism, assessmentSection) {} + } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresContextTest.cs =================================================================== diff -u -r0b5415143ee123cb716065ae7b7681913d2587e2 -rdd72cf407b7d0e9284d101bb2e2854e569b1a29a --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresContextTest.cs (.../HeightStructuresContextTest.cs) (revision 0b5415143ee123cb716065ae7b7681913d2587e2) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresContextTest.cs (.../HeightStructuresContextTest.cs) (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -20,16 +20,13 @@ // 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.Common.Data.AssessmentSection; using Ringtoets.HeightStructures.Data; using Ringtoets.HeightStructures.Forms.PresentationObjects; -using Ringtoets.HydraRing.Data; namespace Ringtoets.HeightStructures.Forms.Test.PresentationObjects { @@ -40,89 +37,34 @@ public void ParameteredConstructor_ExpectedValues() { // Setup - var mockRepository = new MockRepository(); - var assessmentSectionMock = mockRepository.StrictMock(); - mockRepository.ReplayAll(); + var mocks = new MockRepository(); + var assessmentSectionMock = mocks.Stub(); + mocks.ReplayAll(); - var target = new ObservableObject(); - var failureMechanism = new HeightStructuresFailureMechanism(); + var heightStructures = new ObservableList(); // Call - var context = new SimpleHeightStructuresContext(target, failureMechanism, assessmentSectionMock); + var context = new HeightStructuresContext(heightStructures, assessmentSectionMock); // Assert - Assert.IsInstanceOf>(context); - Assert.AreSame(target, context.WrappedData); + Assert.IsInstanceOf>>(context); + Assert.AreSame(heightStructures, context.WrappedData); Assert.AreSame(assessmentSectionMock, context.AssessmentSection); - Assert.AreSame(failureMechanism, context.FailureMechanism); - mockRepository.VerifyAll(); + mocks.VerifyAll(); } [Test] - public void ParameteredConstructor_FailureMechanismIsNull_ThrowsArgumentNullException() + public void ParameteredConstructor_AssessmentSectionNull_ThrowsArgumentNullException() { // Setup - var mockRepository = new MockRepository(); - var assessmentSectionMock = mockRepository.StrictMock(); - mockRepository.ReplayAll(); + var heightStructures = new ObservableList(); - var observableObject = new ObservableObject(); - // Call - TestDelegate call = () => new SimpleHeightStructuresContext(observableObject, null, assessmentSectionMock); + TestDelegate test = () => new HeightStructuresContext(heightStructures, null); // Assert - const string expectedMessage = "Het hoogte kunstwerk toetsspoor mag niet 'null' zijn."; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); - mockRepository.VerifyAll(); + var exception = Assert.Throws(test); + Assert.AreEqual("assessmentSection", exception.ParamName); } - - [Test] - public void ParameteredConstructor_AssessmentSectionIsNull_ThrowsArgumentNullException() - { - // Setup - var observableObject = new ObservableObject(); - var failureMechanism = new HeightStructuresFailureMechanism(); - - // Call - TestDelegate call = () => new SimpleHeightStructuresContext(observableObject, failureMechanism, null); - - // Assert - const string expectedMessage = "Het traject mag niet 'null' zijn."; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); - } - - [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 assessmentSectionStub = mockRepository.Stub(); - assessmentSectionStub.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; - mockRepository.ReplayAll(); - - var target = new ObservableObject(); - var failureMechanism = new HeightStructuresFailureMechanism(); - var context = new SimpleHeightStructuresContext(target, failureMechanism, assessmentSectionStub); - - // Call - var availableHydraulicBoundaryLocations = context.AvailableHydraulicBoundaryLocations; - - // Assert - Assert.AreEqual(1, availableHydraulicBoundaryLocations.Count()); - Assert.AreEqual(hydraulicBoundaryDatabase.Locations, availableHydraulicBoundaryLocations); - 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) {} - } } } \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresInputContextTest.cs =================================================================== diff -u -rd689ea05c1014eb4d51b927e11eb6c48255f0a47 -rdd72cf407b7d0e9284d101bb2e2854e569b1a29a --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresInputContextTest.cs (.../HeightStructuresInputContextTest.cs) (revision d689ea05c1014eb4d51b927e11eb6c48255f0a47) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresInputContextTest.cs (.../HeightStructuresInputContextTest.cs) (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -57,7 +57,7 @@ var context = new HeightStructuresInputContext(input, calculation, failureMechanism, assessmentSectionMock); // Assert - Assert.IsInstanceOf>(context); + Assert.IsInstanceOf>(context); Assert.AreEqual(input, context.WrappedData); Assert.AreEqual(calculation, context.Calculation); Assert.AreEqual(failureMechanism, context.FailureMechanism); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj =================================================================== diff -u -r240fbc1c83da30eae57a9dace4f4a136c8213437 -rdd72cf407b7d0e9284d101bb2e2854e569b1a29a --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision 240fbc1c83da30eae57a9dace4f4a136c8213437) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -61,17 +61,17 @@ Properties\GlobalAssembly.cs - + - + - + Fisheye: Tag dd72cf407b7d0e9284d101bb2e2854e569b1a29a refers to a dead (removed) revision in file `Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCollectionContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresContextTreeNodeInfoTest.cs (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -0,0 +1,241 @@ +// 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.Drawing; +using System.Linq; +using Core.Common.Base; +using Core.Common.Base.Geometry; +using Core.Common.Controls.TreeView; +using Core.Common.Gui; +using Core.Common.Gui.ContextMenu; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.HeightStructures.Data; +using Ringtoets.HeightStructures.Forms.PresentationObjects; +using Ringtoets.HeightStructures.Plugin; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.HeightStructures.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class HeightStructuresContextTreeNodeInfoTest + { + private HeightStructuresPlugin plugin; + private TreeNodeInfo info; + + [SetUp] + public void SetUp() + { + plugin = new HeightStructuresPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(HeightStructuresContext)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(HeightStructuresContext), info.TagType); + Assert.IsNotNull(info.Text); + Assert.IsNotNull(info.Image); + Assert.IsNotNull(info.ForeColor); + Assert.IsNotNull(info.ChildNodeObjects); + Assert.IsNotNull(info.ContextMenuStrip); + Assert.IsNull(info.EnsureVisibleOnCreate); + Assert.IsNull(info.CanRename); + Assert.IsNull(info.OnNodeRenamed); + Assert.IsNull(info.CanRemove); + Assert.IsNull(info.OnNodeRemoved); + Assert.IsNull(info.CanCheck); + Assert.IsNull(info.IsChecked); + Assert.IsNull(info.OnNodeChecked); + Assert.IsNull(info.CanDrag); + Assert.IsNull(info.CanDrop); + Assert.IsNull(info.CanInsert); + Assert.IsNull(info.OnDrop); + } + + [Test] + public void Text_Always_ReturnExpectedText() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var heightStructures = new ObservableList(); + + var heightStructuresContext = new HeightStructuresContext(heightStructures, assessmentSection); + + // Call + string text = info.Text(heightStructuresContext); + + // Assert + const string expectedText = "Kunstwerken"; + Assert.AreEqual(expectedText, text); + mocks.VerifyAll(); + } + + [Test] + public void Image_Always_ReturnExpectedImage() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var heightStructures = new ObservableList(); + + var heightStructuresContext = new HeightStructuresContext(heightStructures, assessmentSection); + + // Call + Image image = info.Image(heightStructuresContext); + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GeneralFolderIcon, image); + mocks.VerifyAll(); + } + + [Test] + public void ForeColor_CollectionHasElementsEmpty_ReturnControlText() + { + // Setup + var mocks = new MockRepository(); + var asssessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var heightStructures = new ObservableList + { + CreateHeightStructure() + }; + + // Precondition + CollectionAssert.IsNotEmpty(heightStructures); + + var heightStructuresContext = new HeightStructuresContext(heightStructures, asssessmentSection); + + // Call + Color color = info.ForeColor(heightStructuresContext); + + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color); + mocks.VerifyAll(); + } + + [Test] + public void ChildNodeObjects_Always_ReturnDikeProfiles() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + HeightStructure heightStructure1 = CreateHeightStructure(); + HeightStructure heightStructure2 = CreateHeightStructure(); + var heightStructures = new ObservableList + { + heightStructure1, + heightStructure2 + }; + + var heightStructuresContext = new HeightStructuresContext(heightStructures, assessmentSection); + + // Call + object[] children = info.ChildNodeObjects(heightStructuresContext); + + // Assert + CollectionAssert.AreEqual(heightStructures, children); + mocks.VerifyAll(); + } + + [Test] + public void ForeColor_CollectionIsEmpty_ReturnGrayText() + { + // Setup + var mocks = new MockRepository(); + var asssessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var heightStructures = new ObservableList(); + + // Precondition + CollectionAssert.IsEmpty(heightStructures); + + var heightStructuresContext = new HeightStructuresContext(heightStructures, asssessmentSection); + + // Call + Color color = info.ForeColor(heightStructuresContext); + + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color); + mocks.VerifyAll(); + } + + [Test] + public void ContextMenuStrip_Always_CallsBuilder() + { + // Setup + var mocks = new MockRepository(); + var menuBuilderMock = mocks.StrictMock(); + menuBuilderMock.Expect(mb => mb.AddImportItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.Build()).Return(null); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocks.Stub(); + gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilderMock); + + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(null, null, treeViewControl); + } + // Assert + mocks.VerifyAll(); + } + + private static HeightStructure CreateHeightStructure() + { + var heightStructure = new HeightStructure("aName", "anId", new Point2D(1.22, 2.333), + 0.12345, + 234.567, 0.23456, + 345.678, 0.34567, + 456.789, 0.45678, + 567.890, 0.56789, + 0.67890, + 112.223, 0.11222, + 225.336, 0.22533); + return heightStructure; + } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r15ba2de00ab1dd0df317409a272ef686ee688297 -rdd72cf407b7d0e9284d101bb2e2854e569b1a29a --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 15ba2de00ab1dd0df317409a272ef686ee688297) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -126,9 +126,9 @@ Assert.AreSame(failureMechanism.ForeshoreProfiles, profilesContext.WrappedData); Assert.AreSame(assessmentSectionMock, profilesContext.ParentAssessmentSection); - var heightStructureContext = (HeightStructuresCollectionContext) inputsFolder.Contents[2]; - Assert.AreSame(failureMechanism.HeightStructures, heightStructureContext.WrappedData); - Assert.AreSame(assessmentSectionMock, heightStructureContext.AssessmentSection); + var heightStructuresContext = (HeightStructuresContext) inputsFolder.Contents[2]; + Assert.AreSame(failureMechanism.HeightStructures, heightStructuresContext.WrappedData); + Assert.AreSame(assessmentSectionMock, heightStructuresContext.AssessmentSection); var commentContext = (CommentContext) inputsFolder.Contents[3]; Assert.AreSame(failureMechanism, commentContext.WrappedData); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs =================================================================== diff -u -r240fbc1c83da30eae57a9dace4f4a136c8213437 -rdd72cf407b7d0e9284d101bb2e2854e569b1a29a --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs (.../HeightStructuresPluginTest.cs) (revision 240fbc1c83da30eae57a9dace4f4a136c8213437) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs (.../HeightStructuresPluginTest.cs) (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -102,7 +102,7 @@ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresCalculationGroupContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresCalculationContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresInputContext))); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresCollectionContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructuresContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HeightStructure))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ProbabilityAssessmentOutput))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(EmptyProbabilityAssessmentOutput))); @@ -156,7 +156,7 @@ // Assert Assert.AreEqual(1, importInfos.Length); - Assert.AreEqual(1, importInfos.Count(i => i.DataType == typeof(HeightStructuresCollectionContext))); + Assert.AreEqual(1, importInfos.Count(i => i.DataType == typeof(HeightStructuresContext))); } mocks.VerifyAll(); } @@ -172,7 +172,7 @@ // Assert Assert.AreEqual(1, importInfos.Length); - Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(HeightStructuresCollectionContext))); + Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(HeightStructuresContext))); } } } Fisheye: Tag dd72cf407b7d0e9284d101bb2e2854e569b1a29a refers to a dead (removed) revision in file `Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/ImportInfos/HeightStructureContextImportInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/ImportInfos/HeightStructuresContextImportInfoTest.cs =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/ImportInfos/HeightStructuresContextImportInfoTest.cs (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/ImportInfos/HeightStructuresContextImportInfoTest.cs (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -0,0 +1,189 @@ +// 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.Drawing; +using System.Linq; +using Core.Common.Base; +using Core.Common.Base.IO; +using Core.Common.Gui.Plugin; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.HeightStructures.Data; +using Ringtoets.HeightStructures.Forms.PresentationObjects; +using Ringtoets.HeightStructures.IO; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.HeightStructures.Plugin.Test.ImportInfos +{ + [TestFixture] + public class HeightStructuresContextImportInfoTest + { + [Test] + public void CreateFileImporter_Always_ExpectedPropertiesSet() + { + // Setup + var mocks = new MockRepository(); + ReferenceLine referenceLine = mocks.Stub(); + var assessmentSection = mocks.Stub(); + assessmentSection.ReferenceLine = referenceLine; + mocks.ReplayAll(); + + var list = new ObservableList(); + + var importTarget = new HeightStructuresContext(list, assessmentSection); + + using (var plugin = new HeightStructuresPlugin()) + { + ImportInfo importInfo = GetImportInfo(plugin); + + // Call + IFileImporter importer = importInfo.CreateFileImporter(importTarget, "test"); + + // Assert + Assert.IsInstanceOf(importer); + } + mocks.VerifyAll(); + } + + [Test] + public void Name_Always_ReturnExpectedName() + { + // Setup + using (var plugin = new HeightStructuresPlugin()) + { + ImportInfo importInfo = GetImportInfo(plugin); + + // Call + string name = importInfo.Name; + + // Assert + Assert.AreEqual("Kunstwerklocaties", name); + } + } + + [Test] + public void Category_Always_ReturnExpectedCategory() + { + // Setup + using (var plugin = new HeightStructuresPlugin()) + { + ImportInfo importInfo = GetImportInfo(plugin); + + // Call + string category = importInfo.Category; + + // Assert + Assert.AreEqual("Algemeen", category); + } + } + + [Test] + public void Image_Always_ReturnExpectedIcon() + { + // Setup + using (var plugin = new HeightStructuresPlugin()) + { + ImportInfo importInfo = GetImportInfo(plugin); + + // Call + Image image = importInfo.Image; + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.StructuresIcon, image); + } + } + + [Test] + public void FileFilter_Always_ReturnExpectedFileFilter() + { + // Setup + using (var plugin = new HeightStructuresPlugin()) + { + ImportInfo importInfo = GetImportInfo(plugin); + + // Call + string fileFilter = importInfo.FileFilter; + + // Assert + Assert.AreEqual("Shapebestand (*.shp)|*.shp", fileFilter); + } + } + + [Test] + public void IsEnabled_ReferenceLineSet_ReturnTrue() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + assessmentSection.ReferenceLine = new ReferenceLine(); + mocks.ReplayAll(); + + var list = new ObservableList(); + + var context = new HeightStructuresContext(list, assessmentSection); + + using (var plugin = new HeightStructuresPlugin()) + { + ImportInfo importInfo = GetImportInfo(plugin); + + // Call + bool isEnabled = importInfo.IsEnabled(context); + + // Assert + Assert.IsTrue(isEnabled); + } + mocks.VerifyAll(); + } + + [Test] + public void IsEnabled_ReferenceLineNotSet_ReturnFalse() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + assessmentSection.ReferenceLine = null; + mocks.ReplayAll(); + + var list = new ObservableList(); + + var context = new HeightStructuresContext(list, assessmentSection); + + using (var plugin = new HeightStructuresPlugin()) + { + ImportInfo importInfo = GetImportInfo(plugin); + + // Call + bool isEnabled = importInfo.IsEnabled(context); + + // Assert + Assert.IsFalse(isEnabled); + } + mocks.VerifyAll(); + } + + private static ImportInfo GetImportInfo(HeightStructuresPlugin plugin) + { + return plugin.GetImportInfos().First(ii => ii.DataType == typeof(HeightStructuresContext)); + } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/Ringtoets.HeightStructures.Plugin.Test.csproj =================================================================== diff -u -r423010168fe01b2373e9be55f047659911e670f5 -rdd72cf407b7d0e9284d101bb2e2854e569b1a29a --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/Ringtoets.HeightStructures.Plugin.Test.csproj (.../Ringtoets.HeightStructures.Plugin.Test.csproj) (revision 423010168fe01b2373e9be55f047659911e670f5) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/Ringtoets.HeightStructures.Plugin.Test.csproj (.../Ringtoets.HeightStructures.Plugin.Test.csproj) (revision dd72cf407b7d0e9284d101bb2e2854e569b1a29a) @@ -55,7 +55,7 @@ Properties\GlobalAssembly.cs - +