예제 #1
0
        public void Prig_should_assert_on_method_callbacks()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                var handler = default(Foo.EchoEventHandler);

                var fooProxy = new PProxyFoo();
                fooProxy.AddOnEchoCallbackFooEchoEventHandler().Body = (@this, value) => handler += value;
                fooProxy.EchoInt32().Body = (@this, arg1) => { handler(true); return(arg1); };

                var foo = (Foo)fooProxy;

                var called = false;
                foo.OnEchoCallback += echoed => called = echoed;


                // Act
                foo.Echo(10);


                // Assert
                Assert.IsTrue(called);
            }
        }
예제 #2
0
        public void Prig_should_setup_a_call_to_a_final_method()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                var fooProxy = new PProxyFoo();
                fooProxy.EchoInt32().Body = (@this, arg1) => 10;
                var foo = (Foo)fooProxy;


                // Act
                var actual = foo.Echo(1);


                // Assert
                Assert.AreEqual(10, actual);
            }
        }
예제 #3
0
        public void Prig_should_setup_a_call_to_a_final_method()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                var fooProxy = new PProxyFoo();
                fooProxy.EchoInt32().Body = (@this, arg1) => 10;
                var foo = (Foo)fooProxy;


                // Act
                var actual = foo.Echo(1);


                // Assert
                Assert.AreEqual(10, actual);
            }
        }
예제 #4
0
        public void Prig_should_assert_on_method_callbacks()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                var handler = default(Foo.EchoEventHandler);

                var fooProxy = new PProxyFoo();
                fooProxy.AddOnEchoCallbackFooEchoEventHandler().Body = (@this, value) => handler += value;
                fooProxy.EchoInt32().Body = (@this, arg1) => { handler(true); return arg1; };

                var foo = (Foo)fooProxy;

                var called = false;
                foo.OnEchoCallback += echoed => called = echoed;


                // Act
                foo.Echo(10);


                // Assert
                Assert.IsTrue(called);
            }
        }