Inheritance: System.Attribute
Beispiel #1
0
 public void GetAttributeNull()
 {
     var test = new TestAttribute();
     var attribute = test.GetAttribute<ActionNameAttribute>();
     Assert.IsNull(attribute);
 }
 public void IncludeTypes()
 {
     var someObj = new TestAttribute();
     Funcs.IncludeTypes(false, typeof(Object))(someObj, someObj.GetType()).Should().BeFalse();
     Funcs.IncludeTypes(true, typeof(Object))(someObj, someObj.GetType()).Should().BeTrue();
 }
Beispiel #3
0
 public void PropertySetter()
 {
     {
         string s = "a string";
         Assert.Throws<InvalidOperationException>( () => ReflectionHelper.CreateSetter( s, x => x.Length ) );
         Assert.That( ReflectionHelper.CreateSetter( s, x => x.Length, ReflectionHelper.CreateInvalidSetterOption.NullAction ), Is.Null );
         var p = ReflectionHelper.CreateSetter( s, x => x.Length, ReflectionHelper.CreateInvalidSetterOption.VoidAction );
         p( s, 4554 );
     }
     {
         // NUnit.Framework.TestAttribute is an object with a public read/write property...
         TestAttribute a = new TestAttribute();
         var setter = ReflectionHelper.CreateSetter( a, x => x.Description );
         Assert.That( a.Description, Is.Null );
         setter( a, "Hello World!" );
         Assert.That( a.Description, Is.EqualTo( "Hello World!" ) );
     }
 }
 // this is a bogus overload (TestAtttribute is used since its not ever to be passed) that should never be matched
 // by a message handler method
 // (retain this so that we can test against ambiguity in multi-handler-method-resolution)
 /// <summary>The handle message.</summary>
 /// <param name="value">The value.</param>
 /// <exception cref="InvalidOperationException"></exception>
 public void HandleMessage(TestAttribute value) { throw new InvalidOperationException("We should never get here since this overload should never be matched!"); }