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 MustNotInterceptAttributeTest()
        {
            RealServiceExecuted.ResetExecuted();
            MyInterceptor.ResetExecuted();

            unityContainer.RegisterType <IMyFooService, MyFooServiceWithDoNotInterceptAttribute>();
            unityContainer = InterceptionHelper.InterceptContainer(unityContainer, new IInterceptor[] { new MyInterceptor() });

            var myService = unityContainer.Resolve <IMyFooService>();

            // ACT
            myService.Execute();

            // ASSERT
            Assert.IsTrue(RealServiceExecuted.Executed);
            Assert.IsFalse(MyInterceptor.ExecutedBefore);
            Assert.IsFalse(MyInterceptor.ExecutedAfter);
        }
        public void AttributeInterceptorTest()
        {
            // ARRANGE
            RealServiceExecuted.ResetExecuted();
            MyInterceptor.ResetExecuted();

            unityContainer.RegisterType <IMyFooService, MyFooServiceWithAttributeInterceptor>();
            unityContainer = InterceptionHelper.InterceptContainer(unityContainer, new IInterceptor[] { });

            var myService = unityContainer.Resolve <IMyFooService>();

            // ACT
            myService.Execute();

            // ASSERT
            Assert.IsTrue(RealServiceExecuted.Executed);
            Assert.IsTrue(MyInterceptor.ExecutedBefore);
            Assert.IsTrue(MyInterceptor.ExecutedAfter);
        }
        public void GlobalInterceptorTypesOverloadTest()
        {
            // ARRANGE
            RealServiceExecuted.ResetExecuted();
            MyInterceptor.ResetExecuted();

            unityContainer.RegisterType <IMyFooService, MyFooService>();
            unityContainer = InterceptionHelper.InterceptContainer(unityContainer, new Type[] { typeof(MyInterceptor) });

            var myService = unityContainer.Resolve <IMyFooService>();

            // ACT
            myService.Execute();

            // ASSERT
            Assert.IsTrue(RealServiceExecuted.Executed);
            Assert.IsTrue(MyInterceptor.ExecutedBefore);
            Assert.IsTrue(MyInterceptor.ExecutedAfter);
        }