Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/NormalDistributionVariationPropertiesTest.cs =================================================================== diff -u -r9ee17a39e4ba653cfc2e1a576f0ac53dcdf8a7dc -rd9a31419cf4e540600190bea6b36c0c92dda4845 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/NormalDistributionVariationPropertiesTest.cs (.../NormalDistributionVariationPropertiesTest.cs) (revision 9ee17a39e4ba653cfc2e1a576f0ac53dcdf8a7dc) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/NormalDistributionVariationPropertiesTest.cs (.../NormalDistributionVariationPropertiesTest.cs) (revision d9a31419cf4e540600190bea6b36c0c92dda4845) @@ -20,11 +20,14 @@ // All rights reserved. using System; +using System.Collections; using System.ComponentModel; +using System.Linq; using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Gui.PropertyBag; using Core.Common.TestUtil; +using Core.Common.Utils.Attributes; using Core.Common.Utils.Reflection; using NUnit.Framework; using Rhino.Mocks; @@ -278,21 +281,46 @@ }); Assert.AreEqual(3, dynamicProperties.Count); - PropertyDescriptor distributionTypeProperty = dynamicProperties[0]; + var distributionTypePropertyName = TypeUtils.GetMemberName(ndp => ndp.DistributionType); + PropertyDescriptor distributionTypeProperty = dynamicProperties.Find(distributionTypePropertyName, false); Assert.IsTrue(distributionTypeProperty.IsReadOnly); - Assert.AreEqual("Type verdeling", distributionTypeProperty.DisplayName); - Assert.AreEqual("Het soort kansverdeling waarin deze parameter gedefinieerd wordt.", distributionTypeProperty.Description); + AssertAttributeProperty(distributionTypeProperty.Attributes, "Type verdeling", + attribute => attribute.DisplayName); + AssertAttributeProperty(distributionTypeProperty.Attributes, + "Het soort kansverdeling waarin deze parameter gedefinieerd wordt.", + attribute => attribute.Description); - PropertyDescriptor meanProperty = dynamicProperties[1]; + var meanPropertyName = TypeUtils.GetMemberName(ndp => ndp.Mean); + PropertyDescriptor meanProperty = dynamicProperties.Find(meanPropertyName, false); Assert.AreEqual(expectMeanReadOnly, meanProperty.IsReadOnly); - Assert.AreEqual("Verwachtingswaarde", meanProperty.DisplayName); - Assert.AreEqual("De gemiddelde waarde van de normale verdeling.", meanProperty.Description); + AssertAttributeProperty(meanProperty.Attributes, "Verwachtingswaarde", + attribute => attribute.DisplayName); + AssertAttributeProperty(meanProperty.Attributes, + "De gemiddelde waarde van de normale verdeling.", + attribute => attribute.Description); - PropertyDescriptor variationCoefficientProperty = dynamicProperties[2]; + var variationCoefficientPropertyName = TypeUtils.GetMemberName(ndp => ndp.VariationCoefficient); + PropertyDescriptor variationCoefficientProperty = dynamicProperties.Find(variationCoefficientPropertyName, false); Assert.AreEqual(expectVariationCoefficientReadOnly, variationCoefficientProperty.IsReadOnly); - Assert.AreEqual("Variatiecoëfficiënt", variationCoefficientProperty.DisplayName); - Assert.AreEqual("De variatiecoëfficiënt van de normale verdeling.", variationCoefficientProperty.Description); + AssertAttributeProperty(variationCoefficientProperty.Attributes, "Variatiecoëfficiënt", + attribute => attribute.DisplayName); + AssertAttributeProperty(variationCoefficientProperty.Attributes, + "De variatiecoëfficiënt van de normale verdeling.", + attribute => attribute.Description); + mockRepository.VerifyAll(); } + + private static void AssertAttributeProperty( + IEnumerable attributes, + TAttributePropertyValueType expectedValue, + Func getAttributePropertyValue) + { + var attributesOfTypeTAttributeType = attributes.OfType(); + Assert.IsNotNull(attributesOfTypeTAttributeType); + var attribute = attributesOfTypeTAttributeType.FirstOrDefault(); + Assert.IsNotNull(attribute, string.Format("Attribute type '{0} not found in {1}'", typeof(TAttributeType), attributes)); + Assert.AreEqual(expectedValue, getAttributePropertyValue(attribute)); + } } } \ No newline at end of file