public void select_interceptors() { var activator1 = new ActivatorInterceptor<ITarget>(x => x.Activate()); var activator2 = new ActivatorInterceptor<Target>(x => x.UseSession(null)); var activator3 = new ActivatorInterceptor<Target>(x => x.ThrowUp()); var activator4 = new ActivatorInterceptor<ITarget>(x => x.Debug()); var activator5 = new ActivatorInterceptor<IGateway>(x => x.DoSomething()); var policies = new InterceptorPolicies(); policies.Add(activator1.ToPolicy()); policies.Add(activator2.ToPolicy()); policies.Add(activator3.ToPolicy()); policies.Add(activator4.ToPolicy()); policies.Add(activator5.ToPolicy()); policies.SelectInterceptors(typeof(ITarget), new SmartInstance<Target>()) .ShouldHaveTheSameElementsAs(activator1, activator2, activator3, activator4); policies.SelectInterceptors(typeof(ITarget), new SmartInstance<ATarget>()) .ShouldHaveTheSameElementsAs(activator1, activator4); policies.SelectInterceptors(typeof(ITarget), new SmartInstance<StubbedGateway>()) .ShouldHaveTheSameElementsAs(activator5); }
public void select_interceptors() { var activator1 = new ActivatorInterceptor <ITarget>(x => x.Activate()); var activator2 = new ActivatorInterceptor <Target>(x => x.UseSession(null)); var activator3 = new ActivatorInterceptor <Target>(x => x.ThrowUp()); var activator4 = new ActivatorInterceptor <ITarget>(x => x.Debug()); var activator5 = new ActivatorInterceptor <IGateway>(x => x.DoSomething()); var policies = new InterceptorPolicies(); policies.Add(activator1.ToPolicy()); policies.Add(activator2.ToPolicy()); policies.Add(activator3.ToPolicy()); policies.Add(activator4.ToPolicy()); policies.Add(activator5.ToPolicy()); policies.SelectInterceptors(typeof(ITarget), new SmartInstance <Target>()) .ShouldHaveTheSameElementsAs(activator1, activator2, activator3, activator4); policies.SelectInterceptors(typeof(ITarget), new SmartInstance <ATarget>()) .ShouldHaveTheSameElementsAs(activator1, activator4); policies.SelectInterceptors(typeof(ITarget), new SmartInstance <StubbedGateway>()) .ShouldHaveTheSameElementsAs(activator5); }
public void do_not_duplicate_interceptor_policies() { var theActivator = new ActivatorInterceptor<ITarget>(x => x.Activate()); var policy1 = new InterceptorPolicy<ITarget>(theActivator); var policy2 = new InterceptorPolicy<ITarget>(theActivator); policy1.ShouldEqual(policy2); var policies = new InterceptorPolicies(); policies.Add(policy1); policies.Add(policy2); policies.Add(policy1); policies.Add(policy2); policies.Policies.Single().ShouldBeTheSameAs(policy1); }
public void do_not_duplicate_interceptor_policies() { var theActivator = new ActivatorInterceptor <ITarget>(x => x.Activate()); var policy1 = new InterceptorPolicy <ITarget>(theActivator); var policy2 = new InterceptorPolicy <ITarget>(theActivator); policy1.ShouldEqual(policy2); var policies = new InterceptorPolicies(); policies.Add(policy1); policies.Add(policy2); policies.Add(policy1); policies.Add(policy2); policies.Policies.Single().ShouldBeTheSameAs(policy1); }