public void has_explicit_name() { var instance = new InstanceUnderTest(); instance.HasExplicitName().ShouldBeFalse(); instance.Name = "name of instance"; instance.HasExplicitName().ShouldBeTrue(); }
private bool nestedIsValidForLifecycle(ILifecycle lifecycle) { var instance = new InstanceUnderTest(); instance.SetLifecycleTo(lifecycle); return(instance.IsValidInNestedContainer()); }
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"); }
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); }); }
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); }); }
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); }
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); }
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)); } }
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)); } }
private bool nestedIsValidForLifecycle(ILifecycle lifecycle) { var instance = new InstanceUnderTest(); instance.SetLifecycleTo(lifecycle); return instance.IsValidInNestedContainer(); }