// Copyright (C) Stichting Deltares 2018. 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.Base.Geometry; using Core.Common.Gui.PropertyBag; using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.TestUtil; using Ringtoets.GrassCoverErosionInwards.Forms.PropertyClasses; namespace Ringtoets.GrassCoverErosionInwards.Forms.Test.PropertyClasses { [TestFixture] public class DikeProfilePropertiesTest { private const int idPropertyIndex = 0; private const int namePropertyIndex = 1; private const int worldReferencePointPropertyIndex = 2; private const int orientationPropertyIndex = 3; private const int breakWaterPropertyIndex = 4; private const int foreshorePropertyIndex = 5; private const int dikeGeometryPropertyIndex = 6; private const int dikeHeightPropertyIndex = 7; [Test] public void Constructor_ExpectedValues() { // Call var properties = new DikeProfileProperties(); // Assert Assert.IsInstanceOf>(properties); Assert.IsNull(properties.Data); } [Test] public void Data_SetNewDikeProfileInstance_ReturnCorrectPropertyValues() { // Setup const string id = "DP"; const string name = "Dijkprofiel"; var dikeProfile = new DikeProfile( new Point2D(12.34, 56.78), Enumerable.Empty(), Enumerable.Empty(), new BreakWater(BreakWaterType.Caisson, 2), new DikeProfile.ConstructionProperties { Id = id, Name = name }); // Call var properties = new DikeProfileProperties { Data = dikeProfile }; // Assert Assert.AreEqual(new Point2D(12, 57), properties.WorldReferencePoint); Assert.AreEqual(id, properties.Id); Assert.AreEqual(name, properties.Name); Assert.AreEqual(2, properties.Orientation.NumberOfDecimalPlaces); Assert.AreEqual(0.0, properties.Orientation.Value); Assert.AreSame(dikeProfile.ForeshoreProfile, properties.BreakWater.Data); Assert.AreSame(dikeProfile.ForeshoreProfile, properties.Foreshore.Data); Assert.AreSame(dikeProfile, properties.DikeGeometry.Data); Assert.AreEqual(2, properties.DikeHeight.NumberOfDecimalPlaces); Assert.AreEqual(0.0, properties.DikeHeight.Value); } [Test] public void Constructor_Always_PropertiesHaveExpectedAttributesValues() { // Setup DikeProfile dikeProfile = DikeProfileTestFactory.CreateDikeProfile(); // Call var properties = new DikeProfileProperties { Data = dikeProfile }; // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(8, dynamicProperties.Count); PropertyDescriptor idProperty = dynamicProperties[idPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(idProperty, "Algemeen", "ID", "ID van het dijkprofiel.", true); PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, "Algemeen", "Naam", "Naam van het dijkprofiel.", true); PropertyDescriptor worldReferencePointProperty = dynamicProperties[worldReferencePointPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(worldReferencePointProperty, "Schematisatie", "Locatie (RD) [m]", "De coördinaten van de locatie van de dijk in het Rijksdriehoeksstelsel.", true); PropertyDescriptor orientationProperty = dynamicProperties[orientationPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(orientationProperty, "Schematisatie", "Oriëntatie [°]", "Oriëntatie van de dijknormaal ten opzichte van het noorden.", true); PropertyDescriptor breakWaterProperty = dynamicProperties[breakWaterPropertyIndex]; Assert.IsInstanceOf(breakWaterProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(breakWaterProperty, "Schematisatie", "Dam", "Eigenschappen van de dam.", true); PropertyDescriptor foreshoreProperty = dynamicProperties[foreshorePropertyIndex]; Assert.IsInstanceOf(foreshoreProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(foreshoreProperty, "Schematisatie", "Voorlandgeometrie", "Eigenschappen van de voorlandgeometrie.", true); PropertyDescriptor dikeGeometryProperty = dynamicProperties[dikeGeometryPropertyIndex]; Assert.IsInstanceOf(dikeGeometryProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dikeGeometryProperty, "Schematisatie", "Dijkgeometrie", "Eigenschappen van de dijkgeometrie.", true); PropertyDescriptor dikeHeightProperty = dynamicProperties[dikeHeightPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dikeHeightProperty, "Schematisatie", "Dijkhoogte [m+NAP]", "De hoogte van de dijk.", true); } } }