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_FromGenericMethodDefinition() { var typeArguments = new[] { ReflectionObjectMother.GetSomeType() }; var method = CustomMethodInfoObjectMother.Create(_declaringType, typeArguments: typeArguments); Assert.That(method.IsGenericMethodDefinition, Is.True); var instantiation = new MethodOnTypeInstantiation(_declaringType, method); Assert.That(instantiation.IsGenericMethod, Is.True); Assert.That(instantiation.IsGenericMethodDefinition, Is.True); Assert.That(instantiation.GetGenericMethodDefinition(), Is.SameAs(instantiation)); Assert.That(instantiation.GetGenericArguments(), Is.EqualTo(typeArguments)); }