private void Process_MultipleMessages_CharWise() { var reader = new JsonMessageReader(); foreach (var data in GetTestData(minMessageCount: 2)) { string json = data.Item1; var expectedMessages = data.Item2; var endIndexOfLogMessages = data.Item3; int messageNumber = 0; for (int i = 0; i < json.Length; i++) { var readMessages = reader.Process(json[i].ToString()); if (endIndexOfLogMessages.Contains(i)) { // message should have been read successfully at this point Assert.Single(readMessages); Assert.Equal(expectedMessages[messageNumber++], readMessages[0]); } else { // message is still incomplete Assert.Empty(readMessages); } } reader.Reset(); } }
private void Process_SingleMessage_AllAtOnce(string json, string newline, LogMessage expected) { var reader = new JsonMessageReader(); var messages = reader.Process(json); Assert.Single(messages); Assert.Equal(expected, messages[0]); }
private void Process_SingleMessage_CharWise(string json, string newline, LogMessage expected) { var reader = new JsonMessageReader(); ILogMessage[] messages; // pass all characters except the last one (that would complete the message) to the reader for (int i = 0; i < json.Length - 1; i++) { messages = reader.Process(json[i].ToString()); Assert.Empty(messages); } // pass the last character into the reader completing the message messages = reader.Process(json[json.Length - 1].ToString()); Assert.Single(messages); Assert.Equal(expected, messages[0]); }
private void Process_MultipleMessages_AllAtOnce() { var reader = new JsonMessageReader(); foreach (var data in GetTestData(minMessageCount: 2)) { string json = data.Item1; var expectedMessages = data.Item2; var messages = reader.Process(json); Assert.Equal(expectedMessages.Length, messages.Length); Assert.Equal(expectedMessages, messages); } reader.Reset(); }