public void CallingConvention() { var constructor = CustomConstructorInfoObjectMother.Create(attributes: 0); var typeInitializer = CustomConstructorInfoObjectMother.Create(attributes: MethodAttributes.Static); Assert.That(constructor.CallingConvention, Is.EqualTo(CallingConventions.Standard | CallingConventions.HasThis)); Assert.That(typeInitializer.CallingConvention, Is.EqualTo(CallingConventions.Standard)); }
public void GetCustomAttributeData() { var customAttributes = new[] { CustomAttributeDeclarationObjectMother.Create() }; var ctor = CustomConstructorInfoObjectMother.Create(customAttributes: customAttributes); var ctorInstantiation = new ConstructorOnTypeInstantiation(_declaringType, ctor); Assert.That(ctorInstantiation.GetCustomAttributeData(), Is.EqualTo(customAttributes)); }
public void Name() { var constructor = CustomConstructorInfoObjectMother.Create(attributes: 0); var typeInitializer = CustomConstructorInfoObjectMother.Create(attributes: MethodAttributes.Static); Assert.That(constructor.Name, Is.EqualTo(".ctor")); Assert.That(typeInitializer.Name, Is.EqualTo(".cctor")); }
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 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)); }