Beispiel #1
0
        public void SetUp()
        {
            _memberSelectorMock = MockRepository.GenerateStrictMock <IMemberSelector>();

            _name       = "TypeName";
            _namespace  = "MyNamespace";
            _attributes = (TypeAttributes)7;

            _customType = new TestableCustomType(
                _name,
                _namespace,
                _attributes,
                genericTypeDefinition: null,
                typeArguments: Type.EmptyTypes)
            {
                NestedTypes  = new[] { ReflectionObjectMother.GetSomeType() },
                Interfaces   = new[] { typeof(IDisposable) },
                Fields       = new[] { ReflectionObjectMother.GetSomeField() },
                Constructors = new[] { ReflectionObjectMother.GetSomeConstructor() },
                Methods      = new[] { ReflectionObjectMother.GetSomeMethod() },
                Properties   = new[] { ReflectionObjectMother.GetSomeProperty() },
                Events       = new[] { ReflectionObjectMother.GetSomeEvent() }
            };
            _customType.SetMemberSelector(_memberSelectorMock);

            _typeArgument = ReflectionObjectMother.GetSomeType();
            _genericTypeUnderlyingDefinition = typeof(IList <>);
            _genericType = CustomTypeObjectMother.Create(
                name: "GenericType`1", genericTypeDefinition: _genericTypeUnderlyingDefinition, typeArguments: new[] { _typeArgument });

            _typeParameter         = ReflectionObjectMother.GetSomeGenericParameter();
            _genericTypeDefinition = CustomTypeObjectMother.Create(name: "GenericTypeDefinition`1", typeArguments: new[] { _typeParameter });
        }
Beispiel #2
0
        public void GetEvents()
        {
            Assert.That(_customType.Events, Is.Not.Null.And.Not.Empty);
            var bindingAttr = BindingFlags.NonPublic;
            var fakeResult  = new[] { ReflectionObjectMother.GetSomeEvent() };

            _memberSelectorMock.Expect(mock => mock.SelectEvents(_customType.Events, bindingAttr, _customType)).Return(fakeResult);

            var result = _customType.GetEvents(bindingAttr);

            _memberSelectorMock.VerifyAllExpectations();
            Assert.That(result, Is.EqualTo(fakeResult));
        }
Beispiel #3
0
        public void GetEvent()
        {
            Assert.That(_customType.Fields, Is.Not.Null.And.Not.Empty);
            var name        = "some name";
            var bindingAttr = BindingFlags.NonPublic;
            var fakeResult  = ReflectionObjectMother.GetSomeEvent();

            _memberSelectorMock.Expect(mock => mock.SelectSingleEvent(_customType.Events, bindingAttr, name, _customType)).Return(fakeResult);

            var resultField = _customType.GetEvent(name, bindingAttr);

            _memberSelectorMock.VerifyAllExpectations();
            Assert.That(resultField, Is.SameAs(fakeResult));
        }