using System; using System.Collections.Generic; using System.Linq; using System.Text; using UnitTestSharp.Extensions; namespace TestsForUnitTestSharp.Extensions { public class MemberInfoExtensionsTests : UnitTestSharp.TestFixture { [System.Serializable()] class Internal { } class Child : Internal { } [System.AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] class MultipleAttribute : Attribute { } [Multiple] [Multiple] class DoubleAttribute { } public void HasAttribute_Internal() { Check(typeof(Internal).HasAttribute(typeof(System.SerializableAttribute))); } public void HasAttribute_FalsePositive() { CheckFalse(typeof(Internal).HasAttribute(typeof(System.StackOverflowException))); } public void HasAttribute_Child() { CheckFalse(typeof(Child).HasAttribute(typeof(System.SerializableAttribute))); } public void HasAttribute_DoubleAttribute() { Check(typeof(DoubleAttribute).HasAttribute(typeof(MultipleAttribute))); } public void GetAttribute_Internal() { Check(typeof(Internal).GetAttribute(typeof(System.SerializableAttribute)) is System.SerializableAttribute); } public void GetAttribute_FalsePositive() { CheckNull(typeof(Internal).GetAttribute(typeof(MultipleAttribute))); } public void GetAttribute_Child() { CheckNull(typeof(Child).GetAttribute(typeof(System.SerializableAttribute))); } public void GetAttribute_DoubleAttribute() { CheckThrow(typeof(Exception)); typeof(DoubleAttribute).GetAttribute(typeof(MultipleAttribute)); } } }