/// <summary> /// Refreshes the test cases. /// </summary> public void RefreshTestCases() { this.ObservableTestCases.Clear(); ExecutionContext.Preferences.TestPlan.Refresh(); ExecutionContext.Preferences.TestPlan.RootSuite.Refresh(); List <TestCase> testCasesList = TestCaseManager.GetAllTestCasesInTestPlan(ExecutionContext.TestManagementTeamProject, ExecutionContext.Preferences.TestPlan); testCasesList.ForEach(t => this.ObservableTestCases.Add(t)); }
/// <summary> /// Initializes the test cases. /// </summary> public void InitializeTestCases() { ExecutionContext.Preferences.TestPlan.Refresh(); ExecutionContext.Preferences.TestPlan.RootSuite.Refresh(); List <TestCase> testCasesList = TestCaseManager.GetAllTestCasesInTestPlan(ExecutionContext.TestManagementTeamProject, ExecutionContext.Preferences.TestPlan, false); //List<TestCase> testCasesList = TestCaseManager.GetAllTestCasesFromSuiteCollection(ExecutionContext.Preferences.TestPlan, ExecutionContext.Preferences.TestPlan.RootSuite.SubSuites); //TestCaseManager.AddTestCasesWithoutSuites(ExecutionContext.TestManagementTeamProject, ExecutionContext.Preferences.TestPlan, testCasesList); this.ObservableTestCases = new ObservableCollection <TestCase>(); testCasesList.ForEach(t => this.ObservableTestCases.Add(t)); }
/// <summary> /// Initializes a new instance of the <see cref="TestCasesInitialViewModel"/> class. /// </summary> public TestCasesInitialViewModel() { this.InitialViewFilters = new InitialViewFilters(); List <Suite> subSuites = TestSuiteManager.GetAllSuites(ExecutionContext.Preferences.TestPlan.RootSuite.SubSuites).ToList(); subSuites.Sort(); // Load last selected suite in the treeview in order to selected it again this.selectedSuiteId = RegistryManager.Instance.GetSelectedSuiteId(); List <TestCase> suiteTestCaseCollection = new List <TestCase>(); this.ShowSubSuitesTestCases = RegistryManager.Instance.ReadShowSubsuiteTestCases(); if (this.selectedSuiteId != -1) { try { suiteTestCaseCollection = TestCaseManager.GetAllTestCaseFromSuite(ExecutionContext.Preferences.TestPlan, this.selectedSuiteId); this.AddTestCasesSubsuites(suiteTestCaseCollection); } catch (NullReferenceException ex) { log.Error(ex); if (subSuites.Count > 0) { suiteTestCaseCollection = TestCaseManager.GetAllTestCaseFromSuite(ExecutionContext.Preferences.TestPlan, subSuites[0].Id); this.selectedSuiteId = subSuites[0].Id; } else { suiteTestCaseCollection = TestCaseManager.GetAllTestCasesInTestPlan(ExecutionContext.TestManagementTeamProject, ExecutionContext.Preferences.TestPlan); } } } else if (ExecutionContext.Preferences.TestPlan.RootSuite != null && ExecutionContext.Preferences.TestPlan.RootSuite.SubSuites != null && ExecutionContext.Preferences.TestPlan.RootSuite.SubSuites.Count > 0) { suiteTestCaseCollection = TestCaseManager.GetAllTestCaseFromSuite(ExecutionContext.Preferences.TestPlan, ExecutionContext.Preferences.TestPlan.RootSuite.SubSuites.First().Id); this.selectedSuiteId = ExecutionContext.Preferences.TestPlan.RootSuite.SubSuites.First().Id; this.ShowSubSuitesTestCases = false; RegistryManager.Instance.WriteShowSubsuiteTestCases(false); } else { this.ShowSubSuitesTestCases = false; RegistryManager.Instance.WriteShowSubsuiteTestCases(false); suiteTestCaseCollection = TestCaseManager.GetAllTestCasesInTestPlan(ExecutionContext.TestManagementTeamProject, ExecutionContext.Preferences.TestPlan); } this.ObservableTestCases = new ObservableCollection <TestCase>(); this.InitialTestCaseCollection = new ObservableCollection <TestCase>(); suiteTestCaseCollection.ForEach(t => this.ObservableTestCases.Add(t)); this.InitializeInitialTestCaseCollection(this.ObservableTestCases); this.TestCasesCount = this.ObservableTestCases.Count.ToString(); this.Suites = new ObservableCollection <Suite>(); ObservableCollection <Suite> currentSubSuites = new ObservableCollection <Suite>(); var setting = SearchQueryCompilerBuilder.Instance.BuildUpDefaultObjectCompilerSetting <TestCase>(); compiler = SearchQueryCompilerBuilder.Instance.BuildUpCompiler <TestCase>(setting); subSuites.ForEach(s => currentSubSuites.Add(s)); // Add a master node which will represnt all test cases in the plan. If selected all test cases will be displayed. Suite masterSuite = new Suite("ALL", -1, currentSubSuites); masterSuite.IsNodeExpanded = true; masterSuite.IsSelected = false; masterSuite.IsCopyEnabled = false; masterSuite.IsRenameEnabled = false; masterSuite.IsCutEnabled = false; masterSuite.IsRemoveEnabled = false; this.Suites.Add(masterSuite); TestSuiteManager.SetParentToAllChildrenSuites(masterSuite.SubSuites, masterSuite); this.SelectPreviouslySelectedSuite(this.Suites, this.selectedSuiteId); this.IsAfterInitialize = true; this.SelectedTestCasesCount = "0"; this.CurrentExecutionStatusOption = TestCaseExecutionType.All; }
/// <summary> /// Adds the new test cases to new suites destination. /// </summary> public void AddNewTestCasesToNewSuitesDestinationInternal() { if (!string.IsNullOrEmpty(this.MigrationAddTestCasesToSuitesRetryJsonPath) && File.Exists(this.MigrationAddTestCasesToSuitesRetryJsonPath)) { this.testCasesAddToSuitesMigrationLogManager = new MigrationLogManager(this.MigrationAddTestCasesToSuitesRetryJsonPath); this.testCasesAddToSuitesMigrationLogManager.LoadCollectionFromExistingFile(); this.sharedStepsMapping = this.testCasesAddToSuitesMigrationLogManager.GetProssedItemsMappings(); } else { this.testCasesAddToSuitesMigrationLogManager = new MigrationLogManager("testCasesToSuites", this.DefaultJsonFolder); } this.ProgressConcurrentQueue.Enqueue("Prepare destination test cases..."); ITestPlan destinationTestPlan = TestPlanManager.GetTestPlanByName(this.destinationTeamProject, this.SelectedDestinationTestPlan); List <TestCase> destinationTestCases = TestCaseManager.GetAllTestCasesInTestPlan(this.destinationTeamProject, destinationTestPlan, false); this.ProgressConcurrentQueue.Enqueue("Prepare source test cases..."); ITestPlan sourceTestPlan = TestPlanManager.GetTestPlanByName(this.sourceTeamProject, this.SelectedSourceTestPlan); List <TestCase> sourceTestCases = TestCaseManager.GetAllTestCasesFromSuiteCollection(this.sourcePreferences.TestPlan, this.sourcePreferences.TestPlan.RootSuite.SubSuites); foreach (TestCase currentSourceTestCase in sourceTestCases) { if (this.executionCancellationToken.IsCancellationRequested) { break; } // If it's already processed skip it if (this.testCasesAddToSuitesMigrationLogManager.MigrationEntries.Count(e => e.SourceId.Equals(currentSourceTestCase.ITestCase.Id) && e.IsProcessed.Equals(true)) > 0) { continue; } if (currentSourceTestCase.ITestSuiteBase != null && this.ObservableSuitesToBeSkipped.Count(t => t != null && t.NewText != null && t.NewText.Equals(currentSourceTestCase.ITestSuiteBase.Title)) > 0) { continue; } string infoMessage = String.Empty; try { infoMessage = String.Format("Start Adding to Suite Test Case with Source Id= {0}", currentSourceTestCase.Id); log.Info(infoMessage); this.ProgressConcurrentQueue.Enqueue(infoMessage); if (currentSourceTestCase.ITestSuiteBase == null) { continue; } else { int sourceParentSuiteId = currentSourceTestCase.ITestSuiteBase.Id; if (!this.suitesMapping.ContainsKey(sourceParentSuiteId)) { return; } else { int destinationSuiteId = this.suitesMapping[sourceParentSuiteId]; ITestSuiteBase destinationSuite = this.destinationTeamProject.TestSuites.Find(destinationSuiteId); if (this.testCasesMapping.ContainsKey(currentSourceTestCase.ITestCase.Id)) { TestCase currentDestinationTestCase = destinationTestCases.FirstOrDefault(t => t.Id.Equals(this.testCasesMapping[currentSourceTestCase.ITestCase.Id])); destinationSuite.AddTestCase(currentDestinationTestCase.ITestCase); this.testCasesAddToSuitesMigrationLogManager.Log(currentSourceTestCase.ITestCase.Id, destinationSuite.Id, true); infoMessage = String.Format("Test Case SUCCESSFULLY added to Suite: Test Case Id= {0}, Suite Id= {1}", currentDestinationTestCase.ITestCase.Id, destinationSuite.Id); log.Info(infoMessage); this.ProgressConcurrentQueue.Enqueue(infoMessage); } } } } catch (Exception ex) { if (currentSourceTestCase != null) { this.testCasesAddToSuitesMigrationLogManager.Log(currentSourceTestCase.ITestCase.Id, -1, false, ex.Message); log.Error(ex); this.ProgressConcurrentQueue.Enqueue(ex.Message); } } finally { this.testCasesAddToSuitesMigrationLogManager.Save(); this.MigrationAddTestCasesToSuitesRetryJsonPath = this.testCasesAddToSuitesMigrationLogManager.FullResultFilePath; } } }