示例#1
0
        public void ShouldUseProxyCallbackValueOnMethodWithValueTypeReturnValue()
        {
            const int     ReturnValue = 1234;
            AbstractClass proxy       = Proxifier.For <AbstractClass>(new FuncProxyAction((instance, method, args) => {
                return(1234);
            })).Build();
            int result = proxy.MethodWithValueTypeReturnValue();

            Assert.Equal(ReturnValue, result);
        }
示例#2
0
        public void ShouldUseProxyCallbackValueOnMethodWithReferenceTypeReturnValue()
        {
            const string  ReturnValue = "Test string";
            AbstractClass proxy       = Proxifier.For <AbstractClass>(new FuncProxyAction((instance, method, args) => {
                return(ReturnValue);
            })).Build();
            String result = proxy.MethodWithReferenceTypeReturnValue();

            Assert.Equal(ReturnValue, result);
        }
示例#3
0
        public void ShouldWireCallback()
        {
            bool          proxyCalled = false;
            AbstractClass proxy       = Proxifier.For <AbstractClass>(new FuncProxyAction((instance, method, args) => {
                proxyCalled = true;
                return(null);
            })).Build();

            proxy.Method();
            Assert.True(proxyCalled, "The proxy callback was not invoked");
        }
示例#4
0
        public void ShouldWireCallbackOnMethodWithArgs()
        {
            bool proxyCalled = false;

            Object[]      proxyArgs = null;
            AbstractClass proxy     = Proxifier.For <AbstractClass>(new FuncProxyAction((instance, method, args) => {
                proxyCalled = true;
                proxyArgs   = args;
                return(null);
            })).Build();

            proxy.MethodWithArgs(100, "Proxy method test");
            Assert.True(proxyCalled, "The proxy callback was not invoked");
            Assert.Equal(new object[] { 100, "Proxy method test" }, proxyArgs);
        }
示例#5
0
        public void ShouldConstructProxyForAbstractClass()
        {
            AbstractClass proxy = Proxifier.For <AbstractClass>(new FuncProxyAction((instance, method, args) => null)).Build();

            Assert.IsAssignableFrom(typeof(object), proxy);
        }