TestCaseData ProvideIgnoreReasonTo(TestCaseData target) { if (reason != null) { target.Ignore(reason); } return target; }
private ITestCaseData CreateTestCase(TestPath path, IDictionary<string, string> ignores) { var testCase = new TestCaseData(path).SetName(path.TestName); if (ignores.ContainsKey(path.Ignore)) { testCase.Ignore(ignores[path.Ignore]); } return testCase; }
private static ITestCaseData GenerateTestCase(ApiTestData apiTestData) { IComparerResult comparerResult = apiTestData.ComparerResult; bool fail = comparerResult.GetAllCount(Severity.Error) + comparerResult.GetAllCount(Severity.Warning) > 0; TestCaseData testCaseData = new TestCaseData(!fail, fail ? GetFailMessage(comparerResult) : "").SetName(comparerResult.Name).SetCategory(apiTestData.Category); if (apiTestData.IgnoreList.Contains(comparerResult.Name)) { testCaseData.Ignore(); } if (apiTestData.Explicit) { testCaseData.MakeExplicit(""); } return testCaseData; }
public static IEnumerable<TestCaseData> TestCasesFromDirectory(string testDirectory = null) { var tests = TestRunner.RunAllTests(testDirectory); List<TestCaseData> testCases = new List<TestCaseData>(); foreach (var test in tests) { var testCase = new TestCaseData(test).SetName(test.Name); if (test.Skipped) { testCase.Ignore("This test was skipped in mocha"); } testCases.Add(testCase); } return testCases; }
private static TestCaseData datumToTestCase(Datum d) { var ignore = false; var quoted = checkQuote(d); if(quoted != null) { d = quoted; ignore = true; } var combo = d.ToArray(); if (combo.Length < 3) throw new Exception(string.Format("'{0}' is not a valid test case", d)); var name = combo[0] as Symbol; if (name == null) throw new Exception(string.Format("'{0}' is not a valid test case", d)); var expected = combo[1]; var expression = combo[2]; var testCase = new TestCaseData(expression); testCase.Returns(expected); testCase.SetName(name.Identifier); if (ignore) testCase.Ignore("quoted"); return testCase; }
public static IEnumerable<ITestCaseData> GetTestCases() { const string prefix = "MongoDB.Driver.Specifications.connection_string.tests."; return Assembly .GetExecutingAssembly() .GetManifestResourceNames() .Where(path => path.StartsWith(prefix) && path.EndsWith(".json")) .SelectMany(path => { var definition = ReadDefinition(path); var tests = (BsonArray)definition["tests"]; var fullName = path.Remove(0, prefix.Length); var list = new List<TestCaseData>(); foreach (BsonDocument test in tests) { var data = new TestCaseData(test); data.Categories.Add("Specifications"); data.Categories.Add("ConnectionString"); var testName = fullName.Remove(fullName.Length - 5) + ": " + test["description"]; if (_ignoredTestNames.Contains(testName)) { data = data.Ignore("Does not apply"); } list.Add(data.SetName(testName)); } return list; }); }
public static IEnumerable<TestCaseData> GenerateTests() { var file = Directory.GetFiles(@"..\..\..\Unit Tests\Script-Tests", "*.zip").First(); var zipfile = new ZipFile(file); var includeBuilder = new StringBuilder(); includeBuilder.AppendLine(File.ReadAllText(Path.Combine(@"..\..\..\Unit Tests\Script-Tests", @"harness\cth.js"))); includeBuilder.AppendLine(File.ReadAllText(Path.Combine(@"..\..\..\Unit Tests\Script-Tests", @"harness\sta.js"))); includeBuilder.AppendLine(File.ReadAllText(Path.Combine(@"..\..\..\Unit Tests\Script-Tests", @"harness\ed.js"))); var includes = includeBuilder.ToString(); var skippedTests = XDocument.Load(Path.Combine(@"..\..\..\Unit Tests\Script-Tests", @"config\excludelist.xml")) .Element("excludeList") .Elements("test") .Select(t => new { Name = t.Attribute("id").Value, Reason = t.Value }).ToList(); Regex r = new Regex("^ \\* @([a-z]+)(.*?)$", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); for (int i = 0; i < zipfile.Count; i++) { var zf = zipfile[i]; if (zf.IsFile && zf.Name.EndsWith(".js")) { string content; using (var sr = new StreamReader(zipfile.GetInputStream(zf))) content = sr.ReadToEnd(); var isNegative = content.Contains("@negative"); string negativeType = null; if (isNegative) { var negativeStart = content.IndexOf("@negative ") + "@negative ".Length; if (negativeStart != -1 + "@negative ".Length) { negativeType = content.Substring(negativeStart, content.IndexOfAny(new char[] { '\r', '\n' }, negativeStart) - negativeStart).Trim(); if (string.IsNullOrWhiteSpace(negativeType)) negativeType = null; } } var forceStrictMode = content.Contains("@onlyStrict"); var fn = Path.GetFileName(zf.Name); string name = fn.Substring(0, fn.Length - 3); var tcd = new TestCaseData(includes, content, forceStrictMode, isNegative, negativeType).SetName(name.Replace("_", "__").Replace('.', '_')); if (skippedTests.Any(t => t.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase))) { tcd = tcd.Ignore(skippedTests.First(t => t.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)).Reason); } else { tcd = tcd.SetProperty("_NOTIGNORED", "TRUE"); } tcd = tcd.SetProperty("@_name", zf.Name.Substring(0, zf.Name.Length - 3)).SetProperty("@_negativeType", negativeType); foreach (Match match in r.Matches(content)) { if (match.Groups[2].Length > 0) tcd = tcd.SetProperty("_" + match.Groups[1].Value.ToUpper(), match.Groups[2].Value.Trim()); else tcd = tcd.SetProperty("_" + match.Groups[1].Value.ToUpper(), "TRUE"); } yield return tcd; } } }
protected static IEnumerable<TestCaseData> ConvertCodeFileToTestCaseData(string[] files, MethodsOnASingleClassCloneFinder clonefinder) { foreach (var file in files) { var codefile = Path.GetFullPath(file); var codeText = File.ReadAllText(codefile); var tcase = new TestCaseData(codefile, clonefinder); var desc = string.Join(" ", (from str11 in codeText.Split(Environment.NewLine.ToCharArray()) where str11.TrimStart().StartsWith("//") select str11.Trim().TrimStart('/')).ToArray()).Trim(); tcase.SetDescription(desc); tcase.SetName(Path.GetFileNameWithoutExtension(file)); if(desc.StartsWith("Ignore")) tcase.Ignore(desc); yield return tcase; } }