bool ProcessProfile(string profileName = null, bool exclude = false) { bool softCheck = profileName != null; if (softCheck || NextParam(ref profileName)) { profileName = profileName.ToLower(); var profMatch = DefinedProfiles.Where(p => p.ProfileName.ToLower() == profileName); if (profMatch.Count() == 0) { profMatch = DefinedProfiles.Where(p => p.ProfileName.ToLower().StartsWith(profileName)); } if (profMatch.Count() != 0) { var tests = profMatch.First().GetProfileTests(this); if (exclude) { TestsToExclude.AddRange(tests); } else { // An explicitly specified profile was added, so clear the // default profile if necessary ClearDefaultProfile(); TestCfg.TestsToRun.AddRange(tests); } return(true); } // Check if the requested profile is a test category name var categories = Enum.GetNames(typeof(Category)); var catMatch = categories.Where(c => c.ToLower() == profileName); if (catMatch.Count() == 0) { catMatch = categories.Where(c => c.ToLower().StartsWith(profileName)); } foreach (var catName in catMatch) { Category cat = Category.None; if (!Enum.TryParse(catName, true, out cat)) { Debug.Assert("Failed to parse test category name" == null); } var tests = Target.AllTestNames.Where(item => Target.GetTestAttribute(item).Category.HasFlag(cat)); if (exclude) { TestsToExclude.AddRange(tests); // Store info about disabled category TestCfg.DisabledTests.Category |= cat; } else { // An explicitly specified profile was added, so clear the // default profile if necessary ClearDefaultProfile(); TestCfg.TestsToRun.AddRange(tests); // Prevent possible filtering out just included tests TestCfg.DisabledTests.Category &= ~cat; } return(true); } if (!softCheck) { Target.WriteErrorToLog("Profile name is not recognized"); } } if (!softCheck) { Console.WriteLine("Defined test profiles:\n" + GetDefinedProfileNamesList()); } return(false); }