public void ReturnType() { var type = ReflectionObjectMother.GetSomeType(); _customMethod.ReturnParameter_ = CustomParameterInfoObjectMother.Create(type: type); Assert.That(_customMethod.ReturnType, Is.SameAs(type)); }
public new void ToString() { var type = ReflectionObjectMother.GetSomeType(); var returnParameter = CustomParameterInfoObjectMother.Create(type: type); var method = CustomMethodInfoObjectMother.Create(returnParameter: returnParameter); var name = "MyProperty"; var property = CustomPropertyInfoObjectMother.Create(name: name, getMethod: method); Assert.That(property.ToString(), Is.EqualTo(type.Name + " MyProperty")); }
public void GetCustomAttributeData() { var customAttributes = new[] { CustomAttributeDeclarationObjectMother.Create() }; var member = MethodOnTypeInstantiationObjectMother.Create(); var parameter = CustomParameterInfoObjectMother.Create(member, customAttributes: customAttributes); var parameterInstantiation = new MemberParameterOnInstantiation(member, parameter); Assert.That(parameterInstantiation.GetCustomAttributeData(), Is.EqualTo(customAttributes)); }
public void GetCustomAttributeData() { var member = ReflectionObjectMother.GetSomeProperty(); var customAttribute = CustomAttributeDeclarationObjectMother.Create(); var parameter = CustomParameterInfoObjectMother.Create(customAttributes: new ICustomAttributeData[] { customAttribute }); var wrapper = new PropertyParameterInfoWrapper(member, parameter); Assert.That(wrapper.GetCustomAttributeData(), Is.EqualTo(new[] { customAttribute })); }
public void Initialization_OnMethodInstantiation() { var parameter = CustomParameterInfoObjectMother.Create(type: _genericMethodParameter); var result = new MemberParameterOnInstantiation(_methodInstantiation, parameter); Assert.That(result.Member, Is.SameAs(_methodInstantiation)); Assert.That(result.MemberParameterOnGenericDefinition, Is.SameAs(parameter)); Assert.That(result.ParameterType, Is.SameAs(_typeArgument)); }
public void ToDebugString() { var declaringType = CustomTypeObjectMother.Create(name: "Abc"); var ctor = CustomConstructorInfoObjectMother.Create( declaringType, parameters: new ParameterInfo[] { CustomParameterInfoObjectMother.Create(type: typeof(int)) }); var expected = "TestableCustomConstructor = \"Void .ctor(Int32)\", DeclaringType = \"Abc\""; Assert.That(ctor.ToDebugString(), Is.EqualTo(expected)); }
public void SetUp() { _typeParameter = MutableGenericParameterObjectMother.Create(); _parameter = CustomParameterInfoObjectMother.Create(); _genericMethodDefinition = CustomMethodInfoObjectMother.Create(parameters: new[] { _parameter }, typeArguments: new[] { _typeParameter }); _typeArgument = CustomTypeObjectMother.Create(); var info = new MethodInstantiationInfo(_genericMethodDefinition, new[] { _typeArgument }); _instantiation = new MethodInstantiation(info); }
public new void ToString() { _constructor.Parameters = new ParameterInfo[] { CustomParameterInfoObjectMother.Create(type: typeof(int)), CustomParameterInfoObjectMother.Create(type: typeof(string).MakeByRefType()) }; Assert.That(_constructor.ToString(), Is.EqualTo("Void .ctor(Int32, String&)")); }
public void SetUp() { _indexParameter = CustomParameterInfoObjectMother.Create(); _declaringType = TypeInstantiationObjectMother.Create(); _getMethod = MethodOnTypeInstantiationObjectMother.Create(_declaringType, typeof(GenericType <>).GetMethod("get_Item")); _setMethod = MethodOnTypeInstantiationObjectMother.Create(_declaringType, typeof(GenericType <>).GetMethod("set_Item")); _originalProperty = CustomPropertyInfoObjectMother.Create( indexParameters: new[] { _indexParameter }, getMethod: _getMethod, setMethod: _setMethod); _property = new PropertyOnTypeInstantiation(_declaringType, _originalProperty, _getMethod, _setMethod); }
public void ToDebugString() { var method = CustomMethodInfoObjectMother.Create( declaringType: MutableTypeObjectMother.Create(name: "AbcProxy"), name: "Xxx", returnParameter: CustomParameterInfoObjectMother.Create(position: -1, type: typeof(void)), parameters: new[] { CustomParameterInfoObjectMother.Create(type: typeof(int)) }); var expected = "TestableCustomMethod = \"Void Xxx(Int32)\", DeclaringType = \"AbcProxy\""; Assert.That(method.ToDebugString(), Is.EqualTo(expected)); }
public new void ToString() { var parameters = new[] { CustomParameterInfoObjectMother.Create(type: typeof(int)), CustomParameterInfoObjectMother.Create(type: typeof(string).MakeByRefType()) }; var returnParameter = CustomParameterInfoObjectMother.Create(type: typeof(string)); var method = CustomMethodInfoObjectMother.Create(name: "Xxx", returnParameter: returnParameter, parameters: parameters); Assert.That(method.ToString(), Is.EqualTo("String Xxx(Int32, String&)")); }
public void Initialization_OnTypeInstantiation() { var parameter = CustomParameterInfoObjectMother.Create(type: _genericTypeParameter); var result = new MemberParameterOnInstantiation(_memberOnTypeInstantiation, parameter); Assert.That(result.Member, Is.SameAs(_memberOnTypeInstantiation)); Assert.That(result.MemberParameterOnGenericDefinition, Is.SameAs(parameter)); Assert.That(result.Position, Is.EqualTo(parameter.Position)); Assert.That(result.Name, Is.EqualTo(parameter.Name)); Assert.That(result.Attributes, Is.EqualTo(parameter.Attributes)); Assert.That(result.ParameterType, Is.SameAs(_typeArgument)); }
public void SetUp() { _declaringType = CustomTypeObjectMother.Create(); _type = ReflectionObjectMother.GetSomeType(); _valueParameter = CustomParameterInfoObjectMother.Create(type: _type); var indexParameterType = ReflectionObjectMother.GetSomeOtherType(); _indexParameter = CustomParameterInfoObjectMother.Create(type: indexParameterType); _getMethod = CustomMethodInfoObjectMother.Create(attributes: MethodAttributes.Public, parameters: new[] { _indexParameter }, returnParameter: _valueParameter); _setMethod = CustomMethodInfoObjectMother.Create(attributes: MethodAttributes.Public, parameters: new[] { _indexParameter, _valueParameter }); _readOnlyProperty = CustomPropertyInfoObjectMother.Create(getMethod: _getMethod); _writeOnlyProperty = CustomPropertyInfoObjectMother.Create(setMethod: _setMethod); }
public void Initialization() { var parameter = CustomParameterInfoObjectMother.Create(); var ctor = CustomConstructorInfoObjectMother.Create(_declaringType, parameters: new[] { parameter }); var result = new ConstructorOnTypeInstantiation(_declaringType, ctor); Assert.That(result.DeclaringType, Is.SameAs(_declaringType)); Assert.That(result.Attributes, Is.EqualTo(ctor.Attributes)); Assert.That(result.ConstructorOnGenericType, Is.SameAs(ctor)); var memberParameter = result.GetParameters().Single(); Assert.That(memberParameter, Is.TypeOf <MemberParameterOnInstantiation>()); Assert.That(memberParameter.Member, Is.SameAs(result)); Assert.That(memberParameter.As <MemberParameterOnInstantiation>().MemberParameterOnGenericDefinition, Is.SameAs(parameter)); }
public void ToDebugString() { var declaringType = CustomTypeObjectMother.Create(); var type = ReflectionObjectMother.GetSomeType(); var returnParameter = CustomParameterInfoObjectMother.Create(type: type); var method = CustomMethodInfoObjectMother.Create(returnParameter: returnParameter); var name = "MyProperty"; var property = CustomPropertyInfoObjectMother.Create(declaringType, name, getMethod: method); // Note: ToDebugString is defined in CustomFieldInfo base class. Assertion.IsNotNull(property.DeclaringType); var declaringTypeName = property.DeclaringType.Name; var propertyTypeName = property.PropertyType.Name; var propertyName = property.Name; var expected = "TestableCustomProperty = \"" + propertyTypeName + " " + propertyName + "\", DeclaringType = \"" + declaringTypeName + "\""; Assert.That(property.ToDebugString(), Is.EqualTo(expected)); }
public void SetUp() { _declaringType = CustomTypeObjectMother.Create(); _name = "abc"; _attributes = (MethodAttributes)7; _returnParameter = CustomParameterInfoObjectMother.Create(); _customMethod = new TestableCustomMethodInfo(_declaringType, _name, _attributes, null, Type.EmptyTypes) { ReturnParameter_ = _returnParameter }; _typeArgument = ReflectionObjectMother.GetSomeType(); _genericMethodUnderlyingDefinition = ReflectionObjectMother.GetSomeGenericMethodDefinition(); _genericMethod = CustomMethodInfoObjectMother.Create( genericMethodDefintion: _genericMethodUnderlyingDefinition, typeArguments: new[] { _typeArgument }); _typeParameter = ReflectionObjectMother.GetSomeGenericParameter(); _genericMethodDefinition = CustomMethodInfoObjectMother.Create(typeArguments: new[] { _typeParameter }); }
public new void ToString() { var parameter = CustomParameterInfoObjectMother.Create(name: "param1", type: typeof(int), attributes: ParameterAttributes.Out); Assert.That(parameter.ToString(), Is.EqualTo("Int32 param1")); }