Esempio n. 1
0
        public void SelectSingleType()
        {
            var types = new[]
            {
                CreateTypeStub("type1", TypeAttributes.NestedAssembly),
                CreateTypeStub("this type is removed because of its name", TypeAttributes.NestedFamily),
                CreateTypeStub("type1", TypeAttributes.NestedPublic)
            };
            var bindingFlags = (BindingFlags)1;

            _bindingFlagsEvaluatorMock.Expect(mock => mock.HasRightAttributes(types[0].Attributes, bindingFlags)).Return(false);
            _bindingFlagsEvaluatorMock.Expect(mock => mock.HasRightAttributes(types[2].Attributes, bindingFlags)).Return(true);

            var result = _selector.SelectSingleType(types, bindingFlags, "type1");

            _bindingFlagsEvaluatorMock.VerifyAllExpectations();
            Assert.That(result, Is.SameAs(types[2]));
        }
Esempio n. 2
0
        public void SelectSingleType()
        {
            var types = new[]
            {
                CreateTypeStub("type1", TypeAttributes.Class),
                CreateTypeStub("this type is removed because of its name", TypeAttributes.NotPublic),
                CreateTypeStub("type1", TypeAttributes.Sealed)
            };
            var bindingFlags = (BindingFlags)1;

            _bindingFlagsEvaluatorMock.Setup(mock => mock.HasRightAttributes(types[0].Attributes, bindingFlags)).Returns(false).Verifiable();
            _bindingFlagsEvaluatorMock.Setup(mock => mock.HasRightAttributes(types[2].Attributes, bindingFlags)).Returns(true).Verifiable();

            var result = _selector.SelectSingleType(types, bindingFlags, "type1");

            _bindingFlagsEvaluatorMock.Verify();
            Assert.That(result, Is.SameAs(types[2]));
        }