예제 #1
0
        public void IsAssignableFromFast_TypeInstantiations()
        {
            var genericTypeDefinition = typeof(List <>);
            var instantiation1        = TypeInstantiationObjectMother.Create(genericTypeDefinition, new[] { typeof(int) });
            var instantiation2        = TypeInstantiationObjectMother.Create(genericTypeDefinition, new[] { typeof(double) });
            var instantiation3        = TypeInstantiationObjectMother.Create(genericTypeDefinition, new[] { typeof(int) });

            Assert.That(instantiation1.IsTypePipeAssignableFrom(instantiation2), Is.False);
            Assert.That(instantiation1.IsTypePipeAssignableFrom(instantiation3), Is.True);
        }
예제 #2
0
        public void SetUp()
        {
            _declaringType = TypeInstantiationObjectMother.Create();
            _originalEvent = GetType().GetEvent("Event");
            _addMethod     = MethodOnTypeInstantiationObjectMother.Create(_declaringType, GetType().GetMethod("add_Event"));
            _removeMethod  = MethodOnTypeInstantiationObjectMother.Create(_declaringType, GetType().GetMethod("remove_Event"));
            _raiseMethod   = MethodOnTypeInstantiationObjectMother.Create(_declaringType, GetType().GetMethod("RaiseMethod"));

            _event = new EventOnTypeInstantiation(_declaringType, _originalEvent, _addMethod, _removeMethod, _raiseMethod);
        }
        public void Add()
        {
            var instantiation = TypeInstantiationObjectMother.Create();

            _context.Add(_info, instantiation);

            var result = _context.Instantiate(_info);

            Assert.That(result, Is.SameAs(instantiation));
        }
        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 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 });
        }
예제 #6
0
        public void ContainsGenericParameters()
        {
            Assert.That(_customMethod.ContainsGenericParameters, Is.False);
            Assert.That(_genericMethod.ContainsGenericParameters, Is.False);
            Assert.That(_genericMethodDefinition.ContainsGenericParameters, Is.True);

            var typeInstantiation = TypeInstantiationObjectMother.Create(typeof(IList <>), new[] { ReflectionObjectMother.GetSomeGenericParameter() });
            var method1           = CustomMethodInfoObjectMother.Create(
                genericMethodDefintion: _genericMethodUnderlyingDefinition, typeArguments: new[] { typeInstantiation });

            Assert.That(method1.ContainsGenericParameters, Is.True);

            var genericTypeDefinition = CustomTypeObjectMother.Create(typeArguments: new[] { ReflectionObjectMother.GetSomeGenericParameter() });
            var method2 = CustomMethodInfoObjectMother.Create(declaringType: genericTypeDefinition);

            Assert.That(method2.ContainsGenericParameters, Is.True);
        }
 public void SetUp()
 {
     _declaringType = TypeInstantiationObjectMother.Create();
 }
 public void SetUp()
 {
     _typeParameter = typeof(GenericType <>).GetGenericArguments().Single();
     _typeArgument  = ReflectionObjectMother.GetSomeType();
     _declaringType = TypeInstantiationObjectMother.Create(typeof(GenericType <>), new[] { _typeArgument });
 }