/// <summary> /// Migrates the shared steps from source to destination. /// </summary> private void MigrateSharedStepsFromSourceToDestinationInternal() { if (!string.IsNullOrEmpty(this.MigrationSharedStepsRetryJsonPath) && File.Exists(this.MigrationSharedStepsRetryJsonPath)) { this.sharedStepsMigrationLogManager = new MigrationLogManager(this.MigrationSharedStepsRetryJsonPath); this.sharedStepsMigrationLogManager.LoadCollectionFromExistingFile(); this.sharedStepsMapping = this.sharedStepsMigrationLogManager.GetProssedItemsMappings(); } else { this.sharedStepsMigrationLogManager = new MigrationLogManager("sharedSteps", this.DefaultJsonFolder); } List <SharedStep> sourceSharedSteps = SharedStepManager.GetAllSharedStepsInTestPlan(this.sourceTeamProject); foreach (SharedStep currentSourceSharedStep in sourceSharedSteps) { if (this.executionCancellationToken.IsCancellationRequested) { break; } // If it's already processed skip it if (this.sharedStepsMigrationLogManager.MigrationEntries.Count(e => e.SourceId.Equals(currentSourceSharedStep.ISharedStep.Id) && e.IsProcessed.Equals(true)) > 0) { continue; } string infoMessage = String.Empty; try { infoMessage = String.Format("Start Migrating Shared Step with Source Id= {0}", currentSourceSharedStep.Id); log.Info(infoMessage); this.ProgressConcurrentQueue.Enqueue(infoMessage); List <TestStep> testSteps = TestStepManager.GetTestStepsFromTestActions(this.sourceTeamProject, currentSourceSharedStep.ISharedStep.Actions); SharedStep newSharedStep = currentSourceSharedStep.Save(this.destinationTeamProject, true, testSteps, false); newSharedStep.ISharedStep.Refresh(); this.sharedStepsMapping.Add(currentSourceSharedStep.ISharedStep.Id, newSharedStep.ISharedStep.Id); this.sharedStepsMigrationLogManager.Log(currentSourceSharedStep.Id, newSharedStep.ISharedStep.Id, true); infoMessage = String.Format("Shared Step Migrated SUCCESSFULLY: Source Id= {0}, Destination Id= {1}", currentSourceSharedStep.Id, newSharedStep.ISharedStep.Id); log.Info(infoMessage); this.ProgressConcurrentQueue.Enqueue(infoMessage); } catch (Exception ex) { this.sharedStepsMigrationLogManager.Log(currentSourceSharedStep.Id, -1, false, ex.Message); log.Error(ex); this.ProgressConcurrentQueue.Enqueue(ex.Message); } finally { this.sharedStepsMigrationLogManager.Save(); this.MigrationSharedStepsRetryJsonPath = this.sharedStepsMigrationLogManager.FullResultFilePath; } } this.IsSharedStepsMigrationFinished = true; }
/// <summary> /// Initializes a new instance of the <see cref="TestCaseEditViewModel"/> class. /// </summary> /// <param name="editViewContext">The edit view context.</param> public TestCaseEditViewModel(EditViewContext editViewContext) { this.EditViewContext = editViewContext; this.Areas = this.GetProjectAreas(); this.ObservableTestSteps = new ObservableCollection <TestStep>(); this.GenericParameters = new Dictionary <string, Dictionary <string, string> >(); if (!this.EditViewContext.IsSharedStep) { this.ShowTestCaseSpecificFields = true; ITestSuiteBase testSuiteBaseCore = null; if (this.EditViewContext.TestSuiteId != -1) { testSuiteBaseCore = TestSuiteManager.GetTestSuiteById(TestCaseManagerCore.ExecutionContext.TestManagementTeamProject, TestCaseManagerCore.ExecutionContext.Preferences.TestPlan, this.EditViewContext.TestSuiteId); } if (this.EditViewContext.CreateNew && !this.EditViewContext.Duplicate) { ITestCase newTestCase = TestCaseManagerCore.ExecutionContext.TestManagementTeamProject.TestCases.Create(); this.TestCase = new TestCase(newTestCase, testSuiteBaseCore, TestCaseManagerCore.ExecutionContext.Preferences.TestPlan, false); } else { ITestCase testCaseCore = TestCaseManagerCore.ExecutionContext.TestManagementTeamProject.TestCases.Find(this.EditViewContext.TestCaseId); this.TestCase = new TestCase(testCaseCore, testSuiteBaseCore, TestCaseManagerCore.ExecutionContext.Preferences.TestPlan, false); } this.ObservableSharedSteps = new ObservableCollection <SharedStep>(); this.InitializeObservableSharedSteps(); this.InitializeInitialSharedStepCollection(); this.InitializeTestCaseTestStepsFromITestCaseActions(); this.AssociatedAutomation = this.TestCase.ITestCase.GetAssociatedAutomation(); this.TestBase = this.TestCase; } else { if (this.EditViewContext.CreateNew && !this.EditViewContext.Duplicate) { ISharedStep currentSharedStepCore = TestCaseManagerCore.ExecutionContext.TestManagementTeamProject.SharedSteps.Create(); this.SharedStep = new SharedStep(currentSharedStepCore); } else { SharedStep currentSharedStep = SharedStepManager.GetSharedStepById(TestCaseManagerCore.ExecutionContext.TestManagementTeamProject, this.EditViewContext.SharedStepId); this.SharedStep = currentSharedStep; } List <TestStep> innerTestSteps = TestStepManager.GetAllTestStepsInSharedStep(this.SharedStep.ISharedStep, false); this.AddTestStepsToObservableCollection(innerTestSteps); this.ShowTestCaseSpecificFields = false; this.TestBase = this.SharedStep; this.ClearTestStepNames(); } this.InitializeIdLabelFromTestBase(this.EditViewContext.CreateNew, this.EditViewContext.Duplicate); this.InitializePageTitle(); log.InfoFormat("Load Edit View with Context: {0} ", editViewContext); TestStepManager.UpdateGenericSharedSteps(this.ObservableTestSteps); }
/// <summary> /// Refreshes the shared steps /// </summary> public void RefreshSharedSteps() { this.ObservableSharedSteps.Clear(); ExecutionContext.Preferences.TestPlan.Refresh(); ExecutionContext.Preferences.TestPlan.RootSuite.Refresh(); List <SharedStep> sharedStepsList = SharedStepManager.GetAllSharedStepsInTestPlan(ExecutionContext.TestManagementTeamProject); sharedStepsList.Sort(); sharedStepsList.ForEach(t => this.ObservableSharedSteps.Add(t)); }
/// <summary> /// Initializes a new instance of the <see cref="TestCasesBatchDuplicateViewModel"/> class. /// </summary> public TestCasesBatchDuplicateViewModel(bool loadTestCases, bool loadSpecificTestCases) { this.InitializeInnerCollections(); this.loadTestCases = loadTestCases; this.ShowTestCaseSpecificFields = loadTestCases; this.InitializeTeamFoundationIdentityNames(); this.ReplaceContext = new ReplaceContext(); if (loadTestCases) { if (!loadSpecificTestCases) { this.InitializeTestCases(); } else { this.InitializeTestCasesFromSpecificSelectedTestCases(); } this.InitializeInitialTestCaseCollection(); this.EntitiesCount = this.ObservableTestCases.Count.ToString(); this.InitializeTestSuiteList(); this.ReplaceContext.SelectedSuite = this.ObservableTestSuites[0]; } else { this.ObservableSharedSteps = new ObservableCollection <SharedStep>(); List <SharedStep> allSharedSteps = SharedStepManager.GetAllSharedStepsInTestPlan(ExecutionContext.TestManagementTeamProject); allSharedSteps.ForEach(s => this.ObservableSharedSteps.Add(s)); this.InitialSharedStepsCollection = new ObservableCollection <SharedStep>(); allSharedSteps.ForEach(s => this.InitialSharedStepsCollection.Add(s)); this.EntitiesCount = this.ObservableSharedSteps.Count.ToString(); } if (this.ObservableTeamFoundationIdentityNames.Count > 0) { this.ReplaceContext.SelectedTeamFoundationIdentityName = this.ObservableTeamFoundationIdentityNames[0]; } this.SelectedEntitiesCount = "0"; var setting = SearchQueryCompilerBuilder.Instance.BuildUpDefaultObjectCompilerSetting <TestCase>(); testCasesCompiler = SearchQueryCompilerBuilder.Instance.BuildUpCompiler <TestCase>(setting); var sharedSteposSetting = SearchQueryCompilerBuilder.Instance.BuildUpDefaultObjectCompilerSetting <SharedStep>(); sharedStepsCompiler = SearchQueryCompilerBuilder.Instance.BuildUpCompiler <SharedStep>(sharedSteposSetting); }