public void can_parse_test_messages(string input) { var parser = new Parser(); var rawInput = input.Replace("\r\n", "\n") + "\n\n"; foreach (char c in rawInput) { parser.Append(c); } Assert.True(parser.Completed); var message = parser.ExtractMessage(); Assert.NotNull(message); Console.WriteLine(message.ToString()); }
public void it_should_extract_the_body_from_a_message(string input) { var parser = new Parser(); var rawInput = input.Replace("\r\n", "\n") + "\n\n"; foreach (char c in rawInput) { parser.Append(c); } Assert.True(parser.Completed); BasicMessage payload = parser.ExtractMessage(); Assert.Equal(ContentTypes.EventPlain, payload.ContentType); Assert.NotNull(payload.BodyText); Assert.Equal(payload.ContentLength, payload.BodyText.Length); Console.WriteLine(payload.ToString()); }
public void it_should_parse_BackgroundJobResult_OK() { var input = TestMessages.BackgroundJob; var parser = new Parser(); var rawInput = input.Replace("\r\n", "\n") + "\n\n"; foreach (char c in rawInput) { parser.Append(c); } Assert.True(parser.Completed); var backroundJobResult = new BackgroundJobResult(new EventMessage(parser.ExtractMessage())); Assert.NotNull(backroundJobResult); Assert.True(backroundJobResult.Success); Console.WriteLine(backroundJobResult.ToString()); }
public void it_should_parse_event_messages(string input, EventName eventName) { var parser = new Parser(); var rawInput = input.Replace("\r\n", "\n") + "\n\n"; foreach (char c in rawInput) { parser.Append(c); } Assert.True(parser.Completed); var eventMessage = new EventMessage(parser.ExtractMessage()); Assert.NotNull(eventMessage); Assert.Equal(eventName, eventMessage.EventName); Console.WriteLine(eventMessage.ToString()); }
public void it_should_parse_Api_Response_ERR() { var parser = new Parser(); var rawInput = "Content-Type: api/response\nContent-Length: 10\n\n-ERR Error"; foreach (char c in rawInput) { parser.Append(c); } Assert.True(parser.Completed); var response = new ApiResponse(parser.ExtractMessage()); Assert.NotNull(response); Assert.False(response.Success); Assert.Equal("Error", response.ErrorMessage); Console.WriteLine(response); }
public void it_should_parse_Command_Reply_ERR() { var parser = new Parser(); var rawInput = "Content-Type: command/reply\nReply-Text: -ERR Error\n\n"; foreach (char c in rawInput) { parser.Append(c); } Assert.True(parser.Completed); var reply = new CommandReply(parser.ExtractMessage()); Assert.NotNull(reply); Assert.False(reply.Success); Assert.Equal("Error", reply.ErrorMessage); Console.WriteLine(reply); }