public void Initialization() { var parameter = ReflectionObjectMother.GetSomeParameter(); var method = CustomMethodInfoObjectMother.Create(_declaringType, parameters: new[] { parameter }); var instantiation = new MethodOnTypeInstantiation(_declaringType, method); Assert.That(instantiation.DeclaringType, Is.SameAs(_declaringType)); Assert.That(instantiation.Name, Is.EqualTo(method.Name)); Assert.That(instantiation.Attributes, Is.EqualTo(method.Attributes)); Assert.That(instantiation.IsGenericMethod, Is.False); Assert.That(() => instantiation.GetGenericMethodDefinition(), Throws.InvalidOperationException); Assert.That(instantiation.GetGenericArguments(), Is.Empty); Assert.That(instantiation.MethodOnGenericType, Is.SameAs(method)); var returnParameter = instantiation.ReturnParameter; Assertion.IsNotNull(returnParameter); Assert.That(returnParameter, Is.TypeOf <MemberParameterOnInstantiation>()); Assert.That(returnParameter.Member, Is.SameAs(instantiation)); Assert.That(returnParameter.As <MemberParameterOnInstantiation>().MemberParameterOnGenericDefinition, Is.SameAs(method.ReturnParameter)); var memberParameter = instantiation.GetParameters().Single(); Assert.That(memberParameter, Is.TypeOf <MemberParameterOnInstantiation>()); Assert.That(memberParameter.Member, Is.SameAs(instantiation)); Assert.That(memberParameter.As <MemberParameterOnInstantiation>().MemberParameterOnGenericDefinition, Is.SameAs(parameter)); }
public void Initialization_NonTypeInstantiationMember() { var member = ReflectionObjectMother.GetSomeMember(); var parameter = ReflectionObjectMother.GetSomeParameter(); Dev.Null = new MemberParameterOnInstantiation(member, parameter); }
public void SetUp() { var attributeTarget = ReflectionObjectMother.GetSomeType(); _key1 = new CustomAttributeDataCacheKey(attributeTarget, inherit: true); _key2 = new CustomAttributeDataCacheKey(ReflectionObjectMother.GetSomeParameter(), true); _key3 = new CustomAttributeDataCacheKey(attributeTarget, false); _key4 = new CustomAttributeDataCacheKey(attributeTarget, true); }
public void Initialization_NonTypeInstantiationMember() { var member = ReflectionObjectMother.GetSomeMember(); var parameter = ReflectionObjectMother.GetSomeParameter(); Assert.That( () => Dev.Null = new MemberParameterOnInstantiation(member, parameter), Throws.ArgumentException .With.ArgumentExceptionMessageEqualTo( "MemberParameterOnInstantiation can only represent parameters of members on TypeInstantiation or parameters of " + "MethodInstantiation instances.", "declaringMember")); }
public void Initialization() { var parameter = ReflectionObjectMother.GetSomeParameter(); var member = ReflectionObjectMother.GetSomeProperty(); var wrapper = new PropertyParameterInfoWrapper(member, parameter); Assert.That(wrapper.Member, Is.SameAs(member)); Assert.That(wrapper.Position, Is.EqualTo(parameter.Position)); Assert.That(wrapper.Name, Is.EqualTo(parameter.Name)); Assert.That(wrapper.ParameterType, Is.SameAs(parameter.ParameterType)); Assert.That(wrapper.Attributes, Is.EqualTo(parameter.Attributes)); }