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

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

            instance.SetLifecycleTo(lifecycle);

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

            instance.HasExplicitName().ShouldBeFalse();

            instance.Name = "name of instance";
            instance.HasExplicitName().ShouldBeTrue();
        }
Beispiel #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);
        }
        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");
        }
Beispiel #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);
        }
Beispiel #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");
        }
        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); });
        }
Beispiel #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); });
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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));
            }
        }
Beispiel #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));
            }
        }
Beispiel #14
0
        private bool nestedIsValidForLifecycle(ILifecycle lifecycle)
        {
            var instance = new InstanceUnderTest();
            instance.SetLifecycleTo(lifecycle);

            return instance.IsValidInNestedContainer();
        }