public void Initialization_Field_ValueAssignable() { var propertyInfo = CustomAttributeReflectionObjectMother.GetFieldWithType(typeof(ValueType)); int value = 7; new NamedArgumentDeclaration(propertyInfo, value); }
public void Initialization_Field_WithNullArgument() { var nullableMember2 = CustomAttributeReflectionObjectMother.GetFieldWithType(typeof(object)); var nullableMember1 = CustomAttributeReflectionObjectMother.GetFieldWithType(typeof(int?)); new NamedArgumentDeclaration(nullableMember1, null); new NamedArgumentDeclaration(nullableMember2, null); }
public void Initialization_Field_WithInvalidNullArgument() { var nonNullMember = CustomAttributeReflectionObjectMother.GetFieldWithType(typeof(int)); Assert.That( () => new NamedArgumentDeclaration(nonNullMember, null), Throws.ArgumentException .With.ArgumentExceptionMessageEqualTo("Parameter 'value' has type '<null>' when type 'System.Int32' was expected.", "value")); }
public void Initialization_Field_ValueNotAssignable() { var propertyInfo = CustomAttributeReflectionObjectMother.GetFieldWithType(typeof(ValueType)); string value = "not assignable"; Assert.That( () => new NamedArgumentDeclaration(propertyInfo, value), Throws.ArgumentException .With.ArgumentExceptionMessageEqualTo( "Parameter 'value' has type 'System.String' when type 'System.ValueType' was expected.", "value")); }
public void Initialization_Field() { var fieldInfo = CustomAttributeReflectionObjectMother.GetFieldWithType(typeof(ValueType)); int value = 7; var declaration = new NamedArgumentDeclaration(fieldInfo, value); Assert.That(declaration.MemberInfo, Is.SameAs(fieldInfo)); Assert.That(declaration.MemberType, Is.SameAs(typeof(ValueType))); Assert.That(declaration.Value, Is.EqualTo(value)); }
public void Initialization_Field_WithInvalidNullArgument() { var nonNullMember = CustomAttributeReflectionObjectMother.GetFieldWithType(typeof(int)); new NamedArgumentDeclaration(nonNullMember, null); }