예제 #1
0
        public void CallMethodFoo()
        {
            MockRepository mocks       = new MockRepository();
            FooRequest     fooRequest  = FooRequest.CreateBuilder().Build();
            FooResponse    fooResponse = FooResponse.CreateBuilder().Build();
            IRpcController controller  = mocks.StrictMock <IRpcController>();

            bool fooCalled = false;

            TestService service = new TestServiceImpl((request, responseAction) => {
                Assert.AreSame(fooRequest, request);
                fooCalled = true;
                responseAction(fooResponse);
            }, null, controller);

            bool doneHandlerCalled        = false;
            Action <IMessage> doneHandler = (response => {
                Assert.AreSame(fooResponse, response);
                doneHandlerCalled = true;
            });

            using (mocks.Record()) {
                // No mock interactions to record
            }

            service.CallMethod(FooDescriptor, controller, fooRequest, doneHandler);

            Assert.IsTrue(doneHandlerCalled);
            Assert.IsTrue(fooCalled);
            mocks.VerifyAll();
        }
        public void CallMethodFoo()
        {
            FooRequest     fooRequest  = FooRequest.CreateBuilder().Build();
            FooResponse    fooResponse = FooResponse.CreateBuilder().Build();
            IRpcController controller  = new RpcTestController();

            bool fooCalled = false;

            TestGenericService service = new TestServiceImpl((request, responseAction) =>
            {
                Assert.AreSame(fooRequest, request);
                fooCalled = true;
                responseAction(fooResponse);
            }, null, controller);

            bool doneHandlerCalled        = false;
            Action <IMessage> doneHandler = (response =>
            {
                Assert.AreSame(fooResponse, response);
                doneHandlerCalled = true;
            });

            service.CallMethod(FooDescriptor, controller, fooRequest, doneHandler);

            Assert.IsTrue(doneHandlerCalled);
            Assert.IsTrue(fooCalled);
        }