public void TestInvalidCastWithoutStrict() { SimpleClass testClass = new SimpleClass(); ISimpleInterface testClassProxy = (ISimpleInterface)new EasyProxy(InvocationHandler).Create(testClass); testClassProxy.Should().Not.Be.Null(); // Test invalid cast INotImplemented notImplementedInterface = (INotImplemented)testClassProxy; notImplementedInterface.NotImplementedMethod(); }
public void TestInvalidCastWithoutStrict() { SimpleClass testClass = new SimpleClass(); ISimpleInterface testClassProxy = (ISimpleInterface) DynamicProxyFactory.Instance.CreateProxy(testClass, new InvocationDelegate(InvocationHandler)); testClassProxy.Should().Not.Be.Null(); // Test invalid cast INotImplemented notImplementedInterface = (INotImplemented)testClassProxy; notImplementedInterface.NotImplementedMethod(); }
public void TestSimpleProxy() { SimpleClass testClass = new SimpleClass(); ISimpleInterface testClassProxy = (ISimpleInterface)new EasyProxy(InvocationHandler).Create(testClass); TestCreatedSimpleProxy(testClassProxy); }
public void TestStrictness() { SimpleClass testClass = new SimpleClass(); ISimpleInterface testClassProxy = (ISimpleInterface) DynamicProxyFactory.Instance.CreateProxy(testClass, new InvocationDelegate(InvocationHandler), true); testClassProxy.Should().Not.Be.Null(); // No test for method 1, just make sure it doesn't bomb ;-) testClassProxy.Method1(); // Test casting IImplemented implementedInterface = (IImplemented)testClassProxy; implementedInterface.ImplementedMethod(); }
public void TestSimpleProxy() { SimpleClass testClass = new SimpleClass(); ISimpleInterface testClassProxy = (ISimpleInterface) DynamicProxyFactory.Instance.CreateProxy(testClass, new InvocationDelegate(InvocationHandler)); TestCreatedSimpleProxy(testClassProxy); }
public void TestStrictnessWithSupportedListAndInvalidCast() { SimpleClass testClass = new SimpleClass(); ISimpleInterface testClassProxy = (ISimpleInterface) DynamicProxyFactory.Instance.CreateProxy(testClass, new InvocationDelegate(InvocationHandler), true, new Type[] { typeof(INotImplemented) }); testClassProxy.Should().Not.Be.Null(); // No test for method 1, just make sure it doesn't bomb ;-) testClassProxy.Method1(); // Test invalid cast INotImplemented2 notImplementedInterface2 = null; notImplementedInterface2 = (INotImplemented2)testClassProxy; }