Beispiel #1
0
 public void SplitLines()
 {
     foreach (var testCase in new[] {
         new { Source = "A\nB\nC\n", Expected = new[] { "A", "B", "C" } },
         new { Source = "A\r\nB\r\nC\r\n", Expected = new[] { "A", "B", "C" } },
         new { Source = "A\n\rB\n\rC\n\r", Expected = new[] { "A", "", "B", "", "C", "" } },
         new { Source = "A\n\nB\n\nC\n\n", Expected = new[] { "A", "", "B", "", "C", "" } },
         new { Source = "A\nB\nC\n ", Expected = new[] { "A", "B", "C", " " } },
         new { Source = "A", Expected = new[] { "A" } },
         new { Source = "\r\nABC", Expected = new[] { "", "ABC" } },
         new { Source = "", Expected = new[] { "" } },
         new { Source = "\r", Expected = new[] { "" } },
         new { Source = "\n", Expected = new[] { "" } },
         new { Source = "\r\n", Expected = new[] { "" } },
         new { Source = "\n\r", Expected = new[] { "", "" } },
     })
     {
         var lines = ProcessOutput.SplitLines(testCase.Source).ToList();
         Assert.AreEqual(testCase.Expected.Length, lines.Count, string.Format("Source:<{0}>", testCase.Source));
         foreach (var pair in testCase.Expected.Zip(lines, Tuple.Create <string, string>))
         {
             Console.WriteLine("[" + pair.Item1 + "]");
             Console.WriteLine("{" + pair.Item2 + "}");
         }
         Console.WriteLine();
         foreach (var pair in testCase.Expected.Zip(lines, Tuple.Create <string, string>))
         {
             Assert.AreEqual(pair.Item1, pair.Item2, string.Format("Source:<{0}>", testCase.Source));
         }
     }
 }