Ejemplo n.º 1
0
        public void GetCustomAttributeData()
        {
            var customAttributes        = new[] { CustomAttributeDeclarationObjectMother.Create() };
            var genericMethodDefinition = CustomMethodInfoObjectMother.Create(typeArguments: new[] { _typeArgument }, customAttributes: customAttributes);
            var instantiation           = MethodInstantiationObjectMother.Create(genericMethodDefinition);

            Assert.That(instantiation.GetCustomAttributeData(), Is.EqualTo(customAttributes));
        }
Ejemplo n.º 2
0
        public void SubstituteGenericParameters_RemembersSubstitutedTypes()
        {
            var genericMethodDefinition = NormalizingMemberInfoFromExpressionUtility.GetGenericMethodDefinition(() => GenericMethod <Dev.T> (null, null));
            var instantiation           = MethodInstantiationObjectMother.Create(genericMethodDefinition, new[] { _typeArgument });

            var parameterTypes = instantiation.GetParameters().Select(p => p.ParameterType).ToList();

            Assert.That(parameterTypes, Has.Count.EqualTo(2));
            Assert.That(parameterTypes[0].GetGenericTypeDefinition(), Is.SameAs(typeof(List <>)));
            Assert.That(parameterTypes[0].GetGenericArguments().Single(), Is.SameAs(_typeArgument));
            Assert.That(parameterTypes[0], Is.SameAs(parameterTypes[1]));
        }
        public void SetUp()
        {
            _typeArgument = ReflectionObjectMother.GetSomeType();

            var genericTypeDefinition = typeof(GenericType <>);

            _genericTypeParameter      = genericTypeDefinition.GetGenericArguments().Single();
            _declaringType             = TypeInstantiationObjectMother.Create(genericTypeDefinition, new[] { _typeArgument });
            _memberOnTypeInstantiation = MethodOnTypeInstantiationObjectMother.Create(_declaringType);

            var genericMethodDefinition = NormalizingMemberInfoFromExpressionUtility.GetGenericMethodDefinition(() => GenericMethod <Dev.T>());

            _genericMethodParameter = genericMethodDefinition.GetGenericArguments().Single();
            _methodInstantiation    = MethodInstantiationObjectMother.Create(genericMethodDefinition, typeArguments: new[] { _typeArgument });
        }