コード例 #1
0
        public void TestVoidCallOfInterface()
        {
            var instance = new Mock <IDebuggerService>();

            instance.Setup(i => i.Execute(It.IsAny <int>()));

            var dispatcher = new MethodsDispatcher <IDebuggerService>();

            dispatcher.Dispatch(instance.Object, "Execute", new object[] { 1 });
            instance.Verify(i => i.Execute(1), Times.Once);
            instance.VerifyNoOtherCalls();
        }
コード例 #2
0
        public void TestFunctionCallOfInterface()
        {
            var instance = new Mock <IDebuggerService>();

            instance.Setup(i => i.GetThreads()).Returns(new [] { 1, 2, 3 });

            var dispatcher = new MethodsDispatcher <IDebuggerService>();
            var result     = dispatcher.Dispatch(instance.Object, "GetThreads", new object[0]);

            instance.Verify(i => i.GetThreads(), Times.Once);
            instance.VerifyNoOtherCalls();
            Assert.That(result, Has.Length.EqualTo(3));
        }
コード例 #3
0
        private void ProcessSuccess(RpcCall message, ICommunicationChannel responseChannel)
        {
            RpcCallResult callResult = null;

            try
            {
                var methodResult = _requestProcessor.Dispatch(_requestService, message.Id, message.Parameters);
                if (methodResult != null)
                {
                    callResult = RpcCallResult.Respond(message, methodResult);
                }
            }
            catch (Exception e)
            {
                callResult = RpcCallResult.Exception(message, e);
            }

            if (callResult != null)
            {
                responseChannel.Write(callResult);
            }
        }