public void CreateCustomAttributeUsingExplicitValuesForTheConstructorAndASourceAttribute() { CustomAttributeBuilder builder = null; const string expectedName = "Rick"; const int expectedAge = 30; var source = new AnotherCustomAttribute(expectedName, expectedAge, false); builder = ReflectionUtils.CreateCustomAttribute(typeof (AnotherCustomAttribute), new object[] { "Hoop", 2, true }, source); Assert.IsNotNull(builder); var att = (AnotherCustomAttribute) CheckForPresenceOfCustomAttribute(builder, typeof (AnotherCustomAttribute)); Assert.AreEqual(expectedName, att.Name); Assert.AreEqual(expectedAge, att.Age); Assert.IsFalse(att.HasSwallowedExplosives); }
public void CreateCustomAttributeFromSourceAttribute() { CustomAttributeBuilder builder = null; var source = new AnotherCustomAttribute("Rick", 30, true); builder = ReflectionUtils.CreateCustomAttribute(source); Assert.IsNotNull(builder); var att = (AnotherCustomAttribute) CheckForPresenceOfCustomAttribute(builder, typeof (AnotherCustomAttribute)); Assert.AreEqual(source.Name, att.Name); Assert.AreEqual(source.Age, att.Age); Assert.AreEqual(source.HasSwallowedExplosives, att.HasSwallowedExplosives); }