Exemplo n.º 1
0
        public void SelectSingleField()
        {
            var fields = new[]
            {
                CreateFieldStub("field1", FieldAttributes.Assembly),
                CreateFieldStub("this field is removed because of its name", FieldAttributes.Family),
                CreateFieldStub("field1", FieldAttributes.Public)
            };
            var bindingFlags = (BindingFlags)1;

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

            var result = _selector.SelectSingleField(fields, bindingFlags, "field1", _someDeclaringType);

            _bindingFlagsEvaluatorMock.VerifyAllExpectations();
            Assert.That(result, Is.SameAs(fields[2]));
        }