public void ToString_Always_ExpectedValue() { // Setup var duneLocation = new DuneLocation(1, "Name", new Point2D(0.0, 1.1), new DuneLocation.ConstructionProperties()); var duneLocationCalculation = new DuneLocationCalculation(duneLocation); var properties = new DuneLocationCalculationProperties(duneLocationCalculation); // Call string result = properties.ToString(); // Assert Assert.AreEqual($"{duneLocation.Name} {duneLocation.Location}", result); }
public void Offset_Always_FormatToString(double offset, string expectedPropertyValue) { var duneLocation = new DuneLocation(1, "test", new Point2D(0, 0), new DuneLocation.ConstructionProperties { Offset = offset }); var duneLocationCalculation = new DuneLocationCalculation(duneLocation); // Call var properties = new DuneLocationCalculationProperties(duneLocationCalculation); // Assert Assert.AreEqual(expectedPropertyValue, properties.Offset); }
public void GetProperties_ValidData_ReturnsExpectedValues() { // Setup var duneLocation = new TestDuneLocation(); var duneLocationCalculation = new DuneLocationCalculation(duneLocation); // Call var properties = new DuneLocationCalculationProperties(duneLocationCalculation); // Assert Assert.AreEqual(duneLocation.Id, properties.Id); Assert.AreEqual(duneLocation.Name, properties.Name); Assert.AreEqual(duneLocation.CoastalAreaId, properties.CoastalAreaId); Assert.AreEqual(duneLocation.Offset.ToString("0.#", CultureInfo.InvariantCulture), properties.Offset); Assert.AreEqual(duneLocation.Location, properties.Location); Assert.IsNaN(properties.WaterLevel); Assert.IsNaN(properties.WaveHeight); Assert.IsNaN(properties.WavePeriod); Assert.IsNaN(properties.TargetProbability); TestHelper.AssertTypeConverter <DuneLocationCalculationProperties, NoProbabilityValueDoubleConverter>( nameof(DuneLocationCalculationProperties.TargetProbability)); Assert.IsNaN(properties.TargetReliability); TestHelper.AssertTypeConverter <DuneLocationCalculationProperties, NoValueRoundedDoubleConverter>( nameof(DuneLocationCalculationProperties.TargetReliability)); Assert.IsNaN(properties.CalculatedProbability); TestHelper.AssertTypeConverter <DuneLocationCalculationProperties, NoProbabilityValueDoubleConverter>( nameof(DuneLocationCalculationProperties.CalculatedProbability)); Assert.IsNaN(properties.CalculatedReliability); TestHelper.AssertTypeConverter <DuneLocationCalculationProperties, NoValueRoundedDoubleConverter>( nameof(DuneLocationCalculationProperties.CalculatedReliability)); string convergenceValue = EnumDisplayNameHelper.GetDisplayName(CalculationConvergence.NotCalculated); Assert.AreEqual(convergenceValue, properties.Convergence); }
public void Constructor_Always_PropertiesHaveExpectedAttributesValues() { // Setup var duneLocationCalculation = new DuneLocationCalculation(new TestDuneLocation()); // Call var properties = new DuneLocationCalculationProperties(duneLocationCalculation); // Assert TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(14, dynamicProperties.Count); Assert.IsInstanceOf <ExpandableObjectConverter>(classTypeConverter); PropertyDescriptor idProperty = dynamicProperties[requiredIdPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(idProperty, "Algemeen", "ID", "ID van de hydraulische belastingenlocatie in de database.", true); PropertyDescriptor nameProperty = dynamicProperties[requiredNamePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, "Algemeen", "Naam", "Naam van de hydraulische belastingenlocatie.", true); PropertyDescriptor coastalAreaIdProperty = dynamicProperties[requiredCoastalAreaIdPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(coastalAreaIdProperty, "Algemeen", "Kustvaknummer", "Nummer van het kustvak waar de locatie onderdeel van uitmaakt.", true); PropertyDescriptor offsetProperty = dynamicProperties[requiredOffSetPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(offsetProperty, "Algemeen", "Metrering [dam]", "Metrering van de locatie binnen het kustvak waar het onderdeel van uitmaakt.", true); PropertyDescriptor locationProperty = dynamicProperties[requiredLocationPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(locationProperty, "Algemeen", "Coördinaten [m]", "Coördinaten van de hydraulische belastingenlocatie.", true); PropertyDescriptor waterLevelProperty = dynamicProperties[requiredWaterLevelPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waterLevelProperty, "Resultaat", "Rekenwaarde waterstand [m+NAP]", "Berekende rekenwaarde voor de waterstand voor het uitvoeren van een sterkteberekening voor het faalmechanisme duinen.", true); PropertyDescriptor waveHeightProperty = dynamicProperties[requiredWaveHeightPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waveHeightProperty, "Resultaat", "Rekenwaarde Hs [m]", "Berekende rekenwaarde voor de significante golfhoogte voor het uitvoeren van een sterkteberekening voor het faalmechanisme duinen.", true); PropertyDescriptor wavePeriodProperty = dynamicProperties[requiredWavePeriodPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(wavePeriodProperty, "Resultaat", "Rekenwaarde Tp [s]", "Berekende rekenwaarde voor de piekperiode van de golven voor het uitvoeren van een sterkteberekening voor het faalmechanisme duinen.", true); PropertyDescriptor d50Property = dynamicProperties[requiredD50PropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(d50Property, "Resultaat", "Rekenwaarde d50 [m]", "Rekenwaarde voor de d50 voor het uitvoeren van een sterkteberekening voor het faalmechanisme duinen.", true); PropertyDescriptor targetProbabilityProperty = dynamicProperties[requiredTargetProbabilityPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(targetProbabilityProperty, "Resultaat", "Doelkans [1/jaar]", "De ingevoerde kans waarvoor het resultaat moet worden berekend.", true); PropertyDescriptor targetReliabilityProperty = dynamicProperties[requiredTargetReliabilityPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(targetReliabilityProperty, "Resultaat", "Betrouwbaarheidsindex doelkans [-]", "Betrouwbaarheidsindex van de ingevoerde kans waarvoor het resultaat moet worden berekend.", true); PropertyDescriptor calculatedProbabilityProperty = dynamicProperties[requiredCalculatedProbabilityPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(calculatedProbabilityProperty, "Resultaat", "Berekende kans [1/jaar]", "De berekende kans van voorkomen van het berekende resultaat.", true); PropertyDescriptor calculatedReliabilityProperty = dynamicProperties[requiredCalculatedReliabilityPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(calculatedReliabilityProperty, "Resultaat", "Betrouwbaarheidsindex berekende kans [-]", "Betrouwbaarheidsindex van de berekende kans van voorkomen van het berekende resultaat.", true); PropertyDescriptor convergenceProperty = dynamicProperties[requiredConvergencePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(convergenceProperty, "Resultaat", "Convergentie", "Is convergentie bereikt in de berekening van de hydraulische belastingen voor de duinlocatie?", true); }
public void GetProperties_ValidDesignWaterLevel_ReturnsExpectedValues() { // Setup const long id = 1234L; const double x = 567.0; const double y = 890.0; const string name = "<some name>"; var random = new Random(); int coastalAreaId = random.Next(); var convergence = random.NextEnumValue <CalculationConvergence>(); double offset = random.NextDouble(); double orientation = random.NextDouble(); double d50 = random.NextDouble(); double waterLevel = random.NextDouble(); double waveHeight = random.NextDouble(); double wavePeriod = random.NextDouble(); double targetProbability = random.NextDouble(); double targetReliability = random.NextDouble(); double calculatedProbability = random.NextDouble(); double calculatedReliability = random.NextDouble(); var output = new DuneLocationCalculationOutput( convergence, new DuneLocationCalculationOutput.ConstructionProperties { WaterLevel = waterLevel, WaveHeight = waveHeight, WavePeriod = wavePeriod, TargetProbability = targetProbability, TargetReliability = targetReliability, CalculatedProbability = calculatedProbability, CalculatedReliability = calculatedReliability }); var duneLocation = new DuneLocation(id, name, new Point2D(x, y), new DuneLocation.ConstructionProperties { CoastalAreaId = coastalAreaId, Offset = offset, Orientation = orientation, D50 = d50 }); var duneLocationCalculation = new DuneLocationCalculation(duneLocation) { Output = output }; // Call var properties = new DuneLocationCalculationProperties(duneLocationCalculation); // Assert Assert.AreEqual(id, properties.Id); Assert.AreEqual(name, properties.Name); Assert.AreEqual(coastalAreaId, properties.CoastalAreaId); Assert.AreEqual(duneLocation.Offset.ToString("0.#", CultureInfo.InvariantCulture), properties.Offset); var expectedLocation = new Point2D(x, y); Assert.AreEqual(expectedLocation, properties.Location); Assert.AreEqual(waterLevel, properties.WaterLevel, properties.WaterLevel.GetAccuracy()); Assert.AreEqual(waveHeight, properties.WaveHeight, properties.WaveHeight.GetAccuracy()); Assert.AreEqual(wavePeriod, properties.WavePeriod, properties.WavePeriod.GetAccuracy()); Assert.AreEqual(d50, properties.D50, properties.D50.GetAccuracy()); Assert.AreEqual(targetProbability, properties.TargetProbability); Assert.AreEqual(targetReliability, properties.TargetReliability, properties.TargetReliability.GetAccuracy()); Assert.AreEqual(calculatedProbability, properties.CalculatedProbability, properties.CalculatedProbability); Assert.AreEqual(calculatedReliability, properties.CalculatedReliability, properties.CalculatedReliability.GetAccuracy()); string convergenceValue = EnumDisplayNameHelper.GetDisplayName(convergence); Assert.AreEqual(convergenceValue, properties.Convergence); }