Пример #1
0
        public void ChildSpecificAccept()
        {
            var visitorMock = MockRepository.GenerateMock <IDefinitionVisitor>();
            var definition  = DefinitionObjectMother.CreateTargetClassDefinition(typeof(BaseType1), typeof(BT1Mixin1)).Mixins[0];

            var interfaceIntroduction           = DefinitionObjectMother.CreateInterfaceIntroductionDefinition(definition);
            var nonInterfaceIntroduction        = DefinitionObjectMother.CreateNonInterfaceIntroductionDefinition(definition);
            var attributeIntroduction           = DefinitionObjectMother.CreateAttributeIntroductionDefinition(definition);
            var nonAttributeIntroduction        = DefinitionObjectMother.CreateNonAttributeIntroductionDefinition(definition);
            var suppressedAttributeIntroduction = DefinitionObjectMother.CreateSuppressedAttributeIntroductionDefinition(definition);
            var targetCallDependency            = DefinitionObjectMother.CreateTargetCallDependencyDefinition(definition);
            var nextCallDependency = DefinitionObjectMother.CreateNextCallDependencyDefinition(definition);
            var mixinDependency    = DefinitionObjectMother.CreateMixinDependencyDefinition(definition);

            using (visitorMock.GetMockRepository().Ordered())
            {
                visitorMock.Expect(mock => mock.Visit(definition));
                visitorMock.Expect(mock => mock.Visit(interfaceIntroduction));
                visitorMock.Expect(mock => mock.Visit(nonInterfaceIntroduction));
                visitorMock.Expect(mock => mock.Visit(attributeIntroduction));
                visitorMock.Expect(mock => mock.Visit(nonAttributeIntroduction));
                visitorMock.Expect(mock => mock.Visit(suppressedAttributeIntroduction));
                visitorMock.Expect(mock => mock.Visit(targetCallDependency));
                visitorMock.Expect(mock => mock.Visit(nextCallDependency));
                visitorMock.Expect(mock => mock.Visit(mixinDependency));
            }

            visitorMock.Replay();
            PrivateInvoke.InvokeNonPublicMethod(definition, "ChildSpecificAccept", visitorMock);
            visitorMock.VerifyAllExpectations();
        }
        private static TargetClassDefinition CreateTargetClassDefinition(params Tuple <Type, bool, Type[]>[] mixinTypesAndDependencies)
        {
            var targetClassDefinition = DefinitionObjectMother.CreateTargetClassDefinition(typeof(NullTarget));

            foreach (var tuple in mixinTypesAndDependencies)
            {
                DefinitionObjectMother.CreateMixinDefinition(targetClassDefinition, tuple.Item1, tuple.Item2);
            }

            foreach (var tuple in mixinTypesAndDependencies)
            {
                foreach (var dependency in tuple.Item3)
                {
                    DefinitionObjectMother.CreateMixinDependencyDefinition(targetClassDefinition.Mixins[tuple.Item1], targetClassDefinition.Mixins[dependency]);
                }
            }

            return(targetClassDefinition);
        }