Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.TestUtil/SerializableAttributeTestHelper.cs
===================================================================
diff -u -re17ab48b3abda85cd6d9cb33e6a9f507e70fdff3 -rd3b53b68914f5cead6eaf7b008168b29b2bd5754
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.TestUtil/SerializableAttributeTestHelper.cs (.../SerializableAttributeTestHelper.cs) (revision e17ab48b3abda85cd6d9cb33e6a9f507e70fdff3)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.IO.TestUtil/SerializableAttributeTestHelper.cs (.../SerializableAttributeTestHelper.cs) (revision d3b53b68914f5cead6eaf7b008168b29b2bd5754)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;
using Core.Common.Util.Reflection;
@@ -37,11 +38,16 @@
///
/// The type to assert.
/// The expected XML type name.
- /// Thrown when the
- /// does not match with the actual attribute.
+ /// Thrown when:
+ ///
+ /// - does not match with the actual attribute;
+ /// - multiple attributes of type were found.
+ ///
+ ///
public static void AssertXmlTypeAttribute(Type type, string typeName)
{
- var attribute = (XmlTypeAttribute) type.GetCustomAttributes(typeof(XmlTypeAttribute), false).Single();
+ var attribute = (XmlTypeAttribute) type.GetCustomAttributes(typeof(XmlTypeAttribute), false).SingleOrDefault();
+ Assert.IsNotNull(attribute);
Assert.AreEqual(typeName, attribute.TypeName);
}
@@ -55,12 +61,14 @@
/// The expected XML namespace url.
/// Thrown when:
///
- /// - the could not be found, or multiple attributes are defined;
+ /// - the could not be found
+ /// - multiple attributes of type were found;
/// - the or do not match
/// with the actual attribute.
///
///
public static void AssertXmlElementAttribute(string propertyName, string elementName, string namespaceUrl = null)
+ where T : class
{
XmlElementAttribute attribute = GetPropertyAttribute(propertyName);
Assert.AreEqual(elementName, attribute.ElementName);
@@ -77,12 +85,14 @@
/// 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.
+ /// - the could not be found;
+ /// - multiple attributes of type were found;
+ /// - the actual attribute does not match with the given
+ /// and .
///
///
public static void AssertXmlAttributeAttribute(string propertyName, string elementName, string namespaceUrl = null)
+ where T : class
{
XmlAttributeAttribute attribute = GetPropertyAttribute(propertyName);
Assert.AreEqual(elementName, attribute.AttributeName);
@@ -91,9 +101,9 @@
private static TAttribute GetPropertyAttribute(string propertyName)
{
- TAttribute attribute = TypeUtils.GetPropertyAttributes(propertyName).SingleOrDefault();
- Assert.IsNotNull(attribute);
- return attribute;
+ IEnumerable attributes = TypeUtils.GetPropertyAttributes(propertyName);
+ Assert.AreEqual(1, attributes.Count());
+ return attributes.Single();
}
}
}
\ No newline at end of file