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.SetCategory("Specifications"); data.SetCategory("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; })); }
/// <summary> /// Private method to return a test case, optionally ignored on the Linux platform. /// We use this since the Platform attribute is not supported on TestCaseData. /// </summary> private TestCaseData GetTestCase(MethodInfo method, ResultState resultState, int assertionCount, bool ignoreOnLinux) { var data = new TestCaseData(method, resultState, assertionCount); if (ON_LINUX && ignoreOnLinux) data = data.Ignore("Intermittent failure on Linux"); return data; }
/// <summary> /// Generate list of tests to run /// </summary> public IEnumerable <TestCaseData> QueryTest_TestCases() { XmlDocument doc = GetTestCaseXml( ); XmlNodeList nameAttrs = doc.DocumentElement.SelectNodes("Test"); foreach (XmlElement node in nameAttrs) { string name = node.GetAttribute("name"); string flags = node.GetAttribute("flags"); if (flags == "UsedElsewhere") { continue; } TestCaseData testCase = new TestCaseData(name); if (flags == "Ignore") { testCase = testCase.Ignore("Ignored"); } yield return(testCase); } }
public static List <TestCaseData> RoomsFromJsonFile() { // read and parse file var filePath = "rooms.json"; var contents = File.ReadAllText(filePath); var rooms = JsonConvert.DeserializeObject <List <ExternalRoomData> >(contents); var testCases = new List <TestCaseData>(); //build up the test case data foreach (var test in rooms) { var testCase = new TestCaseData(test.RoomData) .SetName(test.TestName) .SetDescription(test.Description); test.Categories.ForEach(cat => testCase.SetCategory(cat)); if (test.IsExplicit) { testCase.Explicit(); } if (test.IsIgnored) { testCase.Ignore(test.IgnoreReason); } testCases.Add(testCase); } ; return(testCases); }
public IEnumerator GetEnumerator() { foreach (var testcase in GetTests()) { var name = testcase.Name; var framework = TestContext.Parameters["FRAMEWORK"]; if (!string.IsNullOrWhiteSpace(framework)) { name = $"{framework}.{testcase.Name}"; } var result = new TestCaseData(testcase) .SetCategory(category) .SetName(name) .Returns(0); result.Properties.Add("_CodeFilePath", testcase.Path); var runIgnored = !string.IsNullOrWhiteSpace(TestContext.Parameters["RUN_IGNORED"]); if (testcase.Options.Ignore && !runIgnored) { if (!string.IsNullOrWhiteSpace(testcase.Options.Reason)) { result.Ignore($"ignored - {testcase.Options.Reason}"); } else { result.Ignore("ignored"); } } if (!ConditionMatched(testcase.Options.RunCondition)) { if (!string.IsNullOrWhiteSpace(testcase.Options.Reason)) { result.Ignore($"condition ({testcase.Options.RunCondition}) - {testcase.Options.Reason}"); } else { result.Ignore($"condition ({testcase.Options.RunCondition})"); } } yield return(result); } }
public static TestCaseData ConditionalIgnore(this TestCaseData source, bool condition, string reason) { if (condition) { return(source.Ignore(reason)); } return(source); }
/// <summary> /// Private method to return a test case, optionally ignored on the Linux platform. /// We use this since the Platform attribute is not supported on TestCaseData. /// </summary> private TestCaseData GetTestCase(MethodInfo method, ResultState resultState, int assertionCount, bool ignoreOnLinux) { var data = new TestCaseData(method, resultState, assertionCount); if (ON_LINUX && ignoreOnLinux) { data = data.Ignore("Intermittent failure on Linux"); } return(data); }
/// <summary> /// Private method to return a test case, optionally ignored on the Linux platform. /// We use this since the Platform attribute is not supported on TestCaseData. /// </summary> private static TestCaseData GetTestCase(IMethodInfo method, ResultState resultState, int assertionCount, bool ignoreThis) { var data = new TestCaseData(method, resultState, assertionCount); if (PLATFORM_IGNORE && ignoreThis) { data = data.Ignore("Intermittent failure on Linux"); } return(data); }
public IEnumerator GetEnumerator() { foreach (var testcase in GetTests()) { var name = testcase.Name; var framework = TestContext.Parameters["FRAMEWORK"]; if (!string.IsNullOrWhiteSpace(framework)) { name = $"{framework}.{testcase.Name}"; } var result = new TestCaseData(testcase) .SetCategory(category) .SetName(name) .Returns(0); if (testcase.Options.Ignore && string.IsNullOrWhiteSpace(TestContext.Parameters["RUN_IGNORED"])) { if (!string.IsNullOrWhiteSpace(testcase.Options.Reason)) { result.Ignore(string.Format("ignored - {0}", testcase.Options.Reason)); } else { result.Ignore("ignored"); } } if (!ConditionMatched(testcase.Options.Condition) && string.IsNullOrWhiteSpace(TestContext.Parameters["RUN_IGNORED"])) { if (!string.IsNullOrWhiteSpace(testcase.Options.Reason)) { result.Ignore(string.Format("condition ({0}) - {1}", testcase.Options.Condition, testcase.Options.Reason)); } else { result.Ignore(string.Format("condition ({0})", testcase.Options.Condition)); } } yield return(result); } }
private static 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] ?? "From ignore.txt"); } return(testCase); }
public static TestCaseData IgnoreIf(this TestCaseData input, bool do_ignore, string reason) { if (do_ignore) { return(input.Ignore(reason)); } else { return(input); } }
public IEnumerator GetEnumerator() { foreach (var testcase in GetTests()) { var result = new TestCaseData(testcase) .SetCategory(category) .SetName(testcase.Name) .Returns(0); if (testcase.Options.Ignore) { if (!string.IsNullOrWhiteSpace(testcase.Options.Reason)) { result.Ignore(string.Format("ignored - {0}", testcase.Options.Reason)); } else { result.Ignore("ignored"); } } if (!ConditionMatched(testcase.Options.Condition)) { if (!string.IsNullOrWhiteSpace(testcase.Options.Reason)) { result.Ignore(string.Format("condition ({0}) - {1}", testcase.Options.Condition, testcase.Options.Reason)); } else { result.Ignore(string.Format("condition ({0})", testcase.Options.Condition)); } } yield return(result); } }
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 IEnumerator GetEnumerator() { foreach (var testcase in GetTests()) { var result = new TestCaseData(testcase) .SetCategory(category) .SetName(testcase.Name) .Returns(0); if (testcase.Options.Ignore) { result.Ignore(); } yield return(result); } }
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); }
public static IEnumerable <TestCaseData> TestsCases() { foreach (var file in Directory.GetFiles(_base, "*.vm")) { var name = Path.GetFileNameWithoutExtension(file); var testCase = new TestCaseData(name) .SetName("Regression Test ANTLR: " + name + ".vm"); switch (name) { case "velocimacro": case "velocimacro2": case "vm_test1": case "vm_test2": testCase.Ignore("Global Velocimacros not supported"); break; case "escape2": case "include": testCase.Ignore("Include not supported"); break; case "parse": testCase.Ignore("Parse not supported as it's to expensive to compile. Can revisit if we ever support interpreting templates, as well as compiling & executing"); break; case "escape": case "reference": case "test": testCase.Ignore("Escaping in IronVelocity doesnt' match velocity"); break; case "array": case "interpolation": case "literal": testCase.Ignore("Macros not supported"); break; case "sample": testCase.Ignore("Does not support static typing"); break; default: break; } yield return(testCase); } }
public static IEnumerable <TestCaseData> LoadConstraints(string filename) { CompositeCases cc = JsonConvert.DeserializeObject <CompositeCases>(File.ReadAllText(filename)); return(cc.Results.Select(r => { var tcase = new TestCaseData( cc.Data.Select(s => Learner.Instance.BuildPositiveConstraint(s, true, false)) .Append(new ClusteringParameters(Utils.Default.Mu, Utils.Default.Theta)) .Append(new DisjunctionsLimit(r.Disjuncts, r.Disjuncts)) .Append(new AllowedTokens(Utils.LoadTokens(r.UseExtendedTokens, r.ExcludedTokens, r.CustomRegexTokens))) .ToList(), r.Description, $"clusters={r.Description.Count},avg_length={cc.Data.Average(d => d.Length)},entries={cc.Data.Count},auto={r.Disjuncts == null}").SetName(filename); if (r.IgnoreReason != null) { tcase.Ignore(r.IgnoreReason); } return tcase; })); }
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); } }
/// <summary> /// Private method to return a test case, optionally ignored on the Linux platform. /// We use this since the Platform attribute is not supported on TestCaseData. /// </summary> private static TestCaseData GetTestCase(IMethodInfo method, ResultState resultState, int assertionCount, bool ignoreThis) { var data = new TestCaseData(method, resultState, assertionCount); if (PLATFORM_IGNORE && ignoreThis) data = data.Ignore("Intermittent failure on Linux and under Portable build"); return data; }
/// <summary> /// Get a list of tenants. /// </summary> /// <param name="typeAliasWithNamespace">Alias (with namespace) of type to load instances for.</param> /// <param name="csvIgnoreByName">CSV list of the names of instances that should be flagged as 'ignore'.</param> /// <returns>A list of TestCaseData with three parameters set: 1. <see cref="TenantInfo"/>, 2. instance ID, 3. instance name</returns> public static IEnumerable <TestCaseData> GetInstancesAsTestData(string typeAliasWithNamespace, string csvIgnoreByName = null, string customSql = null) { var tenantList = GetTenants( ); var tenantDict = tenantList.ToDictionary(t => t.TenantId); if (tenantDict.Count == 0) { throw new Exception("No tenants found"); } ISet <string> ignoreNames = new HashSet <string>((csvIgnoreByName ?? "").Split(',').Where(n => n != "")); List <TestCaseData> result = new List <TestCaseData>( ); using (DatabaseContext ctx = DatabaseContext.GetContext( )) using (IDbCommand command = ctx.CreateCommand( )) { // For all tenants, get instances of the (exact) type string sql = customSql ?? @" select isOfTypeRel.TenantId, isOfTypeRel.FromId, name.Data from Relationship isOfTypeRel join Data_Alias isOfTypeAlias on isOfTypeRel.TypeId = isOfTypeAlias.EntityId and isOfTypeRel.TenantId = isOfTypeAlias.TenantId and isOfTypeAlias.Data='isOfType' join Data_Alias typeAlias on isOfTypeRel.ToId = typeAlias.EntityId and isOfTypeRel.TenantId = typeAlias.TenantId and typeAlias.Data=@typeAlias and typeAlias.Namespace=@typeNs join Data_Alias nameAlias on isOfTypeRel.TenantId = nameAlias.TenantId and nameAlias.Data='name' left join Data_NVarChar name on isOfTypeRel.FromId = name.EntityId and isOfTypeRel.TenantId = name.TenantId and name.FieldId = nameAlias.EntityId where isOfTypeRel.TenantId <> 0 order by isOfTypeRel.TenantId, name.Data "; command.CommandText = sql; // Apply type name if (typeAliasWithNamespace != null) { string [] parts = typeAliasWithNamespace.Split(':'); if (parts.Length != 2) { throw new Exception("Expected full namespace"); } ctx.AddParameter(command, "@typeAlias", DbType.String, parts [1]); ctx.AddParameter(command, "@typeNs", DbType.String, parts [0]); } using (IDataReader reader = command.ExecuteReader( )) { while (reader.Read( )) { long tenantId = reader.GetInt64(0); long entityId = reader.GetInt64(1); string entityName = reader.IsDBNull(2) ? "Unnamed" : reader.GetString(2); TenantInfo tenantInfo; if (!tenantDict.TryGetValue(tenantId, out tenantInfo)) { tenantInfo = new TenantInfo(tenantId, "Tenant" + tenantId); tenantDict.Add(tenantId, tenantInfo); } // Create test data TestCaseData testCaseData = new TestCaseData(tenantInfo, entityId, entityName); if (ignoreNames.Contains(entityName)) { testCaseData = testCaseData.Ignore("Ignored"); } testCaseData = testCaseData.SetCategory(tenantInfo.TenantName); if (entityName == "Self Serve Component" || entityName == "Control on Form Except Screens") { testCaseData = testCaseData.SetCategory("ExtendedTests"); } result.Add(testCaseData); } } } return(result); }