Наследование: ISimpleInterface, IImplemented
        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();
        }
Пример #2
0
        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);
 }
Пример #4
0
        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();
        }
Пример #5
0
 public void TestSimpleProxy()
 {
     SimpleClass testClass = new SimpleClass();
     ISimpleInterface testClassProxy = (ISimpleInterface) DynamicProxyFactory.Instance.CreateProxy(testClass, new InvocationDelegate(InvocationHandler));
     TestCreatedSimpleProxy(testClassProxy);
 }
Пример #6
0
        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;
        }