public void TestInvokeAsync_Success_TaskSetSerializedReturnValue() { using (var server = new RpcServer()) using (var transportManager = new NullServerTransportManager(server)) using (var transport = new NullServerTransport(transportManager)) { ServerRequestContext requestContext = DispatchTestHelper.CreateRequestContext(); ServerResponseContext responseContext = DispatchTestHelper.CreateResponseContext(transport); using (var result = new Target(null, RpcErrorMessage.Success).InvokeAsync(requestContext, responseContext)) { result.Wait(); } Assert.That(responseContext.GetReturnValueData(), Is.EqualTo(new byte[] { 123 })); Assert.That(responseContext.GetErrorData(), Is.EqualTo(new byte[] { 0xC0 })); } }
public void TestInvokeAsync_MethodError_TaskSetSerializedError() { using (var server = new RpcServer()) using (var transportManager = new NullServerTransportManager(server)) using (var transport = new NullServerTransport(transportManager)) { ServerRequestContext requestContext = DispatchTestHelper.CreateRequestContext(); ServerResponseContext responseContext = DispatchTestHelper.CreateResponseContext(transport); using (var result = new Target(null, new RpcErrorMessage(RpcError.ArgumentError, MessagePackObject.Nil)).InvokeAsync(requestContext, responseContext)) { result.Wait(); } var error = Unpacking.UnpackObject(responseContext.GetErrorData()); var errorDetail = Unpacking.UnpackObject(responseContext.GetReturnValueData()); Assert.That(error.Value.Equals(RpcError.ArgumentError.Identifier)); Assert.That(errorDetail.Value.IsNil, Is.True); } }
public void TestInvokeAsync_FatalError_TaskSetSerializedError() { using (var server = new RpcServer()) using (var transportManager = new NullServerTransportManager(server)) using (var transport = new NullServerTransport(transportManager)) { ServerRequestContext requestContext = DispatchTestHelper.CreateRequestContext(); ServerResponseContext responseContext = DispatchTestHelper.CreateResponseContext(transport); using (var result = new Target(new Exception("FAIL"), RpcErrorMessage.Success).InvokeAsync(requestContext, responseContext)) { result.Wait(); } var error = Unpacking.UnpackObject(responseContext.GetErrorData()); var errorDetail = Unpacking.UnpackObject(responseContext.GetReturnValueData()); Assert.That(error.Value.Equals(RpcError.CallError.Identifier)); Assert.That(errorDetail.Value.IsNil, Is.False); } }