public void DetectReadTimeout() { TimeSpan readTimeout = TimeSpan.FromMilliseconds(300); TimeSpan timeToWait = readTimeout + readTimeout; var handler = new StubMessageHandler(); handler.QueueResponse(StubResponse.StartStream( StreamAction.Write(":comment1\n"), StreamAction.Write(":comment2\n"), StreamAction.Write(":comment3\n").AfterDelay(timeToWait)) ); handler.QueueResponse(StubResponse.StartStream()); using (var es = StartEventSource(handler, out var eventSink, config => config.ReadTimeout(readTimeout))) { eventSink.ExpectActions( EventSink.OpenedAction(), EventSink.CommentReceivedAction(":comment1"), EventSink.CommentReceivedAction(":comment2"), EventSink.ErrorAction(new ReadTimeoutException()), EventSink.ClosedAction() ); } }
public void ReceiveComment() { var commentSent = ": hello"; var handler = StartStream().Then(Handlers.WriteChunkString(commentSent + "\n")) .Then(LeaveStreamOpen()); WithServerAndStartedEventSource(handler, (_, eventSink) => { eventSink.ExpectActions( EventSink.OpenedAction(), EventSink.CommentReceivedAction(commentSent) ); }); }
public void ReceiveComment() { var commentSent = ": hello"; var handler = new StubMessageHandler(); handler.QueueResponse(StubResponse.StartStream(StreamAction.Write(commentSent + "\n\n"))); using (var es = StartEventSource(handler, out var eventSink)) { eventSink.ExpectActions( EventSink.OpenedAction(), EventSink.CommentReceivedAction(commentSent) );; } }
public void DetectReadTimeout() { TimeSpan readTimeout = TimeSpan.FromMilliseconds(300); TimeSpan timeToWait = readTimeout + readTimeout; var handler = StartStream() .Then(Handlers.WriteChunkString(":comment1\n")) .Then(Handlers.WriteChunkString(":comment2\n")) .Then(Handlers.Delay(timeToWait)) .Then(Handlers.WriteChunkString(":comment3\n")); WithServerAndStartedEventSource(handler, config => config.ReadTimeout(readTimeout), (_, eventSink) => { eventSink.ExpectActions( EventSink.OpenedAction(), EventSink.CommentReceivedAction(":comment1"), EventSink.CommentReceivedAction(":comment2"), EventSink.ErrorAction(new ReadTimeoutException()), EventSink.ClosedAction() ); }); }