public void GlobalAndAttributeInterceptorConfigureOrderTest() { // ARRANGE RealServiceExecuted.ResetExecuted(); MyInterceptor.ResetExecuted(); MyOtherInterceptor.ResetExecuted(); InterceptorsCalled.ResetList(); unityContainer.RegisterType <IMyFooService, MyFooServiceWithAttributeInterceptor>(); unityContainer = InterceptionHelper.InterceptContainer(unityContainer, new IInterceptor[] { new MyOtherInterceptor() }, new InterceptionOptions { GlobalInterceptorsOrder = GlobalInterceptorsOrder.AfterAttributeInterceptors }); var myService = unityContainer.Resolve <IMyFooService>(); // ACT myService.Execute(); // ASSERT Assert.IsTrue(RealServiceExecuted.Executed); Assert.IsTrue(MyInterceptor.ExecutedBefore); Assert.IsTrue(MyInterceptor.ExecutedAfter); Assert.IsTrue(MyOtherInterceptor.ExecutedBefore); Assert.IsTrue(MyOtherInterceptor.ExecutedAfter); Assert.IsTrue(InterceptorsCalled.List[0].GetType() == typeof(MyOtherInterceptor)); Assert.IsTrue(InterceptorsCalled.List[1].GetType() == typeof(MyInterceptor)); }
public void OrderedAttributeInterceptorTest() { // ARRANGE RealServiceExecuted.ResetExecuted(); InterceptorsCalled.ResetList(); unityContainer.RegisterType <IMyFooService, MyFooServiceWithOrderedAttributeInterceptor>(); unityContainer = InterceptionHelper.InterceptContainer(unityContainer, new IInterceptor[] { }); var myService = unityContainer.Resolve <IMyFooService>(); // ACT myService.Execute(); // ASSERT Assert.IsTrue(RealServiceExecuted.Executed); Assert.IsTrue(InterceptorsCalled.List[0].GetType() == typeof(MyInterceptor)); Assert.IsTrue(InterceptorsCalled.List[1].GetType() == typeof(MyOtherInterceptor)); }