public async Task Failed_Subscribe_with_null_stream() { /* Given */ string id = "1"; var payload = new GraphQLRequest(); var context = new MessageHandlingContext(_server, null); _executer.ExecuteAsync(null).ReturnsForAnyArgs( new ExecutionResult { Streams = new Dictionary <string, IObservable <ExecutionResult> > { { "1", null } } }); /* When */ await _sut.SubscribeOrExecuteAsync(id, payload, context); /* Then */ await _writer.Received().SendAsync( Arg.Is <OperationMessage>( message => message.Id == id && message.Type == MessageType.GQL_ERROR)); }
public void On_data_from_stream() { /* Given */ var id = "1"; var payload = new OperationMessagePayload(); var stream = new ReplaySubject <ExecutionResult>(1); var result = new SubscriptionExecutionResult { Streams = new Dictionary <string, IObservable <ExecutionResult> > { { "op", stream } } }; var expected = new ExecutionResult(); var sut = new Subscription(id, payload, result, _writer, null, new NullLogger <Subscription>()); /* When */ stream.OnNext(expected); /* Then */ _writer.Received().Post( Arg.Is <OperationMessage>( message => message.Id == id && message.Type == MessageType.GQL_DATA)); }
public async Task Failed_Subscribe_with_null_stream() { /* Given */ var id = "1"; var payload = new OperationMessagePayload(); _executer.ExecuteAsync(null, null, null).ReturnsForAnyArgs( new SubscriptionExecutionResult { Streams = new Dictionary <string, IObservable <ExecutionResult> > { { "1", null } } }); /* When */ await _sut.SubscribeOrExecuteAsync(id, payload, _writer); /* Then */ await _writer.Received().SendAsync( Arg.Is <OperationMessage>( message => message.Id == id && message.Type == MessageType.GQL_ERROR)); }