private static void AddingToCache <T>(TestCase testCase, IDictionary <string, CachedTestCaseInfo> traitsCache, string key, CategoryList categoryList, T ancestor, Func <T, bool, string, IDictionary <string, CachedTestCaseInfo>, IEnumerable <string> > processTestCaseProperties) { if (traitsCache.ContainsKey(key)) { categoryList.AddRange(traitsCache[key].Traits.Where(o => o.Name == NunitTestCategoryLabel) .Select(prop => prop.Value).ToList()); if (traitsCache[key].Explicit) { testCase.SetPropertyValue(CategoryList.NUnitExplicitProperty, true); } var traitsList = traitsCache[key].Traits.Where(o => o.Name != NunitTestCategoryLabel).ToList(); if (traitsList.Count > 0) { testCase.Traits.AddRange(traitsList); } } else { processTestCaseProperties(ancestor, true, key, traitsCache); // Adding entry to dictionary, so that we will not make SelectNodes call again. if (categoryList.LastNodeListCount == 0 && !traitsCache.ContainsKey(key)) { traitsCache[key] = new CachedTestCaseInfo(); } } }
public static void AddTraitsFromTestNode(this TestCase testCase, NUnitTestCase testNCase, IDictionary <string, CachedTestCaseInfo> traitsCache, ITestLogger logger, IAdapterSettings adapterSettings) { var testNode = testNCase.Node; var ancestor = testNode.ParentNode; var key = ancestor?.Attributes?["id"]?.Value; var categoryList = new CategoryList(testCase, adapterSettings); // Reading ancestor properties of a test-case node. And adding to the cache. while (ancestor != null && key != null) { if (traitsCache.ContainsKey(key)) { categoryList.AddRange(traitsCache[key].Traits.Where(o => o.Name == NunitTestCategoryLabel).Select(prop => prop.Value).ToList()); if (traitsCache[key].Explicit) { testCase.SetPropertyValue(CategoryList.NUnitExplicitProperty, true); } var traitsList = traitsCache[key].Traits.Where(o => o.Name != NunitTestCategoryLabel).ToList(); if (traitsList.Count > 0) { testCase.Traits.AddRange(traitsList); } } else { categoryList.ProcessTestCaseProperties(ancestor, true, key, traitsCache); // Adding entry to dictionary, so that we will not make SelectNodes call again. if (categoryList.LastNodeListCount == 0 && !traitsCache.ContainsKey(key)) { traitsCache[key] = new CachedTestCaseInfo(); } } ancestor = ancestor.ParentNode; key = ancestor?.Attributes?["id"]?.Value; } // No Need to store test-case properties in cache. categoryList.ProcessTestCaseProperties(testNode, false); categoryList.UpdateCategoriesToVs(); }