public void GetProperties_WithValidData_ReturnsExpectedValues() { // Setup var random = new Random(21); var stochasts = new[] { new SubMechanismIllustrationPointStochast("some name", "-", random.NextDouble(), random.NextDouble(), random.NextDouble()) }; var illustrationPointResults = new[] { new IllustrationPointResult("some description", "-", random.NextDouble()) }; var illustrationPoint = new SubMechanismIllustrationPoint("name", random.NextDouble(), stochasts, illustrationPointResults); // Call var properties = new SubMechanismIllustrationPointValuesProperties(illustrationPoint); // Assert CollectionAssert.AreEqual(illustrationPoint.Stochasts, properties.Realizations); CollectionAssert.AreEqual(illustrationPoint.IllustrationPointResults, properties.Results); }
public void ToString_WithValidData_ReturnsEmptyString() { // Setup var random = new Random(21); var illustrationPoint = new SubMechanismIllustrationPoint("Not an empty string", random.NextDouble(), Enumerable.Empty <SubMechanismIllustrationPointStochast>(), Enumerable.Empty <IllustrationPointResult>()); var properties = new SubMechanismIllustrationPointValuesProperties(illustrationPoint); // Call string toStringValue = properties.ToString(); // Assert Assert.IsEmpty(toStringValue); }
public void Constructor_WithValidArgument_ReturnsExpectedProperties() { // Setup var random = new Random(21); var illustrationPoint = new SubMechanismIllustrationPoint(string.Empty, random.NextDouble(), Enumerable.Empty <SubMechanismIllustrationPointStochast>(), Enumerable.Empty <IllustrationPointResult>()); // Call var properties = new SubMechanismIllustrationPointValuesProperties(illustrationPoint); // Assert Assert.IsInstanceOf <ObjectProperties <SubMechanismIllustrationPoint> >(properties); Assert.AreSame(illustrationPoint, properties.Data); TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); Assert.IsInstanceOf <ExpandableObjectConverter>(classTypeConverter); TestHelper.AssertTypeConverter <SubMechanismIllustrationPointValuesProperties, KeyValueExpandableArrayConverter>(nameof(SubMechanismIllustrationPointValuesProperties.Realizations)); TestHelper.AssertTypeConverter <SubMechanismIllustrationPointValuesProperties, KeyValueExpandableArrayConverter>(nameof(SubMechanismIllustrationPointValuesProperties.Results)); }
public void GetProperties_WithValidData_ReturnsExpectedAttributeValues() { // Setup var random = new Random(21); var illustrationPoint = new SubMechanismIllustrationPoint("name", random.NextDouble(), Enumerable.Empty <SubMechanismIllustrationPointStochast>(), Enumerable.Empty <IllustrationPointResult>()); // Call var properties = new SubMechanismIllustrationPointValuesProperties(illustrationPoint); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(2, dynamicProperties.Count); const string category = "Illustratiepunten"; PropertyDescriptor realizationsProperty = dynamicProperties[realizationsPropertyIndex]; Assert.NotNull(realizationsProperty.Attributes[typeof(KeyValueElementAttribute)]); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(realizationsProperty, category, "Stochastwaarden", "Realisaties van de stochasten in het illustratiepunt.", true); PropertyDescriptor resultsProperty = dynamicProperties[resultsPropertyIndex]; Assert.NotNull(resultsProperty.Attributes[typeof(KeyValueElementAttribute)]); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(resultsProperty, category, "Afgeleide variabelen", "Waarden van afgeleide variabelen in het illustratiepunt.", true); }