public void Parse_WhenDataIsIncompleteAndCorrect_ReturnsOneMessage(string data) { byte[] bytes = Encoding.UTF8.GetBytes(data); IEnumerable <ServerSentEventsMessage> messages = m_sut.Parse(new ArraySegment <byte>(bytes)); ServerSentEventsMessage serverSentEventsMessage = messages.Single(); Assert.That(serverSentEventsMessage.Data, Is.EqualTo("Hello, World!")); }
public async Task ProcessAsync_OnMessageHandler_ExecutedOnce() { int executionCount = 0; ServerSentEventsMessage actrualMessage = null; m_sut.OnMessage = message => { executionCount++; actrualMessage = message; }; string data = "data: Hello, World!\r\n\r\n"; using (var stream = GetStream(data)) { await m_sut.ProcessAsync(stream, CancellationToken.None); } Assert.That(executionCount, Is.EqualTo(1)); actrualMessage.ShouldBeEquivalentTo(new ServerSentEventsMessage { Data = "Hello, World!" }); }