/// <summary> /// Creates list of profiles supported. /// </summary> /// <param name="profiles"></param> /// <param name="allTests"></param> /// <param name="selectedTests"></param> /// <param name="features"></param> /// <returns></returns> public static ProfilesSupportInfo LoadPreliminary(IEnumerable <IProfileDefinition> profiles, IEnumerable <TestInfo> allTests, IEnumerable <TestInfo> selectedTests, IEnumerable <Feature> features) { // all functionality to be tested List <Functionality> functionalitiesUnderTests = new List <Functionality>(); // no tests in suite at all List <Functionality> noTests = new List <Functionality>(); Dictionary <IProfileDefinition, List <Functionality> > allSkippedByFeatures = new Dictionary <IProfileDefinition, List <Functionality> >(); Dictionary <IProfileDefinition, List <Functionality> > allMandatorySkippedByFeatures = new Dictionary <IProfileDefinition, List <Functionality> >(); // functionalities under tests foreach (TestInfo info in selectedTests) { foreach (Functionality f in info.FunctionalityUnderTest) { if (!functionalitiesUnderTests.Contains(f)) { functionalitiesUnderTests.Add(f); } } } foreach (IProfileDefinition profile in profiles) { List <Functionality> skippedByFeatures = new List <Functionality>(); List <Functionality> mandatorySkippedByFeatures = new List <Functionality>(); allSkippedByFeatures.Add(profile, skippedByFeatures); allMandatorySkippedByFeatures.Add(profile, mandatorySkippedByFeatures); System.Diagnostics.Debug.WriteLine("Profile: " + profile.Name); foreach (FunctionalityItem item in profile.Functionalities) { System.Diagnostics.Debug.Write(item.Functionality.ToString()); if (functionalitiesUnderTests.Contains(item.Functionality)) { // definetely not skipped continue; } // // Skipped. It can mean: // - no tests at all // - no tests since feature not supported // this can be OK or NOK for profile if (noTests.Contains(item.Functionality)) { System.Diagnostics.Debug.WriteLine(" not under test at all "); // status is known continue; } bool hasTest = false; List <TestInfo> testInfos = new List <TestInfo>(); foreach (TestInfo ti in allTests) { if (ti.FunctionalityUnderTest != null && ti.FunctionalityUnderTest.Contains(item.Functionality)) { hasTest = true; bool skipped = false; foreach (Feature f in ti.RequiredFeatures) { if (!features.ContainsFeature(f)) { skipped = true; break; } } if (!skipped) { testInfos.Add(ti); } } } if (hasTest) { if (testInfos.Count == 0) { // all tests skipped due to features selection if (!profile.IsFunctionalityOptional(item.Functionality)) { System.Diagnostics.Debug.WriteLine(" mandatory, skipped by features "); mandatorySkippedByFeatures.Add(item.Functionality); } else { System.Diagnostics.Debug.WriteLine(" optional, skipped by features "); skippedByFeatures.Add(item.Functionality); } } } else { noTests.Add(item.Functionality); } } } ProfilesSupportInfo psi = new ProfilesSupportInfo(); psi.FunctionalityUnderTests = functionalitiesUnderTests; psi.FunctionalityWithoutTests = noTests; psi.OptionalFunctionalityUnderSkippedTests = allSkippedByFeatures; psi.MandatoryFunctionalityWithoutFeatures = allMandatorySkippedByFeatures; return(psi); }
/// <summary> /// Creates list of profiles supported. /// </summary> /// <param name="profiles"></param> /// <param name="allTests"></param> /// <param name="selectedTests"></param> /// <param name="features"></param> /// <returns></returns> public static ProfilesSupportInfo LoadPreliminary(IEnumerable <IProfileDefinition> profiles, IEnumerable <TestInfo> allTests, IEnumerable <TestInfo> selectedTests, IEnumerable <Feature> features, Dictionary <string, object> parameters) { // all functionality to be tested List <Functionality> functionalitiesUnderTests = new List <Functionality>(); // no tests in suite at all List <Functionality> noTests = new List <Functionality>(); Dictionary <IProfileDefinition, List <Functionality> > allSkippedByFeatures = new Dictionary <IProfileDefinition, List <Functionality> >(); Dictionary <IProfileDefinition, List <Functionality> > allMandatorySkippedByFeatures = new Dictionary <IProfileDefinition, List <Functionality> >(); // functionalities under tests foreach (TestInfo info in selectedTests) { foreach (Functionality f in info.FunctionalityUnderTest) { if (!functionalitiesUnderTests.Contains(f)) { functionalitiesUnderTests.Add(f); } } } foreach (IProfileDefinition profile in profiles) { List <Functionality> skippedByFeatures = new List <Functionality>(); List <Functionality> mandatorySkippedByFeatures = new List <Functionality>(); allSkippedByFeatures.Add(profile, skippedByFeatures); allMandatorySkippedByFeatures.Add(profile, mandatorySkippedByFeatures); System.Diagnostics.Debug.WriteLine("Profile: " + profile.GetProfileName()); foreach (FunctionalityItem item in profile.Functionalities) { System.Diagnostics.Debug.Write(item.Functionality.ToString()); if (item.Features != null && item.Features.Length > 0) { bool featureMissing = false; foreach (Feature f in item.Features) { if (!features.ContainsFeature(f)) { featureMissing = true; break; } } if (featureMissing) { if (!profile.IsFunctionalityOptional(item.Functionality, features)) { mandatorySkippedByFeatures.Add(item.Functionality); } else { skippedByFeatures.Add(item.Functionality); } continue; } else { //Feature is supported if (Functionality.AtLeastTwoPullPointSubscription == item.Functionality) { var maxPullPointsValue = (int)parameters["MaxPullPoints"]; if (maxPullPointsValue < 2) { if (!profile.IsFunctionalityOptional(item.Functionality, features)) { mandatorySkippedByFeatures.Add(item.Functionality); } else { skippedByFeatures.Add(item.Functionality); } continue; } } } } if (functionalitiesUnderTests.Contains(item.Functionality)) { // definetely not skipped continue; } // // Skipped. It can mean: // - no tests at all // - no tests since feature not supported // this can be OK or NOK for profile if (noTests.Contains(item.Functionality)) { System.Diagnostics.Debug.WriteLine(" not under test at all "); // status is known continue; } bool hasTest = selectedTests.Any(ti => ti.FunctionalityUnderTest != null && ti.FunctionalityUnderTest.Contains(item.Functionality)); if (!hasTest) { noTests.Add(item.Functionality); } } } ProfilesSupportInfo psi = new ProfilesSupportInfo(); psi.FunctionalityUnderTests = functionalitiesUnderTests; psi.FunctionalityWithoutTests = noTests; psi.OptionalFunctionalityUnderSkippedTests = allSkippedByFeatures; psi.MandatoryFunctionalityWithoutFeatures = allMandatorySkippedByFeatures; return(psi); }