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); }