private static IEnumerable <UnitTestElementCategory> GetCategories(MultiValueDictionary <string, string> traits) { var categories = from key in traits where !key.IsNullOrEmpty() && !key.IsWhitespace() from value in traits[key] where !value.IsNullOrEmpty() && !value.IsWhitespace() select string.Compare(key, "category", StringComparison.InvariantCultureIgnoreCase) != 0 ? string.Format("{0}[{1}]", key.Trim(), value.Trim()) : value; // TODO: Get rid of the ToHashSet - it's only needed in 8.0 due to a signature change // Unnecessary allocation return(UnitTestElementCategory.Create(categories.ToHashSet())); }
public ContextSpecificationElement(MSpecUnitTestProvider provider, PsiModuleManager psiModuleManager, CacheManager cacheManager, // ReSharper disable SuggestBaseTypeForParameter ContextElement context, // ReSharper restore SuggestBaseTypeForParameter ProjectModelElementEnvoy project, string declaringTypeName, string fieldName, IEnumerable <string> tags, bool isIgnored) : base(provider, psiModuleManager, cacheManager, context, project, declaringTypeName, fieldName, isIgnored || context.Explicit) { if (tags != null) { _categories = UnitTestElementCategory.Create(tags); } }
public static GallioTestElement CreateFromTest(TestData test, ICodeElementInfo codeElement, GallioTestProvider provider, GallioTestElement parent) { if (test == null) { throw new ArgumentNullException("test"); } // The idea here is to generate a test element object that does not retain any direct // references to the code element info and other heavyweight objects. A test element may // survive in memory for quite a long time so we don't want it holding on to all sorts of // irrelevant stuff. Basically we flatten out the test to just those properties that we // need to keep. var project = ReSharperReflectionPolicy.GetProject(codeElement); var element = GetElementById(project, test.Id); if (element == null) { element = new GallioTestElement(provider, parent, test.Id, test.Name, test.Metadata.GetValue(MetadataKeys.TestKind) ?? "Unknown", test.IsTestCase, project, ReSharperReflectionPolicy.GetDeclaredElementResolver(codeElement), GetAssemblyPath(codeElement), GetTypeName(codeElement), GetNamespaceName(codeElement)); } element.State = UnitTestElementState.Valid; var categories = test.Metadata[MetadataKeys.Category]; element.Categories = UnitTestElementCategory.Create(categories); var reason = test.Metadata.GetValue(MetadataKeys.IgnoreReason); if (reason != null) { element.Explicit = true; element.ExplicitReason = reason; } return(element); }
public ContextElement(MSpecUnitTestProvider provider, PsiModuleManager psiModuleManager, CacheManager cacheManager, ProjectModelElementEnvoy projectEnvoy, string typeName, string assemblyLocation, string subject, IEnumerable <string> tags, bool isIgnored) : base(provider, psiModuleManager, cacheManager, null, projectEnvoy, typeName, isIgnored) { _assemblyLocation = assemblyLocation; _subject = subject; if (tags != null) { _categories = UnitTestElementCategory.Create(tags); } }
public ContextElement(MSpecUnitTestProvider provider, IPsi psiModuleManager, ICache cacheManager, ProjectModelElementEnvoy projectEnvoy, IClrTypeName typeName, string assemblyLocation, string subject, IEnumerable <string> tags, bool isIgnored) : base(provider, psiModuleManager, cacheManager, null, projectEnvoy, typeName, isIgnored) { _id = CreateId(subject, TypeName.FullName, tags); _assemblyLocation = assemblyLocation; _subject = subject; if (tags != null) { _categories = UnitTestElementCategory.Create(new JetHashSet <string>(tags)); } }
public void SetCategories(JetHashSet <string> categories) { Categories = UnitTestElementCategory.Create(categories); }