Fisheye: Tag bd9857561de05958b06f90ef92f317415d568d9d refers to a dead (removed) revision in file `Riskeer/Integration/src/Riskeer.Integration.Forms/PropertyClasses/HydraulicBoundaryDataProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Integration/src/Riskeer.Integration.Forms/PropertyClasses/HydraulicLocationConfigurationDatabaseProperties.cs =================================================================== diff -u --- Riskeer/Integration/src/Riskeer.Integration.Forms/PropertyClasses/HydraulicLocationConfigurationDatabaseProperties.cs (revision 0) +++ Riskeer/Integration/src/Riskeer.Integration.Forms/PropertyClasses/HydraulicLocationConfigurationDatabaseProperties.cs (revision bd9857561de05958b06f90ef92f317415d568d9d) @@ -0,0 +1,183 @@ +// Copyright (C) Stichting Deltares 2022. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Util.Attributes; +using Core.Gui.Attributes; +using Core.Gui.PropertyBag; +using Riskeer.Common.Data.Hydraulics; +using Riskeer.Integration.Forms.Properties; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.Integration.Forms.PropertyClasses +{ + /// + /// ViewModel of for properties panel. + /// + public class HydraulicLocationConfigurationDatabaseProperties : ObjectProperties + { + private const int hlcdFilePathPropertyIndex = 0; + private const int scenarioNamePropertyIndex = 1; + private const int yearPropertyIndex = 2; + private const int scopePropertyIndex = 3; + private const int seaLevelPropertyIndex = 4; + private const int riverDischargePropertyIndex = 5; + private const int lakeLevelPropertyIndex = 6; + private const int windDirectionPropertyIndex = 7; + private const int windSpeedPropertyIndex = 8; + private const int commentPropertyIndex = 9; + + /// + /// Creates a new instance of . + /// + /// The hydraulic boundary data to show the properties for. + /// Thrown when is null. + public HydraulicLocationConfigurationDatabaseProperties(HydraulicBoundaryData hydraulicBoundaryData) + { + if (hydraulicBoundaryData == null) + { + throw new ArgumentNullException(nameof(hydraulicBoundaryData)); + } + + Data = hydraulicBoundaryData; + } + + [PropertyOrder(hlcdFilePathPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_FilePath_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_FilePath_Description))] + public string HlcdFilePath + { + get + { + return data.HydraulicLocationConfigurationDatabase.FilePath ?? string.Empty; + } + } + + [PropertyOrder(scenarioNamePropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_ScenarioName_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_ScenarioName_Description))] + public string ScenarioName + { + get + { + return data.HydraulicLocationConfigurationDatabase.ScenarioName ?? string.Empty; + } + } + + [PropertyOrder(yearPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_Year_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_Year_Description))] + public string Year + { + get + { + return data.HydraulicLocationConfigurationDatabase.Year.ToString(); + } + } + + [PropertyOrder(scopePropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_Scope_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_Scope_Description))] + public string Scope + { + get + { + return data.HydraulicLocationConfigurationDatabase.Scope ?? string.Empty; + } + } + + [PropertyOrder(seaLevelPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_SeaLevel_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_SeaLevel_Description))] + public string SeaLevel + { + get + { + return data.HydraulicLocationConfigurationDatabase.SeaLevel ?? string.Empty; + } + } + + [PropertyOrder(riverDischargePropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_RiverDischarge_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_RiverDischarge_Description))] + public string RiverDischarge + { + get + { + return data.HydraulicLocationConfigurationDatabase.RiverDischarge ?? string.Empty; + } + } + + [PropertyOrder(lakeLevelPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_LakeLevel_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_LakeLevel_Description))] + public string LakeLevel + { + get + { + return data.HydraulicLocationConfigurationDatabase.LakeLevel ?? string.Empty; + } + } + + [PropertyOrder(windDirectionPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_WindDirection_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_WindDirection_Description))] + public string WindDirection + { + get + { + return data.HydraulicLocationConfigurationDatabase.WindDirection ?? string.Empty; + } + } + + [PropertyOrder(windSpeedPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_WindSpeed_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_WindSpeed_Description))] + public string WindSpeed + { + get + { + return data.HydraulicLocationConfigurationDatabase.WindSpeed ?? string.Empty; + } + } + + [PropertyOrder(commentPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_Comment_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.HydraulicLocationConfigurationDatabase_Comment_Description))] + public string Comment + { + get + { + return data.HydraulicLocationConfigurationDatabase.Comment ?? string.Empty; + } + } + } +} \ No newline at end of file Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs =================================================================== diff -u -rb8ab33c43fb24b79930ae9de614107644ced42b4 -rbd9857561de05958b06f90ef92f317415d568d9d --- Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision b8ab33c43fb24b79930ae9de614107644ced42b4) +++ Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision bd9857561de05958b06f90ef92f317415d568d9d) @@ -238,9 +238,9 @@ { CreateInstance = data => new BackgroundDataProperties(data) }; - yield return new PropertyInfo + yield return new PropertyInfo { - CreateInstance = context => new HydraulicBoundaryDataProperties(context.WrappedData) + CreateInstance = context => new HydraulicLocationConfigurationDatabaseProperties(context.WrappedData) }; yield return new PropertyInfo { Fisheye: Tag bd9857561de05958b06f90ef92f317415d568d9d refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PropertyClasses/HydraulicBoundaryDataPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PropertyClasses/HydraulicLocationConfigurationDatabasePropertiesTest.cs =================================================================== diff -u --- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PropertyClasses/HydraulicLocationConfigurationDatabasePropertiesTest.cs (revision 0) +++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PropertyClasses/HydraulicLocationConfigurationDatabasePropertiesTest.cs (revision bd9857561de05958b06f90ef92f317415d568d9d) @@ -0,0 +1,229 @@ +// Copyright (C) Stichting Deltares 2022. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.ComponentModel; +using Core.Gui.PropertyBag; +using Core.Gui.TestUtil; +using NUnit.Framework; +using Riskeer.Common.Data.Hydraulics; +using Riskeer.Integration.Forms.PropertyClasses; + +namespace Riskeer.Integration.Forms.Test.PropertyClasses +{ + [TestFixture] + public class HydraulicLocationConfigurationDatabasePropertiesTest + { + private const int hlcdFilePathPropertyIndex = 0; + private const int scenarioNamePropertyIndex = 1; + private const int yearPropertyIndex = 2; + private const int scopePropertyIndex = 3; + private const int seaLevelPropertyIndex = 4; + private const int riverDischargePropertyIndex = 5; + private const int lakeLevelPropertyIndex = 6; + private const int windDirectionPropertyIndex = 7; + private const int windSpeedPropertyIndex = 8; + private const int commentPropertyIndex = 9; + + [Test] + public void Constructor_HydraulicBoundaryDataNull_ThrowsArgumentNullException() + { + // Call + void Call() => new HydraulicLocationConfigurationDatabaseProperties(null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("hydraulicBoundaryData", exception.ParamName); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var hydraulicBoundaryData = new HydraulicBoundaryData(); + + // Call + var properties = new HydraulicLocationConfigurationDatabaseProperties(hydraulicBoundaryData); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.AreSame(hydraulicBoundaryData, properties.Data); + } + + [Test] + public void GetProperties_WithUnlinkedHydraulicBoundaryData_ReturnsExpectedValues() + { + // Setup + var hydraulicBoundaryData = new HydraulicBoundaryData(); + + // Call + var properties = new HydraulicLocationConfigurationDatabaseProperties(hydraulicBoundaryData); + + // Assert + Assert.IsEmpty(properties.HlcdFilePath); + Assert.IsEmpty(properties.ScenarioName); + Assert.AreEqual(0, properties.Year); + Assert.IsEmpty(properties.Scope); + Assert.IsEmpty(properties.SeaLevel); + Assert.IsEmpty(properties.RiverDischarge); + Assert.IsEmpty(properties.LakeLevel); + Assert.IsEmpty(properties.WindDirection); + Assert.IsEmpty(properties.WindSpeed); + Assert.IsEmpty(properties.Comment); + } + + [Test] + public void GetProperties_WithLinkedHydraulicBoundaryData_ReturnsExpectedValues() + { + // Setup + HydraulicBoundaryData hydraulicBoundaryData = CreateLinkedHydraulicBoundaryData(); + + // Precondition + Assert.IsTrue(hydraulicBoundaryData.IsLinked()); + + // Call + var properties = new HydraulicLocationConfigurationDatabaseProperties(hydraulicBoundaryData); + + // Assert + HydraulicLocationConfigurationDatabase hydraulicLocationConfigurationDatabase = hydraulicBoundaryData.HydraulicLocationConfigurationDatabase; + Assert.AreEqual(hydraulicLocationConfigurationDatabase.FilePath, properties.HlcdFilePath); + Assert.AreEqual(hydraulicLocationConfigurationDatabase.ScenarioName, properties.ScenarioName); + Assert.AreEqual(hydraulicLocationConfigurationDatabase.Year.ToString(), properties.Year); + Assert.AreEqual(hydraulicLocationConfigurationDatabase.Scope, properties.Scope); + Assert.AreEqual(hydraulicLocationConfigurationDatabase.SeaLevel, properties.SeaLevel); + Assert.AreEqual(hydraulicLocationConfigurationDatabase.RiverDischarge, properties.RiverDischarge); + Assert.AreEqual(hydraulicLocationConfigurationDatabase.LakeLevel, properties.LakeLevel); + Assert.AreEqual(hydraulicLocationConfigurationDatabase.WindDirection, properties.WindDirection); + Assert.AreEqual(hydraulicLocationConfigurationDatabase.WindSpeed, properties.WindSpeed); + Assert.AreEqual(hydraulicLocationConfigurationDatabase.Comment, properties.Comment); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Constructor_WithHydraulicBoundaryData_PropertiesHaveExpectedAttributesValues(bool useLinkedHydraulicBoundaryData) + { + // Setup + HydraulicBoundaryData hydraulicBoundaryData = useLinkedHydraulicBoundaryData + ? CreateLinkedHydraulicBoundaryData() + : new HydraulicBoundaryData(); + + // Call + var properties = new HydraulicLocationConfigurationDatabaseProperties(hydraulicBoundaryData); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(10, dynamicProperties.Count); + + const string expectedCategory = "Algemeen"; + PropertyDescriptor hlcdFilePathProperty = dynamicProperties[hlcdFilePathPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(hlcdFilePathProperty, + expectedCategory, + "HLCD bestandslocatie", + "Locatie van het HLCD bestand.", + true); + + PropertyDescriptor scenarioNameProperty = dynamicProperties[scenarioNamePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(scenarioNameProperty, + expectedCategory, + "Klimaatscenario", + "Algemene naam van het klimaatscenario.", + true); + + PropertyDescriptor yearProperty = dynamicProperties[yearPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(yearProperty, + expectedCategory, + "Zichtjaar", + "Jaartal van het jaar waarop de statistiek van toepassing is.", + true); + + PropertyDescriptor scopeProperty = dynamicProperties[scopePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(scopeProperty, + expectedCategory, + "Toepassingskader", + "Projectkader waarin de statistiek bedoeld is te gebruiken.", + true); + + PropertyDescriptor seaLevelProperty = dynamicProperties[seaLevelPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(seaLevelProperty, + expectedCategory, + "Zeewaterstand", + "Klimaatinformatie met betrekking tot de zeewaterstand.", + true); + + PropertyDescriptor riverDischargeProperty = dynamicProperties[riverDischargePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(riverDischargeProperty, + expectedCategory, + "Rivierafvoer", + "Klimaatinformatie met betrekking tot de rivierafvoer.", + true); + + PropertyDescriptor lakeLevelProperty = dynamicProperties[lakeLevelPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(lakeLevelProperty, + expectedCategory, + "Meerpeil", + "Klimaatinformatie met betrekking tot het meerpeil/de meerpeilen.", + true); + + PropertyDescriptor windDirectionProperty = dynamicProperties[windDirectionPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(windDirectionProperty, + expectedCategory, + "Windrichting", + "Klimaatinformatie met betrekking tot de windrichting.", + true); + + PropertyDescriptor windSpeedProperty = dynamicProperties[windSpeedPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(windSpeedProperty, + expectedCategory, + "Windsnelheid", + "Klimaatinformatie met betrekking tot de windsnelheid.", + true); + + PropertyDescriptor commentProperty = dynamicProperties[commentPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(commentProperty, + expectedCategory, + "Overig", + "Overige informatie.", + true); + } + + private static HydraulicBoundaryData CreateLinkedHydraulicBoundaryData() + { + return new HydraulicBoundaryData + { + HydraulicLocationConfigurationDatabase = + { + FilePath = "hlcd.sqlite", + ScenarioName = "ScenarioName", + Year = 1337, + Scope = "Scope", + SeaLevel = "SeaLevel", + RiverDischarge = "RiverDischarge", + LakeLevel = "LakeLevel", + WindDirection = "WindDirection", + WindSpeed = "WindSpeed", + Comment = "Comment", + UsePreprocessorClosure = true + } + }; + } + } +} \ No newline at end of file Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/PropertyInfos/HydraulicLocationConfigurationDatabasePropertyInfoTest.cs =================================================================== diff -u -rb8ab33c43fb24b79930ae9de614107644ced42b4 -rbd9857561de05958b06f90ef92f317415d568d9d --- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/PropertyInfos/HydraulicLocationConfigurationDatabasePropertyInfoTest.cs (.../HydraulicLocationConfigurationDatabasePropertyInfoTest.cs) (revision b8ab33c43fb24b79930ae9de614107644ced42b4) +++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/PropertyInfos/HydraulicLocationConfigurationDatabasePropertyInfoTest.cs (.../HydraulicLocationConfigurationDatabasePropertyInfoTest.cs) (revision bd9857561de05958b06f90ef92f317415d568d9d) @@ -44,7 +44,7 @@ public void SetUp() { plugin = new RiskeerPlugin(); - info = plugin.GetPropertyInfos().First(tni => tni.PropertyObjectType == typeof(HydraulicBoundaryDataProperties)); + info = plugin.GetPropertyInfos().First(tni => tni.PropertyObjectType == typeof(HydraulicLocationConfigurationDatabaseProperties)); } [TearDown] @@ -61,7 +61,7 @@ } [Test] - public void CreateInstance_WithContext_ReturnHydraulicBoundaryDataProperties() + public void CreateInstance_WithContext_ReturnHydraulicLocationConfigurationDatabaseProperties() { // Setup var mocks = new MockRepository(); @@ -79,7 +79,7 @@ IObjectProperties objectProperties = info.CreateInstance(context); // Assert - Assert.IsInstanceOf(objectProperties); + Assert.IsInstanceOf(objectProperties); Assert.AreSame(context.WrappedData, objectProperties.Data); } } Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerPluginTest.cs =================================================================== diff -u -rb8ab33c43fb24b79930ae9de614107644ced42b4 -rbd9857561de05958b06f90ef92f317415d568d9d --- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerPluginTest.cs (.../RiskeerPluginTest.cs) (revision b8ab33c43fb24b79930ae9de614107644ced42b4) +++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerPluginTest.cs (.../RiskeerPluginTest.cs) (revision bd9857561de05958b06f90ef92f317415d568d9d) @@ -239,7 +239,7 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(HydraulicLocationConfigurationDatabaseContext), - typeof(HydraulicBoundaryDataProperties)); + typeof(HydraulicLocationConfigurationDatabaseProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos,