Ejemplo n.º 1
0
        public void ShouldUseProxyCallbackValueOnMethodWithValueTypeReturnValue()
        {
            const int     ReturnValue = 1234;
            ConcreteClass proxy       = Proxifier.For <ConcreteClass>(new FuncProxyAction((instance, method, args) => {
                return(1234);
            })).Build();
            int result = proxy.MethodWithValueTypeReturnValue();

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

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

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

            Object[]      proxyArgs = null;
            ConcreteClass proxy     = Proxifier.For <ConcreteClass>(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);
        }
Ejemplo n.º 5
0
        public void ShouldConstructProxyForConcreteClass()
        {
            ConcreteClass proxy = Proxifier.For <ConcreteClass>(new FuncProxyAction((instance, method, args) => null)).Build();

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