예제 #1
0
        public async Task SubscribeNodeException()
        {
            var result = await ExecuteQueryAsync(@"
                subscription {
                    nodeException {
                        code
                        message
                    }
                }
            ");

            var subscribeResult = (SubscriptionExecutionResult)result;
            var stream          = subscribeResult.Streams.Values.FirstOrDefault();

            Assert.NotNull(stream);

            await Assert.ThrowsAsync <TimeoutException>(async() =>
            {
                await stream.Take(1).Timeout(TimeSpan.FromMilliseconds(5000)).FirstAsync();
            });

            const NodeExceptionType code    = (NodeExceptionType)0x01;
            const string            message = "This is test message.";

            StandaloneContextFx.NodeExceptionSubject.OnNext(new NodeException(code, message));
            var rawEvents = await stream.Take(1);

            var rawEvent      = (Dictionary <string, object>)rawEvents.Data;
            var nodeException =
                (Dictionary <string, object>)rawEvent["nodeException"];

            Assert.Equal((int)code, nodeException["code"]);
            Assert.Equal(message, nodeException["message"]);
        }
 public NodeException(NodeExceptionType code, string message)
 {
     Code    = (int)code;
     Message = message;
 }