Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.TestUtil/SerializableAttributeTestHelper.cs =================================================================== diff -u -rf98d0ea5ec2ccf5785d2f94f3df9ed44f5fb2a08 -r328e66989ee3811e7fa65ca79041c79e2c9f4581 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.TestUtil/SerializableAttributeTestHelper.cs (.../SerializableAttributeTestHelper.cs) (revision f98d0ea5ec2ccf5785d2f94f3df9ed44f5fb2a08) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.TestUtil/SerializableAttributeTestHelper.cs (.../SerializableAttributeTestHelper.cs) (revision 328e66989ee3811e7fa65ca79041c79e2c9f4581) @@ -21,6 +21,7 @@ using System.Linq; using System.Xml.Serialization; +using Core.Common.Util.Reflection; using NUnit.Framework; namespace Ringtoets.AssemblyTool.IO.TestUtil @@ -52,9 +53,31 @@ Assert.AreEqual(namespaceUrl, attribute.Namespace); } + /// + /// Asserts whether the property in class + /// has a with the correct values. + /// + /// The class the is in. + /// The name of the property to assert. + /// The expected XML element name. + /// The expected XML namespace url. + /// Thrown when: + /// + /// the could not be found, or multiple attributes are defined; + /// the or do not match + /// with the actual attribute. + /// + /// + public static void AssertXmlAttributeAttribute(string propertyName, string elementName, string namespaceUrl = null) + { + XmlAttributeAttribute attribute = GetPropertyAttribute(propertyName); + Assert.AreEqual(elementName, attribute.AttributeName); + Assert.AreEqual(namespaceUrl, attribute.Namespace); + } + private static TAttribute GetPropertyAttribute(string propertyName) { - var attribute = (TAttribute) typeof(TObject).GetProperty(propertyName)?.GetCustomAttributes(typeof(TAttribute), false).SingleOrDefault(); + TAttribute attribute = TypeUtils.GetPropertyAttributes(propertyName).SingleOrDefault(); Assert.IsNotNull(attribute); return attribute; }