public virtual void CanCastToImplementationClass() { IUnityContainer container = GetContainer(); IInterceptionTestClass sut = this.GetSUT(container); Assert.IsTrue(System.Runtime.Remoting.RemotingServices.IsTransparentProxy(sut)); switch (this.Mode) { case TestMode.Interface: { InterceptionTestClassInterface implementationClass = sut as InterceptionTestClassInterface; Assert.IsNull(implementationClass); } break; case TestMode.MarshalByRefObject: { InterceptionTestClassMarshalByRefObject implementationClass = sut as InterceptionTestClassMarshalByRefObject; Assert.IsTrue(System.Runtime.Remoting.RemotingServices.IsTransparentProxy(implementationClass)); Assert.IsNotNull(implementationClass); } break; } }
public virtual void CanCreateInstance() { IUnityContainer container = GetContainer(); IInterceptionTestClass sut = this.GetSUT(container); Assert.IsNotNull(sut); Assert.IsTrue(System.Runtime.Remoting.RemotingServices.IsTransparentProxy(sut)); }
public virtual void TestPropertyWriteInterception() { IUnityContainer container = GetContainer(); IInterceptionTestClass sut = this.GetSUT(container); sut.PropertyTest = 5; Assert.AreEqual(1, container.Resolve <TestCallHandler>("TestCallHandler").InterceptionCount); }
public virtual void TestPropertyReadInterception() { IUnityContainer container = GetContainer(); IInterceptionTestClass sut = this.GetSUT(container); Assert.IsTrue(System.Runtime.Remoting.RemotingServices.IsTransparentProxy(sut)); int i = sut.PropertyTest; Assert.AreEqual(1, container.Resolve <TestCallHandler>("TestCallHandler").InterceptionCount); }
public virtual void TestMethodInterception() { IUnityContainer container = GetContainer(); IInterceptionTestClass sut = this.GetSUT(container); Assert.IsTrue(System.Runtime.Remoting.RemotingServices.IsTransparentProxy(sut)); int previousValue = sut.SetAndReturnPreviousValue(5); Assert.AreEqual(1, container.Resolve <TestCallHandler>("TestCallHandler").InterceptionCount); }
public virtual void CanCreateTwoInstanceAndIdentitieAreDifferentWhenTransient() { IUnityContainer container = GetContainer(); IInterceptionTestClass sut1 = this.GetSUT(container); IInterceptionTestClass sut2 = this.GetSUT(container); Assert.IsNotNull(sut1); Assert.IsNotNull(sut2); Assert.AreNotSame(sut1, sut2); Assert.IsTrue(System.Runtime.Remoting.RemotingServices.IsTransparentProxy(sut1)); Assert.IsTrue(System.Runtime.Remoting.RemotingServices.IsTransparentProxy(sut2)); }
public virtual void CanCastToOtherInterfaceAndCallMethodsOnIt() { IUnityContainer container = GetContainer(); IInterceptionTestClass sut = this.GetSUT(container); Assert.IsTrue(System.Runtime.Remoting.RemotingServices.IsTransparentProxy(sut)); IInterceptionTestClassEmpty otherInterface = sut as IInterceptionTestClassEmpty; Assert.IsTrue(System.Runtime.Remoting.RemotingServices.IsTransparentProxy(otherInterface)); otherInterface.DoSomething(); Assert.AreEqual(1, container.Resolve <TestCallHandler>("TestCallHandler").InterceptionCount); }
/// <remarks> /// Relies on the fact that a new proxy is ALWAYS generated /// </remarks> public virtual void CanCreateTwoInstanceAndIdentitieAreDifferentWhenContainerControlled() { IUnityContainer container = GetContainer(); container.RegisterType <InterceptionTestClassMarshalByRefObject>(new ContainerControlledLifetimeManager()); container.RegisterType <InterceptionTestClassInterface>(new ContainerControlledLifetimeManager()); IInterceptionTestClass sut1 = this.GetSUT(container); IInterceptionTestClass sut2 = this.GetSUT(container); Assert.IsNotNull(sut1); Assert.IsNotNull(sut2); Assert.AreNotSame(sut1, sut2); Assert.IsTrue(System.Runtime.Remoting.RemotingServices.IsTransparentProxy(sut1)); Assert.IsTrue(System.Runtime.Remoting.RemotingServices.IsTransparentProxy(sut2)); }
public virtual void CanCastToOtherInterface() { IUnityContainer container = GetContainer(); IInterceptionTestClass sut = this.GetSUT(container); Assert.IsTrue(System.Runtime.Remoting.RemotingServices.IsTransparentProxy(sut)); IInterceptionTestClassEmpty otherInterface = sut as IInterceptionTestClassEmpty; Assert.IsTrue(System.Runtime.Remoting.RemotingServices.IsTransparentProxy(otherInterface)); switch (this.Mode) { case TestMode.Interface: Assert.IsNotNull(otherInterface); break; case TestMode.MarshalByRefObject: Assert.IsNotNull(otherInterface); break; } }