Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Data/HydraulicBoundaryLocation.cs =================================================================== diff -u -r27d670bb56639222f0faddadeeda390e855a7079 -r7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Data/HydraulicBoundaryLocation.cs (.../HydraulicBoundaryLocation.cs) (revision 27d670bb56639222f0faddadeeda390e855a7079) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Data/HydraulicBoundaryLocation.cs (.../HydraulicBoundaryLocation.cs) (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -27,7 +27,7 @@ namespace Ringtoets.HydraRing.Data { /// - /// Location of an hydraulic boundary. + /// Location of a hydraulic boundary. /// public class HydraulicBoundaryLocation : Observable, IStorable { Fisheye: Tag 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/DesignWaterLevelContextProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/DesignWaterLevelLocationsContextProperties.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/DesignWaterLevelLocationsContextProperties.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/DesignWaterLevelLocationsContextProperties.cs (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -0,0 +1,57 @@ +// 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.ComponentModel; +using System.Linq; +using Core.Common.Gui.Converters; +using Core.Common.Gui.PropertyBag; +using Core.Common.Utils.Attributes; +using Ringtoets.Common.Data.Properties; +using Ringtoets.HydraRing.Data; + +namespace Ringtoets.Integration.Forms.PropertyClasses +{ + /// + /// ViewModel of for properties panel. + /// + public class DesignWaterLevelLocationsContextProperties : ObjectProperties + { + /// + /// Gets the from the . + /// + [TypeConverter(typeof(ExpandableArrayConverter))] + [ResourcesCategory(typeof(Resources), "Categories_General")] + [ResourcesDisplayName(typeof(Properties.Resources), "HydraulicBoundaryDatabase_Locations_DisplayName")] + [ResourcesDescription(typeof(Properties.Resources), "HydraulicBoundaryDatabase_Locations_Description")] + public HydraulicBoundaryLocationDesignWaterLevelProperties[] Locations + { + get + { + return data != null + ? data.Locations.Select(loc => new HydraulicBoundaryLocationDesignWaterLevelProperties + { + Data = loc + }).ToArray() + : new HydraulicBoundaryLocationDesignWaterLevelProperties[0]; + } + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryLocationDesignWaterLevelProperties.cs =================================================================== diff -u -r5b46971d57aa713831894a0038510017b0c1e3c3 -r7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryLocationDesignWaterLevelProperties.cs (.../HydraulicBoundaryLocationDesignWaterLevelProperties.cs) (revision 5b46971d57aa713831894a0038510017b0c1e3c3) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryLocationDesignWaterLevelProperties.cs (.../HydraulicBoundaryLocationDesignWaterLevelProperties.cs) (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -33,12 +33,6 @@ /// public class HydraulicBoundaryLocationDesignWaterLevelProperties : HydraulicBoundaryLocationProperties { - /// - /// New instance of . - /// - /// whose data will be used for the properties panel. - public HydraulicBoundaryLocationDesignWaterLevelProperties(HydraulicBoundaryLocation hydraulicBoundaryLocationContext) : base(hydraulicBoundaryLocationContext) {} - [PropertyOrder(1)] public override long Id { Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryLocationProperties.cs =================================================================== diff -u -r7779966cdf2cc1cbaf00ce0643da3f47f34fa0af -r7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryLocationProperties.cs (.../HydraulicBoundaryLocationProperties.cs) (revision 7779966cdf2cc1cbaf00ce0643da3f47f34fa0af) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryLocationProperties.cs (.../HydraulicBoundaryLocationProperties.cs) (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -36,15 +36,6 @@ public class HydraulicBoundaryLocationProperties : ObjectProperties { /// - /// New instance of . - /// - /// whose data will be used for the properties panel. - public HydraulicBoundaryLocationProperties(HydraulicBoundaryLocation hydraulicBoundaryLocation) - { - data = hydraulicBoundaryLocation; - } - - /// /// Gets the . /// [PropertyOrder(1)] Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryLocationWaveHeightProperties.cs =================================================================== diff -u -r9b1a62101363da493c64bed7bd26cb97ab03a308 -r7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryLocationWaveHeightProperties.cs (.../HydraulicBoundaryLocationWaveHeightProperties.cs) (revision 9b1a62101363da493c64bed7bd26cb97ab03a308) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryLocationWaveHeightProperties.cs (.../HydraulicBoundaryLocationWaveHeightProperties.cs) (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -33,12 +33,6 @@ /// public class HydraulicBoundaryLocationWaveHeightProperties : HydraulicBoundaryLocationProperties { - /// - /// New instance of . - /// - /// whose data will be used for the properties panel. - public HydraulicBoundaryLocationWaveHeightProperties(HydraulicBoundaryLocation hydraulicBoundaryLocation) : base(hydraulicBoundaryLocation) {} - [PropertyOrder(1)] public override long Id { Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/WaveHeightContextProperties.cs =================================================================== diff -u -rf7b5ed585321bbc2249ec9c8ecd8af7f9eb1808a -r7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/WaveHeightContextProperties.cs (.../WaveHeightContextProperties.cs) (revision f7b5ed585321bbc2249ec9c8ecd8af7f9eb1808a) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/WaveHeightContextProperties.cs (.../WaveHeightContextProperties.cs) (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -46,7 +46,10 @@ get { return data != null - ? data.Locations.Select(loc => new HydraulicBoundaryLocationWaveHeightProperties(loc)).ToArray() + ? data.Locations.Select(loc => new HydraulicBoundaryLocationWaveHeightProperties + { + Data = loc + }).ToArray() : new HydraulicBoundaryLocationWaveHeightProperties[0]; } } Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj =================================================================== diff -u -r5b46971d57aa713831894a0038510017b0c1e3c3 -r7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 5b46971d57aa713831894a0038510017b0c1e3c3) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -58,7 +58,7 @@ - + Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationDesignWaterLevelRow.cs =================================================================== diff -u -r5b46971d57aa713831894a0038510017b0c1e3c3 -r7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationDesignWaterLevelRow.cs (.../HydraulicBoundaryLocationDesignWaterLevelRow.cs) (revision 5b46971d57aa713831894a0038510017b0c1e3c3) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationDesignWaterLevelRow.cs (.../HydraulicBoundaryLocationDesignWaterLevelRow.cs) (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -27,7 +27,7 @@ namespace Ringtoets.Integration.Forms.Views { /// - /// This class represents a row of . + /// This class represents a row of . /// internal class HydraulicBoundaryLocationDesignWaterLevelRow { @@ -36,7 +36,7 @@ /// /// Creates a new instance of . /// - /// The for this row. + /// The for this row. /// Thrown when is null. internal HydraulicBoundaryLocationDesignWaterLevelRow(HydraulicBoundaryLocation hydraulicBoundaryLocation) { @@ -92,6 +92,9 @@ } } + /// + /// Gets the . + /// public HydraulicBoundaryLocation HydraulicBoundaryLocation { get Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationDesignWaterLevelsView.cs =================================================================== diff -u -r27014b59b58198c1ff843949292fcbe4f60f6916 -r7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationDesignWaterLevelsView.cs (.../HydraulicBoundaryLocationDesignWaterLevelsView.cs) (revision 27014b59b58198c1ff843949292fcbe4f60f6916) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/HydraulicBoundaryLocationDesignWaterLevelsView.cs (.../HydraulicBoundaryLocationDesignWaterLevelsView.cs) (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -23,22 +23,25 @@ using System.Windows.Forms; using Core.Common.Base; using Core.Common.Controls.Views; +using Core.Common.Gui.Selection; using Core.Common.Utils.Reflection; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.HydraRing.Data; +using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Forms.Properties; namespace Ringtoets.Integration.Forms.Views { /// /// View for the with . /// - public partial class HydraulicBoundaryLocationDesignWaterLevelsView : UserControl, IView + public partial class HydraulicBoundaryLocationDesignWaterLevelsView : UserControl, ISelectionProvider { private readonly Observer assessmentSectionObserver; private readonly Observer hydraulicBoundaryDatabaseObserver; private IAssessmentSection assessmentSection; private HydraulicBoundaryDatabase hydraulicBoundaryDatabase; + private bool updatingDataSource; /// /// Creates a new instance of . @@ -89,6 +92,8 @@ assessmentSectionObserver.Dispose(); hydraulicBoundaryDatabaseObserver.Dispose(); + dataGridViewControl.RemoveCellClickHandler(DataGridViewOnCellClick); + if (disposing && (components != null)) { components.Dispose(); @@ -99,6 +104,8 @@ private void InitializeDataGridView() { + dataGridViewControl.AddCellClickHandler(DataGridViewOnCellClick); + dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Name), Resources.HydraulicBoundaryDatabase_Locations_Id_DisplayName); dataGridViewControl.AddTextBoxColumn(TypeUtils.GetMemberName(row => row.Id), @@ -111,10 +118,67 @@ private void UpdateDataGridViewDataSource() { + updatingDataSource = true; dataGridViewControl.SetDataSource(hydraulicBoundaryDatabase != null ? hydraulicBoundaryDatabase.Locations.Select(hl => new HydraulicBoundaryLocationDesignWaterLevelRow(hl)).ToArray() : null); dataGridViewControl.RefreshDataGridView(); + updatingDataSource = false; } + + /// + /// Gets or sets the . + /// + public IApplicationSelection ApplicationSelection { get; set; } + + public object Selection + { + get + { + return CreateSelectedItemFromCurrentRow(); + } + } + + #region Event handling + + private void DataGridViewOnCellClick(object sender, DataGridViewCellEventArgs e) + { + if (updatingDataSource) + { + return; + } + + UpdateApplicationSelection(); + } + + private void UpdateApplicationSelection() + { + if (ApplicationSelection == null) + { + return; + } + + DesignWaterLevelLocationContext selection = CreateSelectedItemFromCurrentRow(); + if ((ApplicationSelection.Selection == null && selection != null) || + (ApplicationSelection.Selection != null && !ApplicationSelection.Selection.Equals(selection))) + { + ApplicationSelection.Selection = selection; + } + } + + private DesignWaterLevelLocationContext CreateSelectedItemFromCurrentRow() + { + var currentRow = dataGridViewControl.GetCurrentRow(); + + var designWaterLevelRow = currentRow != null + ? (HydraulicBoundaryLocationDesignWaterLevelRow)currentRow.DataBoundItem + : null; + + return designWaterLevelRow != null + ? new DesignWaterLevelLocationContext(designWaterLevelRow.HydraulicBoundaryLocation) + : null; + } + + #endregion } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -r5b46971d57aa713831894a0038510017b0c1e3c3 -r7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 5b46971d57aa713831894a0038510017b0c1e3c3) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -256,10 +256,14 @@ yield return new PropertyInfo, CalculationGroupContextProperties>(); yield return new PropertyInfo, CalculationContextProperties>(); yield return new PropertyInfo(); - yield return new PropertyInfo + yield return new PropertyInfo { GetObjectPropertiesData = context => context.WrappedData.HydraulicBoundaryDatabase }; + yield return new PropertyInfo + { + GetObjectPropertiesData = context => context.WrappedData + }; yield return new PropertyInfo { GetObjectPropertiesData = context => context.WrappedData.HydraulicBoundaryDatabase @@ -291,7 +295,11 @@ AdditionalDataCheck = context => context.WrappedData.HydraulicBoundaryDatabase != null, Image = RingtoetsCommonFormsResources.GenericInputOutputIcon, CloseForData = CloseHydraulicBoundaryLocationsViewForData, - AfterCreate = (view, context) => { view.AssessmentSection = context.WrappedData; } + AfterCreate = (view, context) => + { + view.ApplicationSelection = Gui; + view.AssessmentSection = context.WrappedData; + } }; yield return new ViewInfo Fisheye: Tag 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/DesignWaterLevelContextPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/DesignWaterLevelLocationsContextPropertiesTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/DesignWaterLevelLocationsContextPropertiesTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/DesignWaterLevelLocationsContextPropertiesTest.cs (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -0,0 +1,121 @@ +// 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.ComponentModel; +using System.Globalization; +using System.Linq; +using Core.Common.Gui.Converters; +using Core.Common.Gui.PropertyBag; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.HydraRing.Data; +using Ringtoets.Integration.Forms.PresentationObjects; +using Ringtoets.Integration.Forms.PropertyClasses; + +namespace Ringtoets.Integration.Forms.Test.PropertyClasses +{ + [TestFixture] + public class DesignWaterLevelLocationsContextPropertiesTest + { + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + var properties = new DesignWaterLevelLocationsContextProperties(); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.IsNull(properties.Data); + } + + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSectionMock = mockRepository.Stub(); + mockRepository.ReplayAll(); + + HydraulicBoundaryDatabase hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + DesignWaterLevelLocationsContext designWaterLevelLocationsContext = new DesignWaterLevelLocationsContext(assessmentSectionMock) + { + WrappedData = + { + HydraulicBoundaryDatabase = hydraulicBoundaryDatabase + } + }; + + const double designWaterLevel = 12.34; + HydraulicBoundaryLocation hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "name", 1.0, 2.0) + { + DesignWaterLevel = designWaterLevel + }; + designWaterLevelLocationsContext.WrappedData.HydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryLocation); + + // Call + DesignWaterLevelLocationsContextProperties properties = new DesignWaterLevelLocationsContextProperties + { + Data = hydraulicBoundaryDatabase + }; + + // Assert + CollectionAssert.AllItemsAreInstancesOfType(properties.Locations, typeof(HydraulicBoundaryLocationDesignWaterLevelProperties)); + Assert.AreEqual(1, properties.Locations.Length); + + HydraulicBoundaryLocationDesignWaterLevelProperties designWaterLevelLocationProperties = properties.Locations.First(); + Assert.AreEqual(hydraulicBoundaryLocation.Name, designWaterLevelLocationProperties.Name); + Assert.AreEqual(hydraulicBoundaryLocation.Id, designWaterLevelLocationProperties.Id); + Assert.AreEqual(hydraulicBoundaryLocation.Location, designWaterLevelLocationProperties.Location); + var expectedDesignWaterLevelValue = designWaterLevel.ToString("F2", CultureInfo.InvariantCulture); + Assert.AreEqual(expectedDesignWaterLevelValue, designWaterLevelLocationProperties.DesignWaterLevel); + mockRepository.VerifyAll(); + } + + [Test] + public void PropertyAttributes_ReturnExpectedValues() + { + // Setup + var properties = new DesignWaterLevelLocationsContextProperties(); + + var dynamicPropertyBag = new DynamicPropertyBag(properties); + const string expectedLocationsDisplayName = "Locaties"; + const string expectedLocationsDescription = "Locaties uit de hydraulische randvoorwaardendatabase."; + const string expectedLocationsCategory = "Algemeen"; + + // Call + TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); + + // Assert + PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(); + PropertyDescriptor locationsProperty = dynamicProperties.Find("Locations", false); + + Assert.IsInstanceOf(classTypeConverter); + Assert.IsNotNull(locationsProperty); + Assert.IsInstanceOf(locationsProperty.Converter); + Assert.IsTrue(locationsProperty.IsReadOnly); + Assert.IsTrue(locationsProperty.IsBrowsable); + Assert.AreEqual(expectedLocationsDisplayName, locationsProperty.DisplayName); + Assert.AreEqual(expectedLocationsDescription, locationsProperty.Description); + Assert.AreEqual(expectedLocationsCategory, locationsProperty.Category); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/HydraulicBoundaryLocationDesignWaterLevelPropertiesTest.cs =================================================================== diff -u -rec29001a9e148ed508108e4fd64c2bc751a6c026 -r7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/HydraulicBoundaryLocationDesignWaterLevelPropertiesTest.cs (.../HydraulicBoundaryLocationDesignWaterLevelPropertiesTest.cs) (revision ec29001a9e148ed508108e4fd64c2bc751a6c026) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/HydraulicBoundaryLocationDesignWaterLevelPropertiesTest.cs (.../HydraulicBoundaryLocationDesignWaterLevelPropertiesTest.cs) (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -46,7 +46,10 @@ // Call HydraulicBoundaryLocationDesignWaterLevelProperties properties = - new HydraulicBoundaryLocationDesignWaterLevelProperties(hydraulicBoundaryLocation); + new HydraulicBoundaryLocationDesignWaterLevelProperties + { + Data = hydraulicBoundaryLocation + }; // Assert Assert.AreEqual(id, properties.Id); @@ -73,7 +76,10 @@ // Call HydraulicBoundaryLocationDesignWaterLevelProperties properties = - new HydraulicBoundaryLocationDesignWaterLevelProperties(hydraulicBoundaryLocation); + new HydraulicBoundaryLocationDesignWaterLevelProperties + { + Data = hydraulicBoundaryLocation + }; // Assert Assert.AreEqual(id, properties.Id); @@ -90,7 +96,10 @@ // Setup HydraulicBoundaryLocation hydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, "", 0.0, 0.0); HydraulicBoundaryLocationDesignWaterLevelProperties properties = - new HydraulicBoundaryLocationDesignWaterLevelProperties(hydraulicBoundaryLocation); + new HydraulicBoundaryLocationDesignWaterLevelProperties + { + Data = hydraulicBoundaryLocation + }; // Call TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/HydraulicBoundaryLocationPropertiesTest.cs =================================================================== diff -u -r48421e138d2217a83dfb53956c74abe593e8df1a -r7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/HydraulicBoundaryLocationPropertiesTest.cs (.../HydraulicBoundaryLocationPropertiesTest.cs) (revision 48421e138d2217a83dfb53956c74abe593e8df1a) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/HydraulicBoundaryLocationPropertiesTest.cs (.../HydraulicBoundaryLocationPropertiesTest.cs) (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -50,7 +50,10 @@ mockRepository.ReplayAll(); // Call - TestDelegate test = () => new HydraulicBoundaryLocationProperties(hydraulicBoundaryLocationMock); + TestDelegate test = () => new HydraulicBoundaryLocationProperties + { + Data = hydraulicBoundaryLocationMock + }; // Assert Assert.DoesNotThrow(test); @@ -72,7 +75,10 @@ mockRepository.ReplayAll(); // Call - HydraulicBoundaryLocationProperties hydraulicBoundaryLocationProperties = new HydraulicBoundaryLocationProperties(hydraulicBoundaryLocationMock); + HydraulicBoundaryLocationProperties hydraulicBoundaryLocationProperties = new HydraulicBoundaryLocationProperties + { + Data = hydraulicBoundaryLocationMock + }; // Assert Assert.AreEqual(id, hydraulicBoundaryLocationProperties.Id); @@ -104,7 +110,10 @@ var expectedString = string.Format("{0} {1}", name, new Point2D(x, y)); // Call - HydraulicBoundaryLocationProperties hydraulicBoundaryLocationProperties = new HydraulicBoundaryLocationProperties(hydraulicBoundaryLocationMock); + HydraulicBoundaryLocationProperties hydraulicBoundaryLocationProperties = new HydraulicBoundaryLocationProperties + { + Data = hydraulicBoundaryLocationMock + }; // Assert Assert.AreEqual(expectedString, hydraulicBoundaryLocationProperties.ToString()); @@ -118,7 +127,10 @@ var hydraulicBoundaryLocationMock = mockRepository.StrictMock(0, "", 0.0, 0.0); mockRepository.ReplayAll(); - var hydraulicBoundaryLocationProperties = new HydraulicBoundaryLocationProperties(hydraulicBoundaryLocationMock); + var hydraulicBoundaryLocationProperties = new HydraulicBoundaryLocationProperties + { + Data = hydraulicBoundaryLocationMock + }; var dynamicPropertyBag = new DynamicPropertyBag(hydraulicBoundaryLocationProperties); const string expectedIdDisplayName = "ID"; @@ -136,7 +148,7 @@ PropertyDescriptor idProperty = dynamicProperties.Find("Id", false); PropertyDescriptor nameProperty = dynamicProperties.Find("Name", false); PropertyDescriptor locationProperty = dynamicProperties.Find("Location", false); - + Assert.IsInstanceOf(classTypeConverter); Assert.IsNotNull(idProperty); Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/HydraulicBoundaryLocationWaveHeightPropertiesTest.cs =================================================================== diff -u -r8ace1c4a8d008b6293faa1f842e1bf17f5634b67 -r7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/HydraulicBoundaryLocationWaveHeightPropertiesTest.cs (.../HydraulicBoundaryLocationWaveHeightPropertiesTest.cs) (revision 8ace1c4a8d008b6293faa1f842e1bf17f5634b67) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/HydraulicBoundaryLocationWaveHeightPropertiesTest.cs (.../HydraulicBoundaryLocationWaveHeightPropertiesTest.cs) (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -46,7 +46,10 @@ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(id, name, x, y); // Call - var properties = new HydraulicBoundaryLocationWaveHeightProperties(hydraulicBoundaryLocation); + var properties = new HydraulicBoundaryLocationWaveHeightProperties + { + Data = hydraulicBoundaryLocation + }; // Assert Assert.AreEqual(id, properties.Id); @@ -72,7 +75,10 @@ }; // Call - var properties = new HydraulicBoundaryLocationWaveHeightProperties(hydraulicBoundaryLocation); + var properties = new HydraulicBoundaryLocationWaveHeightProperties + { + Data = hydraulicBoundaryLocation + }; // Assert Assert.AreEqual(id, properties.Id); @@ -88,7 +94,10 @@ { // Setup var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, "", 0.0, 0.0); - var properties = new HydraulicBoundaryLocationWaveHeightProperties(hydraulicBoundaryLocation); + var properties = new HydraulicBoundaryLocationWaveHeightProperties + { + Data = hydraulicBoundaryLocation + }; // Call TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); Fisheye: Tag 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyInfos/DesignWaterLevelContextPropertyInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyInfos/DesignWaterLevelLocationsContextPropertyInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyInfos/DesignWaterLevelLocationsContextPropertyInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyInfos/DesignWaterLevelLocationsContextPropertyInfoTest.cs (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -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.Linq; +using Core.Common.Gui.Plugin; +using NUnit.Framework; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.HydraRing.Data; +using Ringtoets.Integration.Data; +using Ringtoets.Integration.Forms.PresentationObjects; +using Ringtoets.Integration.Forms.PropertyClasses; +using Ringtoets.Integration.Plugin; + +namespace Ringtoets.Integration.Forms.Test.PropertyInfos +{ + [TestFixture] + public class DesignWaterLevelLocationsContextPropertyInfoTest + { + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + using (RingtoetsPlugin plugin = new RingtoetsPlugin()) + { + PropertyInfo info = GetInfo(plugin); + + // Call + Type propertyObjectType = info.PropertyObjectType; + + // Assert + Assert.AreEqual(typeof(DesignWaterLevelLocationsContextProperties), propertyObjectType); + } + } + + [Test] + public void GetObjectPropertiesData_Always_ReturnsHydraulicBoundaryDatabase() + { + // Setup + AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase() + }; + + DesignWaterLevelLocationsContext context = new DesignWaterLevelLocationsContext(assessmentSection); + + using (RingtoetsPlugin plugin = new RingtoetsPlugin()) + { + PropertyInfo info = GetInfo(plugin); + + // Call + var objectPropertiesData = info.GetObjectPropertiesData(context); + + // Assert + Assert.AreSame(assessmentSection.HydraulicBoundaryDatabase, objectPropertiesData); + } + } + + private static PropertyInfo GetInfo(RingtoetsPlugin plugin) + { + return plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(DesignWaterLevelLocationsContext)); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj =================================================================== diff -u -r5b46971d57aa713831894a0038510017b0c1e3c3 -r7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 5b46971d57aa713831894a0038510017b0c1e3c3) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -70,7 +70,7 @@ - + @@ -79,14 +79,15 @@ - + - + + Fisheye: Tag 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DesignWaterLevelContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DesignWaterLevelLocationContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DesignWaterLevelLocationContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DesignWaterLevelLocationContextTreeNodeInfoTest.cs (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -0,0 +1,28 @@ +// 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. + +namespace Ringtoets.Integration.Forms.Test.TreeNodeInfos +{ + public class DesignWaterLevelLocationContextTreeNodeInfoTest + { + + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -0,0 +1,332 @@ +// 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.Drawing; +using System.Linq; +using System.Windows.Forms; +using Core.Common.Controls.TreeView; +using Core.Common.Gui; +using Core.Common.Gui.ContextMenu; +using Core.Common.Gui.TestUtil.ContextMenu; +using Core.Common.TestUtil; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.HydraRing.Data; +using Ringtoets.Integration.Data; +using Ringtoets.Integration.Forms.PresentationObjects; +using Ringtoets.Integration.Plugin; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Forms.Test.TreeNodeInfos +{ + [TestFixture] + public class DesignWaterLevelLocationsContextTreeNodeInfoTest : NUnitFormTest + { + private MockRepository mockRepository; + + [SetUp] + public void SetUp() + { + mockRepository = new MockRepository(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new RingtoetsPlugin()) + { + var info = GetInfo(plugin); + + // Assert + Assert.AreEqual(typeof(DesignWaterLevelLocationsContext), info.TagType); + 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); + Assert.IsNull(info.EnsureVisibleOnCreate); + Assert.IsNull(info.ChildNodeObjects); + Assert.IsNull(info.CanRename); + Assert.IsNull(info.OnNodeRenamed); + Assert.IsNull(info.CanRemove); + Assert.IsNull(info.OnNodeRemoved); + } + } + + [Test] + public void Text_Always_ReturnsSetName() + { + // Setup + using (var plugin = new RingtoetsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + + // Call + var text = info.Text(null); + + // Assert + Assert.AreEqual("Toetspeilen", text); + } + } + + [Test] + public void Image_Always_ReturnsGenericIcon() + { + // Setup + using (var plugin = new RingtoetsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + + // Call + var image = info.Image(null); + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, image); + } + } + + [Test] + public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() + { + // Setup + var guiMock = mockRepository.StrictMock(); + var menuBuilderMock = mockRepository.StrictMock(); + var assessmentSectionMock = mockRepository.Stub(); + + var nodeData = new DesignWaterLevelLocationsContext(assessmentSectionMock); + + menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.Build()).Return(null); + guiMock.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + guiMock.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilderMock); + + mockRepository.ReplayAll(); + + using (var plugin = new RingtoetsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + + plugin.Gui = guiMock; + + // Call + info.ContextMenuStrip(nodeData, null, treeViewControl); + } + } + // Assert + mockRepository.VerifyAll(); + } + + [Test] + public void ContextMenuStrip_NoHydraulicBoundaryDatabaseSet_ContextMenuItemBerekenenDisabled() + { + // Setup + var guiMock = mockRepository.StrictMock(); + var assessmentSectionMock = mockRepository.Stub(); + + var nodeData = new DesignWaterLevelLocationsContext(assessmentSectionMock); + + guiMock.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + guiMock.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + mockRepository.ReplayAll(); + + using (var plugin = new RingtoetsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + + plugin.Gui = guiMock; + + // Call + ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl); + + // Assert + const string expectedItemText = "&Berekenen"; + const string expectedItemTooltip = "Er is geen hydraulische randvoorwaardendatabase beschikbaar om de toetspeilen te berekenen."; + + TestHelper.AssertContextMenuStripContainsItem(contextMenu, 0, expectedItemText, expectedItemTooltip, RingtoetsCommonFormsResources.FailureMechanismIcon, false); + } + } + + mockRepository.VerifyAll(); // Expect no calls on arguments + } + + [Test] + public void ContextMenuStrip_HydraulicBoundaryDatabaseSet_ContextMenuItemBerekenenEnabled() + { + // Setup + var guiMock = mockRepository.StrictMock(); + var assessmentSectionMock = mockRepository.Stub(); + + var nodeData = new DesignWaterLevelLocationsContext(assessmentSectionMock); + nodeData.WrappedData.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + guiMock.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + guiMock.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + mockRepository.ReplayAll(); + + using (var plugin = new RingtoetsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + + plugin.Gui = guiMock; + + // Call + ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl); + + // Assert + const string expectedItemText = "&Berekenen"; + const string expectedItemTooltip = "Bereken de toetspeilen."; + + TestHelper.AssertContextMenuStripContainsItem(contextMenu, 0, expectedItemText, expectedItemTooltip, RingtoetsCommonFormsResources.FailureMechanismIcon); + } + } + + mockRepository.VerifyAll(); // Expect no calls on arguments + } + + [Test] + public void GivenHydraulicBoundaryDatabaseWithNonExistingFilePath_WhenCalculatingAssessmentLevelFromContextMenu_ThenLogMessagesAddedPreviousOutputNotAffected() + { + // Given + var guiMock = mockRepository.DynamicMock(); + var contextMenuRunAssessmentLevelCalculationsIndex = 0; + + var hydraulicBoundaryLocation1 = new HydraulicBoundaryLocation(100001, "", 1.1, 2.2); + var hydraulicBoundaryLocation2 = new HydraulicBoundaryLocation(100002, "", 3.3, 4.4) + { + DesignWaterLevel = 4.2 + }; + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + Locations = + { + hydraulicBoundaryLocation1, + hydraulicBoundaryLocation2 + }, + FilePath = "D:/nonExistingDirectory/nonExistingFile", + Version = "random" + }; + + var assessmentSectionMock = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = hydraulicBoundaryDatabase + }; + var designWaterLevelContext = new DesignWaterLevelLocationsContext(assessmentSectionMock); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(cmp => cmp.Get(designWaterLevelContext, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + + mockRepository.ReplayAll(); + + using (var plugin = new RingtoetsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + plugin.Gui = guiMock; + + ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(designWaterLevelContext, null, treeViewControl); + + // When + Action action = () => { contextMenuAdapter.Items[contextMenuRunAssessmentLevelCalculationsIndex].PerformClick(); }; + + // Then + string message = string.Format("Berekeningen konden niet worden gestart. Fout bij het lezen van bestand '{0}': Het bestand bestaat niet.", + hydraulicBoundaryDatabase.FilePath); + TestHelper.AssertLogMessageWithLevelIsGenerated(action, new Tuple(message, LogLevelConstant.Error)); + + Assert.IsNaN(hydraulicBoundaryLocation1.DesignWaterLevel); // No result set + Assert.AreEqual(4.2, hydraulicBoundaryLocation2.DesignWaterLevel); // Previous result not cleared + } + } + mockRepository.VerifyAll(); + } + + [Test] + public void ForeColor_ContextHasNoHydraulicBoundaryDatabase_ReturnDisabledColor() + { + // Setup + var assessmentSectionMock = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var designWaterLevelContext = new DesignWaterLevelLocationsContext(assessmentSectionMock); + + using (var plugin = new RingtoetsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + + // Call + Color color = info.ForeColor(designWaterLevelContext); + + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color); + } + mockRepository.VerifyAll(); + } + + [Test] + public void ForeColor_ContextHasHydraulicBoundaryDatabase_ReturnControlColor() + { + // Setup + var assessmentSectionMock = mockRepository.Stub(); + assessmentSectionMock.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + mockRepository.ReplayAll(); + + var designWaterLevelContext = new DesignWaterLevelLocationsContext(assessmentSectionMock); + + using (var plugin = new RingtoetsPlugin()) + { + TreeNodeInfo info = GetInfo(plugin); + + // Call + Color color = info.ForeColor(designWaterLevelContext); + + // Assert + Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color); + } + mockRepository.VerifyAll(); + } + + private static TreeNodeInfo GetInfo(RingtoetsPlugin plugin) + { + return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(DesignWaterLevelLocationsContext)); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs =================================================================== diff -u -r5b46971d57aa713831894a0038510017b0c1e3c3 -r7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 5b46971d57aa713831894a0038510017b0c1e3c3) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 7cb21cb8c5e2a67bf24b9e2858ef861a15ee537e) @@ -196,7 +196,7 @@ PropertyInfo[] propertyInfos = plugin.GetPropertyInfos().ToArray(); // Assert - Assert.AreEqual(9, propertyInfos.Length); + Assert.AreEqual(10, propertyInfos.Length); var ringtoetsProjectProperties = propertyInfos.Single(pi => pi.DataType == typeof(IProject)); Assert.AreEqual(typeof(RingtoetsProjectProperties), ringtoetsProjectProperties.PropertyObjectType); @@ -240,12 +240,18 @@ Assert.IsNull(outputContextProperties.GetObjectPropertiesData); Assert.IsNull(outputContextProperties.AfterCreate); - var designWaterLevelContextProperties = propertyInfos.Single(pi => pi.DataType == typeof(DesignWaterLevelLocationsContext)); - Assert.AreEqual(typeof(DesignWaterLevelContextProperties), designWaterLevelContextProperties.PropertyObjectType); - Assert.IsNull(designWaterLevelContextProperties.AdditionalDataCheck); - Assert.IsNotNull(designWaterLevelContextProperties.GetObjectPropertiesData); - Assert.IsNull(designWaterLevelContextProperties.AfterCreate); + var designWaterLevelLocationsContextProperties = propertyInfos.Single(pi => pi.DataType == typeof(DesignWaterLevelLocationsContext)); + Assert.AreEqual(typeof(DesignWaterLevelLocationsContextProperties), designWaterLevelLocationsContextProperties.PropertyObjectType); + Assert.IsNull(designWaterLevelLocationsContextProperties.AdditionalDataCheck); + Assert.IsNotNull(designWaterLevelLocationsContextProperties.GetObjectPropertiesData); + Assert.IsNull(designWaterLevelLocationsContextProperties.AfterCreate); + var designWaterLevelLocationContextProperties = propertyInfos.Single(pi => pi.DataType == typeof(DesignWaterLevelLocationContext)); + Assert.AreEqual(typeof(HydraulicBoundaryLocationDesignWaterLevelProperties), designWaterLevelLocationContextProperties.PropertyObjectType); + Assert.IsNull(designWaterLevelLocationContextProperties.AdditionalDataCheck); + Assert.IsNotNull(designWaterLevelLocationContextProperties.GetObjectPropertiesData); + Assert.IsNull(designWaterLevelLocationContextProperties.AfterCreate); + var waveHeightContextProperties = propertyInfos.Single(pi => pi.DataType == typeof(WaveHeightContext)); Assert.AreEqual(typeof(WaveHeightContextProperties), waveHeightContextProperties.PropertyObjectType); Assert.IsNull(waveHeightContextProperties.AdditionalDataCheck); @@ -288,9 +294,9 @@ Assert.AreEqual(typeof(FailureMechanismContributionView), contributionViewInfo.ViewType); TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.FailureMechanismContributionIcon, contributionViewInfo.Image); - var designWaterLevelsViewInfo = viewInfos.Single(vi => vi.DataType == typeof(DesignWaterLevelLocationsContext)); - Assert.AreEqual(typeof(HydraulicBoundaryLocationDesignWaterLevelsView), designWaterLevelsViewInfo.ViewType); - TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, designWaterLevelsViewInfo.Image); + var designWaterLevelLocationsViewInfo = viewInfos.Single(vi => vi.DataType == typeof(DesignWaterLevelLocationsContext)); + Assert.AreEqual(typeof(HydraulicBoundaryLocationDesignWaterLevelsView), designWaterLevelLocationsViewInfo.ViewType); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, designWaterLevelLocationsViewInfo.Image); var mapViewInfo = viewInfos.Single(vi => vi.DataType == typeof(IAssessmentSection)); Assert.AreEqual(typeof(AssessmentSectionView), mapViewInfo.ViewType);