public void NoTransparentProxyInterceptionOccursWhenNoPoliciesAreDefined_MBR() { IUnityContainer uc = new UnityContainer(); uc.AddNewExtension <Interception>(); uc.RegisterType <InterceptionTestClass_MBR>(new ContainerControlledLifetimeManager()); InterceptionTestClass_MBR beforeInterception = uc.Resolve <InterceptionTestClass_MBR>(); uc.Configure <Interception>() .SetDefaultInterceptorFor <InterceptionTestClass_MBR>(new TransparentProxyInterceptor()); InterceptionTestClass_MBR afterInterception = uc.Resolve <InterceptionTestClass_MBR>(); Assert.AreSame(beforeInterception, afterInterception); Assert.IsFalse(RemotingServices.IsTransparentProxy(beforeInterception)); Assert.IsFalse(RemotingServices.IsTransparentProxy(afterInterception)); }
public void TransparentProxyInterceptionOccursWhenPoliciesAreDefined_MBR() { IUnityContainer uc = new UnityContainer(); uc.AddNewExtension <Interception>(); uc.RegisterType <InterceptionTestClass_MBR>(new ContainerControlledLifetimeManager()); InterceptionTestClass_MBR beforeInterception = uc.Resolve <InterceptionTestClass_MBR>(); uc.Configure <Interception>() .SetDefaultInterceptorFor <InterceptionTestClass_MBR>(new TransparentProxyInterceptor()) .AddPolicy("Always Matches") .AddMatchingRule <AlwaysMatchingRule>() .AddCallHandler <ConvenienceInterceptionAPI.CallCountHandler>(); InterceptionTestClass_MBR afterInterception = uc.Resolve <InterceptionTestClass_MBR>(); Assert.AreNotSame(beforeInterception, afterInterception); Assert.IsFalse(RemotingServices.IsTransparentProxy(beforeInterception)); Assert.IsTrue(RemotingServices.IsTransparentProxy(afterInterception)); }