public void ToString_DifferentClosingSituations_ReturnsCombinationOfWindDirectionAndClosingSituation() { // Setup string illustrationPointName = string.Empty; var subMechanismIllustrationPoint = new SubMechanismIllustrationPoint(illustrationPointName, 3, Enumerable.Empty <SubMechanismIllustrationPointStochast>(), Enumerable.Empty <IllustrationPointResult>()); const string closingSituation = "direction"; WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(); var context = new TopLevelSubMechanismIllustrationPoint(windDirection, closingSituation, subMechanismIllustrationPoint); // Call var properties = new TopLevelSubMechanismIllustrationPointProperties( context, new[] { closingSituation, closingSituation, "Different situation" }); // Assert string expectedStringValue = $"{windDirection.Name} ({closingSituation})"; Assert.AreEqual(expectedStringValue, properties.ToString()); }
public void Constructor_ValidArgumentValues_DoesNotThrowException() { // Call var properties = new TopLevelSubMechanismIllustrationPointProperties( new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), string.Empty, new TestSubMechanismIllustrationPoint()), Enumerable.Empty <string>()); // Assert Assert.IsInstanceOf <ObjectProperties <TopLevelSubMechanismIllustrationPoint> >(properties); }
public void GetProperties_ValidData_ReturnsExpectedValues() { var random = new Random(21); double beta = random.NextDouble(); var stochasts = new[] { new SubMechanismIllustrationPointStochast("some name", "-", random.NextDouble(), random.NextDouble(), random.NextDouble()) }; var illustrationPointResults = new[] { new IllustrationPointResult("some description", "-", random.NextDouble()) }; const string illustrationPointName = "name"; var subMechanismIllustrationPoint = new SubMechanismIllustrationPoint(illustrationPointName, beta, stochasts, illustrationPointResults); const string closingSituation = "closingSituation"; const string windDirectionName = "windDirection"; var illustrationPoint = new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(windDirectionName), closingSituation, subMechanismIllustrationPoint); // Call var properties = new TopLevelSubMechanismIllustrationPointProperties(illustrationPoint, Enumerable.Empty <string>()); // Assert Assert.AreEqual(illustrationPointName, properties.Name); Assert.AreEqual(windDirectionName, properties.WindDirection); Assert.AreEqual(closingSituation, properties.ClosingSituation); CollectionAssert.AreEqual(subMechanismIllustrationPoint.Stochasts, properties.AlphaValues); CollectionAssert.AreEqual(subMechanismIllustrationPoint.Stochasts, properties.Durations); Assert.AreSame(illustrationPoint.SubMechanismIllustrationPoint, properties.SubMechanismIllustrationPointValues.Data); }
public void GetProperties_SameClosingSituations_ReturnsExpectedAttributeValues() { // Setup var context = new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), "closingSituation", new TestSubMechanismIllustrationPoint()); const string closingSituation = "Closing Situation"; // Call var properties = new TopLevelSubMechanismIllustrationPointProperties( context, new[] { closingSituation, closingSituation }); // Assert TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); Assert.IsInstanceOf <ExpandableObjectConverter>(classTypeConverter); PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(7, dynamicProperties.Count); const string generalCategory = "Algemeen"; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[namePropertyIndex], generalCategory, "Naam", "De naam van dit berekende illustratiepunt.", true); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[calculatedProbabilityPropertyIndex], generalCategory, "Berekende kans [-]", "De berekende kans van voorkomen van het berekende resultaat.", true); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[calculatedReliabilityPropertyIndex], generalCategory, "Betrouwbaarheidsindex berekende kans [-]", "Betrouwbaarheidsindex van de berekende kans van voorkomen van het berekende resultaat.", true); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[windDirectionNamePropertyIndex], generalCategory, "Windrichting", "De windrichting waarvoor dit illlustratiepunt is berekend.", true); TestHelper.AssertTypeConverter <TopLevelSubMechanismIllustrationPointProperties, KeyValueExpandableArrayConverter>(nameof(TopLevelSubMechanismIllustrationPointProperties.AlphaValues)); PropertyDescriptor alphaValuesProperty = dynamicProperties[alphaValuesPropertyIndex]; Assert.NotNull(alphaValuesProperty.Attributes[typeof(KeyValueElementAttribute)]); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(alphaValuesProperty, generalCategory, "Invloedscoëfficiënten [-]", "Berekende invloedscoëfficiënten voor alle beschouwde stochasten.", true); TestHelper.AssertTypeConverter <TopLevelSubMechanismIllustrationPointProperties, KeyValueExpandableArrayConverter>(nameof(TopLevelSubMechanismIllustrationPointProperties.Durations)); PropertyDescriptor durationsProperty = dynamicProperties[durationsPropertyIndex]; Assert.NotNull(durationsProperty.Attributes[typeof(KeyValueElementAttribute)]); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(durationsProperty, generalCategory, "Tijdsduren [uur]", "Tijdsduren waarop de stochasten betrekking hebben.", true); PropertyDescriptor illustrationPointValuesProperties = dynamicProperties[illustrationPointValuesPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(illustrationPointValuesProperties, generalCategory, "Waarden in het illustratiepunt", "", true); }