예제 #1
0
        public void has_explicit_name()
        {
            var instance = new InstanceUnderTest();
            instance.HasExplicitName().ShouldBeFalse();

            instance.Name = "name of instance";
            instance.HasExplicitName().ShouldBeTrue();
        }
예제 #2
0
        private bool nestedIsValidForLifecycle(ILifecycle lifecycle)
        {
            var instance = new InstanceUnderTest();

            instance.SetLifecycleTo(lifecycle);

            return(instance.IsValidInNestedContainer());
        }
예제 #3
0
        public void has_explicit_name()
        {
            var instance = new InstanceUnderTest();

            instance.HasExplicitName().ShouldBeFalse();

            instance.Name = "name of instance";
            instance.HasExplicitName().ShouldBeTrue();
        }
예제 #4
0
        public void Build_the_InstanceToken()
        {
            var instance = new InstanceUnderTest();
            instance.Name = "name of instance";

            var token = instance.CreateToken();

            Assert.AreEqual(instance.Name, token.Name);
            Assert.AreEqual("InstanceUnderTest", token.Description);
        }
예제 #5
0
        public void Build_the_InstanceToken()
        {
            var instance = new InstanceUnderTest();
            instance.Name = "name of instance";

            var token = instance.CreateToken();

            token.Name.ShouldBe(instance.Name);
            token.Description.ShouldBe("InstanceUnderTest");
        }
예제 #6
0
        public void Build_the_InstanceToken()
        {
            var instance = new InstanceUnderTest();

            instance.Name = "name of instance";

            var token = instance.CreateToken();

            Assert.AreEqual(instance.Name, token.Name);
            Assert.AreEqual("InstanceUnderTest", token.Description);
        }
예제 #7
0
        public void Build_the_InstanceToken()
        {
            var instance = new InstanceUnderTest();

            instance.Name = "name of instance";

            var token = instance.CreateToken();

            token.Name.ShouldBe(instance.Name);
            token.Description.ShouldBe("InstanceUnderTest");
        }
예제 #8
0
        public void add_interceptor_that_cannot_accept_the_returned_type()
        {
            var instance = new InstanceUnderTest
            {
                Type = typeof(ColorRule)
            };

            var interceptor = new ActivatorInterceptor<IGateway>(g => g.DoSomething());

            instance.ReturnedType.CanBeCastTo(interceptor.Accepts)
                .ShouldBeFalse();

            Exception<ArgumentOutOfRangeException>.ShouldBeThrownBy(() => { instance.AddInterceptor(interceptor); });
        }
예제 #9
0
        public void add_interceptor_that_cannot_accept_the_returned_type()
        {
            var instance = new InstanceUnderTest
            {
                Type = typeof(ColorRule)
            };

            var interceptor = new ActivatorInterceptor <IGateway>(g => g.DoSomething());

            instance.ReturnedType.CanBeCastTo(interceptor.Accepts)
            .ShouldBeFalse();

            Exception <ArgumentOutOfRangeException> .ShouldBeThrownBy(() => { instance.AddInterceptor(interceptor); });
        }
예제 #10
0
        public void add_interceptor_when_the_accept_type_is_possible_on_the_return_type()
        {
            var instance = new InstanceUnderTest
            {
                Type = typeof (StubbedGateway)
            };

            var interceptor = new ActivatorInterceptor<IGateway>(g => g.DoSomething());

            instance.ReturnedType.CanBeCastTo(interceptor.Accepts)
                .ShouldBeTrue();

            instance.AddInterceptor(interceptor);

            instance.Interceptors.Single()
                .ShouldBeTheSameAs(interceptor);
        }
예제 #11
0
        public void add_interceptor_when_the_accept_type_is_possible_on_the_return_type()
        {
            var instance = new InstanceUnderTest
            {
                Type = typeof(StubbedGateway)
            };

            var interceptor = new ActivatorInterceptor <IGateway>(g => g.DoSomething());

            instance.ReturnedType.CanBeCastTo(interceptor.Accepts)
            .ShouldBeTrue();

            instance.AddInterceptor(interceptor);

            instance.Interceptors.Single()
            .ShouldBeTheSameAs(interceptor);
        }
예제 #12
0
        public void Instance_Build_Calls_into_its_Interceptor()
        {
            var mocks = new MockRepository();
            var interceptor = mocks.StrictMock<InstanceInterceptor>();
            var buildSession = mocks.StrictMock<BuildSession>();

            var instanceUnderTest = new InstanceUnderTest();
            instanceUnderTest.Interceptor = interceptor;

            var objectReturnedByInterceptor = new object();

            using (mocks.Record())
            {
                Expect.Call(interceptor.Process(instanceUnderTest.TheInstanceThatWasBuilt, buildSession)).Return(
                    objectReturnedByInterceptor);
            }

            using (mocks.Playback())
            {
                Assert.AreEqual(objectReturnedByInterceptor, instanceUnderTest.Build(typeof (object), buildSession));
            }
        }
예제 #13
0
        public void Instance_Build_Calls_into_its_Interceptor()
        {
            var mocks        = new MockRepository();
            var interceptor  = mocks.StrictMock <InstanceInterceptor>();
            var buildSession = mocks.StrictMock <BuildSession>();


            var instanceUnderTest = new InstanceUnderTest();

            instanceUnderTest.Interceptor = interceptor;

            var objectReturnedByInterceptor = new object();

            using (mocks.Record())
            {
                Expect.Call(interceptor.Process(instanceUnderTest.TheInstanceThatWasBuilt, buildSession)).Return(
                    objectReturnedByInterceptor);
            }

            using (mocks.Playback())
            {
                Assert.AreEqual(objectReturnedByInterceptor, instanceUnderTest.Build(typeof(object), buildSession));
            }
        }
예제 #14
0
        private bool nestedIsValidForLifecycle(ILifecycle lifecycle)
        {
            var instance = new InstanceUnderTest();
            instance.SetLifecycleTo(lifecycle);

            return instance.IsValidInNestedContainer();
        }