public void PropertyAttributes_NoGeneralResult_ReturnExpectedValues(double waveHeight) { // Setup var overtoppingOutput = new OvertoppingOutput(waveHeight, true, 0, null); // Call var properties = new OvertoppingOutputProperties(overtoppingOutput); // Assert int propertiesCount = overtoppingOutput.HasWaveHeight ? 4 : 3; PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(propertiesCount, dynamicProperties.Count); PropertyDescriptor probabilityProperty = dynamicProperties[probabilityPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(probabilityProperty, resultCategoryName, "Faalkans [1/jaar]", "De kans dat het faalmechanisme optreedt voor deze berekening.", true); PropertyDescriptor reliabilityProperty = dynamicProperties[reliabilityPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(reliabilityProperty, resultCategoryName, "Betrouwbaarheidsindex faalkans [-]", "De betrouwbaarheidsindex van de faalkans voor deze berekening.", true); if (overtoppingOutput.HasWaveHeight) { PropertyDescriptor waveHeightProperty = dynamicProperties[waveHeightIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waveHeightProperty, resultCategoryName, "Indicatieve golfhoogte (Hs) [m]", "De golfhoogte van de overslag deelberekening.", true); } int waveHeightNotPresentOffset = overtoppingOutput.HasWaveHeight ? 0 : 1; PropertyDescriptor isDominantProperty = dynamicProperties[isDominantIndex - waveHeightNotPresentOffset]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isDominantProperty, resultCategoryName, "Overslag dominant [-]", "Is het resultaat van de overslag deelberekening dominant over de overloop deelberekening.", true); }
public void Constructor_ExpectedValues() { // Setup var overtoppingOutput = new TestOvertoppingOutput(0.5); // Call var properties = new OvertoppingOutputProperties(overtoppingOutput); // Assert Assert.IsInstanceOf <ObjectProperties <OvertoppingOutput> >(properties); Assert.AreSame(overtoppingOutput, properties.Data); }
public void IllustrationPoints_WithoutGeneralResult_ReturnsEmptyTopLevelFaultTreeIllustrationPointPropertiesArray() { // Setup var overtoppingOutput = new TestOvertoppingOutput(0.5); var properties = new OvertoppingOutputProperties(overtoppingOutput); // Call TopLevelFaultTreeIllustrationPointProperties[] illustrationPoints = properties.IllustrationPoints; // Assert Assert.IsEmpty(illustrationPoints); }
public void GetProperties_WithData_ReturnExpectedValues() { // Setup var random = new Random(39); double waveHeight = random.NextDouble(); bool isOvertoppingDominant = random.NextBoolean(); double reliability = random.NextDouble(); var generalResult = new TestGeneralResultFaultTreeIllustrationPoint(); var overtoppingOutput = new OvertoppingOutput(waveHeight, isOvertoppingDominant, reliability, generalResult); // Call var properties = new OvertoppingOutputProperties(overtoppingOutput); // Assert Assert.AreEqual(2, properties.WaveHeight.NumberOfDecimalPlaces); Assert.AreEqual(waveHeight, properties.WaveHeight, properties.WaveHeight.GetAccuracy()); Assert.AreEqual(reliability, properties.Reliability, properties.Reliability.GetAccuracy()); Assert.AreEqual(ProbabilityFormattingHelper.Format(0.5), properties.Probability); Assert.AreEqual(isOvertoppingDominant, properties.IsOvertoppingDominant); Assert.AreEqual(generalResult.GoverningWindDirection.Name, properties.WindDirection); TestHelper.AssertTypeConverter <StructuresOutputProperties, KeyValueExpandableArrayConverter>( nameof(StructuresOutputProperties.AlphaValues)); TestHelper.AssertTypeConverter <StructuresOutputProperties, KeyValueExpandableArrayConverter>( nameof(StructuresOutputProperties.Durations)); int nrOfExpectedStochasts = generalResult.Stochasts.Count(); Assert.AreEqual(nrOfExpectedStochasts, properties.AlphaValues.Length); Assert.AreEqual(nrOfExpectedStochasts, properties.Durations.Length); Stochast expectedStochast = generalResult.Stochasts.First(); Assert.AreEqual(expectedStochast.Alpha, properties.AlphaValues[0].Alpha); Assert.AreEqual(expectedStochast.Duration, properties.Durations[0].Duration); TestHelper.AssertTypeConverter <StructuresOutputProperties, ExpandableArrayConverter>( nameof(StructuresOutputProperties.IllustrationPoints)); int nrOfExpectedTopLevelIllustrationPoints = generalResult.TopLevelIllustrationPoints.Count(); Assert.AreEqual(nrOfExpectedTopLevelIllustrationPoints, properties.IllustrationPoints.Length); CollectionAssert.AreEqual(generalResult.TopLevelIllustrationPoints, properties.IllustrationPoints.Select(i => i.Data)); }
public void PropertyAttributes_HasGeneralResult_ReturnExpectedValues(double waveHeight) { // Setup var overtoppingOutput = new OvertoppingOutput(waveHeight, true, 0, new TestGeneralResultFaultTreeIllustrationPoint()); // Call var properties = new OvertoppingOutputProperties(overtoppingOutput); // Assert int propertiesCount = overtoppingOutput.HasWaveHeight ? 8 : 7; PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(propertiesCount, dynamicProperties.Count); PropertyDescriptor probabilityProperty = dynamicProperties[probabilityPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(probabilityProperty, resultCategoryName, "Faalkans [1/jaar]", "De kans dat het faalmechanisme optreedt voor deze berekening.", true); PropertyDescriptor reliabilityProperty = dynamicProperties[reliabilityPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(reliabilityProperty, resultCategoryName, "Betrouwbaarheidsindex faalkans [-]", "De betrouwbaarheidsindex van de faalkans voor deze berekening.", true); if (overtoppingOutput.HasWaveHeight) { PropertyDescriptor waveHeightProperty = dynamicProperties[waveHeightIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waveHeightProperty, resultCategoryName, "Indicatieve golfhoogte (Hs) [m]", "De golfhoogte van de overslag deelberekening.", true); } int waveHeightNotPresentOffset = overtoppingOutput.HasWaveHeight ? 0 : 1; PropertyDescriptor isDominantProperty = dynamicProperties[isDominantIndex - waveHeightNotPresentOffset]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isDominantProperty, resultCategoryName, "Overslag dominant [-]", "Is het resultaat van de overslag deelberekening dominant over de overloop deelberekening.", true); PropertyDescriptor windDirectionProperty = dynamicProperties[windDirectionPropertyIndex - waveHeightNotPresentOffset]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(windDirectionProperty, illustrationPointsCategoryName, "Maatgevende windrichting", "De windrichting waarvoor de berekende betrouwbaarheidsindex het laagst is.", true); PropertyDescriptor alphaValuesProperty = dynamicProperties[alphaValuesPropertyIndex - waveHeightNotPresentOffset]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(alphaValuesProperty, illustrationPointsCategoryName, "Invloedscoëfficiënten [-]", "Berekende invloedscoëfficiënten voor alle beschouwde stochasten.", true); PropertyDescriptor durationsProperty = dynamicProperties[durationsPropertyIndex - waveHeightNotPresentOffset]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(durationsProperty, illustrationPointsCategoryName, "Tijdsduren [uur]", "Tijdsduren waarop de stochasten betrekking hebben.", true); PropertyDescriptor illustrationPointProperty = dynamicProperties[illustrationPointsPropertyIndex - waveHeightNotPresentOffset]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(illustrationPointProperty, illustrationPointsCategoryName, "Illustratiepunten", "De lijst van illustratiepunten voor de berekening.", true); }