public void ParentMembers()
        {
            _mockRepository.BackToRecordAll();

            var r1 = new ClassContextBuilder(new MixinConfigurationBuilder(null), typeof(object));
            var r2 = new MixinConfiguration();
            var r3 = _mockRepository.StrictMock <IDisposable> ();

            using (_mockRepository.Ordered())
            {
                _parentBuilderMock.Expect(mock => mock.ForClass <object> ()).Return(r1);
                _parentBuilderMock.Expect(mock => mock.ForClass <string>()).Return(r1);
                _parentBuilderMock.Expect(mock => mock.BuildConfiguration()).Return(r2);
                _parentBuilderMock.Expect(mock => mock.EnterScope()).Return(r3);
            }

            _mockRepository.ReplayAll();

            Assert.That(_classBuilder.ForClass <object> (), Is.SameAs(r1));
            Assert.That(_classBuilder.ForClass <string> (), Is.SameAs(r1));
            Assert.That(_classBuilder.BuildConfiguration(), Is.SameAs(r2));
            Assert.That(_classBuilder.EnterScope(), Is.SameAs(r3));

            _mockRepository.VerifyAll();
        }
        public void AnalyzeIgnoresMixinAttribute()
        {
            IgnoresMixinAttribute attribute = new IgnoresMixinAttribute(s_mixinType);

            _configurationBuilderMock.Expect(mock => mock.ForClass(s_targetClassType)).Return(_classBuilderMock);
            _classBuilderMock.Expect(mock => mock.SuppressMixin(s_mixinType)).Return(_classBuilderMock);

            _mockRepository.ReplayAll();
            attribute.Apply(_configurationBuilderMock, s_targetClassType);
            _mockRepository.VerifyAll();
        }
Beispiel #3
0
        public void Apply()
        {
            var attribute = new ComposedInterfaceAttribute(typeof(string));
            ClassContextBuilder classBuilderMock = _mockRepository.StrictMock <ClassContextBuilder> (_configurationBuilderMock, typeof(string));

            _configurationBuilderMock.Expect(mock => mock.ForClass(typeof(string))).Return(classBuilderMock);
            classBuilderMock.Expect(mock => mock.AddComposedInterface(typeof(IServiceProvider))).Return(classBuilderMock);

            _mockRepository.ReplayAll();
            attribute.Apply(_configurationBuilderMock, typeof(IServiceProvider));
            _mockRepository.VerifyAll();
        }
        public void Apply()
        {
            ExtendsAttribute attribute = new ExtendsAttribute(typeof(object));

            _configurationBuilderMock
            .Expect(
                mock => mock.AddMixinToClass(
                    MixinKind.Extending,
                    typeof(object),
                    _extenderType,
                    MemberVisibility.Private,
                    attribute.AdditionalDependencies,
                    attribute.SuppressedMixins,
                    CreateExpectedOrigin(attribute)))
            .Return(null);

            _mockRepository.ReplayAll();
            attribute.Apply(_configurationBuilderMock, _extenderType);
            _mockRepository.VerifyAll();
        }
        public void Analyze_IncludesClasses_ImplementingIHasComposedInterface()
        {
            var classBuilderMock = MockRepository.GenerateStrictMock <ClassContextBuilder> (typeof(int));

            _configurationBuilderMock.Expect(mock => mock.ForClass(typeof(ClassWithHasComposedInterfaces))).Return(classBuilderMock);
            _configurationBuilderMock.Replay();

            classBuilderMock
            .Expect(mock => mock.AddComposedInterfaces(
                        typeof(ClassWithHasComposedInterfaces.IComposedInterface1),
                        typeof(ClassWithHasComposedInterfaces.IComposedInterface2)))
            .Return(null);
            classBuilderMock.Replay();

            _analyzer.Analyze(typeof(ClassWithHasComposedInterfaces), _configurationBuilderMock);

            _configurationBuilderMock.VerifyAllExpectations();
            classBuilderMock.VerifyAllExpectations();
        }