Beispiel #1
0
        public void SelectFields()
        {
            var candidates = new[]
            {
                CreateFieldStub(attributes: FieldAttributes.Assembly),
                CreateFieldStub(attributes: FieldAttributes.Family),
                CreateFieldStub(attributes: FieldAttributes.FamORAssem)
            };
            var bindingFlags = (BindingFlags)1;

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

            var result = _selector.SelectFields(candidates, bindingFlags, _someDeclaringType).ForceEnumeration();

            _bindingFlagsEvaluatorMock.VerifyAllExpectations();
            Assert.That(result, Is.EqualTo(new[] { candidates[0], candidates[2] }));
        }