public void CallMethodBar()
        {
            MockRepository mocks       = new MockRepository();
            BarRequest     barRequest  = BarRequest.CreateBuilder().Build();
            BarResponse    barResponse = BarResponse.CreateBuilder().Build();
            IRpcController controller  = mocks.StrictMock <IRpcController>();

            bool barCalled = false;

            TestService service = new TestServiceImpl(null, (request, responseAction) => {
                Assert.AreSame(barRequest, request);
                barCalled = true;
                responseAction(barResponse);
            }, controller);

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

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

            service.CallMethod(BarDescriptor, controller, barRequest, doneHandler);

            Assert.IsTrue(doneHandlerCalled);
            Assert.IsTrue(barCalled);
            mocks.VerifyAll();
        }
        public void CallMethodBar()
        {
            BarRequest     barRequest  = BarRequest.CreateBuilder().Build();
            BarResponse    barResponse = BarResponse.CreateBuilder().Build();
            IRpcController controller  = new RpcTestController();

            bool barCalled = false;

            TestGenericService service = new TestServiceImpl(null, (request, responseAction) =>
            {
                Assert.AreSame(barRequest, request);
                barCalled = true;
                responseAction(barResponse);
            }, controller);

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

            service.CallMethod(BarDescriptor, controller, barRequest, doneHandler);

            Assert.IsTrue(doneHandlerCalled);
            Assert.IsTrue(barCalled);
        }
Beispiel #3
0
    public static void Run()
    {       // Exemple of consuming the method
        var input = new BarQuery {
            Bar_Label = "user input", Bar_Ig = 42
        };

        BarResponse result = Bar(input);
    }
        public void GeneratedStubBarCallFails()
        {
            IRpcChannel          channel     = new RpcTestChannel();
            IRpcController       controller  = new RpcTestController();
            TestGenericService   service     = TestGenericService.CreateStub(channel);
            BarResponse          barResponse = null;
            Action <BarResponse> doneHandler = r => barResponse = r;

            service.Bar(controller, BarRequest.DefaultInstance, doneHandler);

            Assert.IsNull(barResponse);
            Assert.IsTrue(controller.Failed);
        }
            protected override async Task WhenAsync(CancellationToken cancellationToken)
            {
                _response = await Server.CreateClient().GetAsync("foo/fooId/bar", cancellationToken);

                _content = JsonConvert.DeserializeObject <BarResponse>(await _response.Content.ReadAsStringAsync());
            }
 protected override void When()
 {
     _response = Client.GetAsync("foo/fooId/bar").Result;
     _content  = _response.Content.ReadAsAsync <BarResponse>().Result;
 }