Example #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();
        }
        public void CreateRequiredMethodDefinitions_NoMatch()
        {
            var targetClassDefinition = DefinitionObjectMother.CreateTargetClassDefinition(typeof(object));
            var requiringMixin        = DefinitionObjectMother.CreateMixinDefinition(targetClassDefinition, typeof(string));

            var dependency  = DefinitionObjectMother.CreateTargetCallDependencyDefinition(requiringMixin);
            var requirement = dependency.RequiredType;

            DefinitionObjectMother.AddRequiringDependency(requirement, dependency);

            var builder = new DuckTypingRequiredMethodDefinitionCollector(targetClassDefinition);

            builder.CreateRequiredMethodDefinitions(requirement).ToArray();
        }