public void TextFileProcessor_TryParseData_WithInvalidStreamInput_ShouldReturnFalseAndNullOutput() { // ARRANGE TextFileProcessor processor = new TextFileProcessor(); IEnumerable <DataItem> results = null; Stream fakeStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes("[2017-12-13 09:42:2- thing fun happened.")); bool actualResult; // ACT actualResult = processor.TryParseData(fakeStream, out results); // ASSERT Assert.Null(results, "No results should have come back."); Assert.False(actualResult, "The result of the TryParse should have been false."); } // end test
public void TextFileProcessor_TryParseData_WithValidStreamInput_ShouldReturnTrueAndOutputResults() { // ARRANGE TextFileProcessor processor = new TextFileProcessor(); IEnumerable <DataItem> results = null; Stream fakeStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes("[2017-12-13 09:42:23.244 INFO - Data Updated] Something fun happened.")); bool actualResult; // ACT actualResult = processor.TryParseData(fakeStream, out results); // ASSERT Assert.AreEqual(1, results.Count(), "One result should have come out of the method."); Assert.True(actualResult, "The result of the TryParse should have been true."); } // end test
public void TextFileProcessor_TryParseData_WithInvalidStringInput_ShouldReturnFalseAndNullOutput() { // ARRANGE TextFileProcessor processor = new TextFileProcessor(); IEnumerable <DataItem> results = null; string fakeString = "[2017-12-13 09:42:2- Data Updated] Something fun happened."; bool actualResult; // ACT actualResult = processor.TryParseData(fakeString, out results); // ASSERT Assert.Null(results, "No results should have come back."); Assert.False(actualResult, "The result of the TryParse should have been false."); } // end test