示例#1
0
        public void SuccessfulTaskCallsCallResultWithResult(WampRpcCall call, object result)
        {
            MockRawFormatter formatter = new MockRawFormatter();

            MockRpcCatalog catalog = new MockRpcCatalog();

            call.CallId = Guid.NewGuid().ToString();

            MockRpcMethod mockMethod = GetMockMethod(call);

            mockMethod.Result = result;

            catalog.MapMethod(mockMethod);

            WampRpcServer<MockRaw> server =
                new WampRpcServer<MockRaw>(formatter, catalog);

            MockClient client = new MockClient();

            server.Call(client, call.CallId, call.ProcUri,
                        SerializeArguments(call, formatter));

            Assert.That(client.GetCallErrorByCallId(call.CallId),
                        Is.Null);

            Assert.That(client.GetResultByCallId(call.CallId),
                        Is.EqualTo(result));
        }
示例#2
0
        public void ErrorTaskCallsCallErrorWithError(WampRpcCall call, CallErrorDetails details)
        {
            MockRawFormatter formatter = new MockRawFormatter();

            MockRpcCatalog catalog = new MockRpcCatalog();

            call.CallId = Guid.NewGuid().ToString();

            MockRpcMethod mockMethod = GetMockMethod(call);

            mockMethod.Error =
                new WampRpcCallException(details.ErrorUri,
                                         details.ErrorDesc,
                                         details.ErrorDetails);

            catalog.MapMethod(mockMethod);

            WampRpcServer<MockRaw> server =
                new WampRpcServer<MockRaw>(formatter, catalog);

            MockClient client = new MockClient();

            server.Call(client, call.CallId, call.ProcUri,
                        SerializeArguments(call, formatter));

            Assert.That(client.GetResultByCallId(call.CallId),
                        Is.Null);

            CallErrorDetails error = client.GetCallErrorByCallId(call.CallId);

            Assert.That(error.ErrorDesc,
                        Is.EqualTo(details.ErrorDesc));

            Assert.That(error.ErrorDetails,
                        Is.EqualTo(details.ErrorDetails));

            Assert.That(error.ErrorUri,
                        Is.EqualTo(details.ErrorUri));
        }