/// <summary> /// Reads a test. /// </summary> private static TestItem ParseTest(string testText) { TestItem test = new TestItem(); List <string> lines = new List <string>( testText.Split( new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None)); if (lines.Count < 3) { ThrowWrongTestFile(); } string headerLine = lines[0]; if (!headerLine.StartsWith("//# [")) { ThrowWrongTestFile(); } if (headerLine.Contains("-- SKIP")) { test.Skip = true; } else if (headerLine == "//# [OK]") { test.ErrorCount = 0; } else if (headerLine == "//# [ERROR]") { test.ErrorCount = 1; } else { if (!headerLine.StartsWith("//# [ERROR:")) { ThrowWrongTestFile(); } string[] parts = headerLine.Split( new[] { "//# [ERROR:", "]" }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length != 1) { ThrowWrongTestFile(); } if (!Int32.TryParse(parts[0], out test.ErrorCount)) { ThrowWrongTestFile(); } } string descriptionLine = lines[1]; if (!descriptionLine.StartsWith("//# ")) { ThrowWrongTestFile(); } test.Description = descriptionLine.Substring(4); if (String.IsNullOrEmpty(test.Description)) { ThrowWrongTestFile(); } lines.RemoveAt(0); lines.RemoveAt(0); test.SourceCode = String.Join(Environment.NewLine, lines.ToArray()); return(test); }
/// <summary> /// Reads a test. /// </summary> private static TestItem ParseTest(string testText) { TestItem test = new TestItem(); List<string> lines = new List<string>( testText.Split( new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None)); if (lines.Count < 3) ThrowWrongTestFile(); string headerLine = lines[0]; if (!headerLine.StartsWith("//# [")) ThrowWrongTestFile(); if (headerLine.Contains("-- SKIP")) { test.Skip = true; } else if (headerLine == "//# [OK]") { test.ErrorCount = 0; } else if (headerLine == "//# [ERROR]") { test.ErrorCount = 1; } else { if (!headerLine.StartsWith("//# [ERROR:")) ThrowWrongTestFile(); string[] parts = headerLine.Split( new[] { "//# [ERROR:", "]" }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length != 1) ThrowWrongTestFile(); if (!Int32.TryParse(parts[0], out test.ErrorCount)) ThrowWrongTestFile(); } string descriptionLine = lines[1]; if (!descriptionLine.StartsWith("//# ")) ThrowWrongTestFile(); test.Description = descriptionLine.Substring(4); if (String.IsNullOrEmpty(test.Description)) ThrowWrongTestFile(); lines.RemoveAt(0); lines.RemoveAt(0); test.SourceCode = String.Join(Environment.NewLine, lines.ToArray()); return test; }