/// <summary>
 /// Removes the test step from test steps observable collection.
 /// </summary>
 /// <param name="testStepToBeRemoved">The test step to be removed.</param>
 /// <param name="selectedIndex">Index of the selected.</param>
 public void RemoveTestStepFromObservableCollection(TestStep testStepToBeRemoved, int selectedIndex)
 {
     this.ObservableTestSteps.Remove(testStepToBeRemoved);
     log.InfoFormat("Remove test step ActionTitle = {0}, ExpectedResult= {1}", testStepToBeRemoved.ActionTitle, testStepToBeRemoved.ActionExpectedResult);
     UndoRedoManager.Instance().Push((r, i) => this.InsertTestStepInTestCase(r, i), testStepToBeRemoved, selectedIndex, "remove Test Step");
     TestStepManager.UpdateGenericSharedSteps(this.ObservableTestSteps);
 }
 /// <summary>
 /// Inserts the test step information to the test case.
 /// </summary>
 /// <param name="testStepToInsert">The test step to be insert.</param>
 /// <param name="selectedIndex">Index of the selected test step.</param>
 /// <param name="skipShared">if set to <c>true</c> [skip shared].</param>
 /// <returns>
 /// new selected index
 /// </returns>
 public int InsertTestStepInTestCase(TestStep testStepToInsert, int selectedIndex, bool skipShared = true)
 {
     if (!skipShared)
     {
         selectedIndex = this.FindNextNotSharedStepIndex(selectedIndex);
     }
     // If you delete first step and call redo operation, the step should be inserted at the beginning
     if (selectedIndex == -2)
     {
         log.InfoFormat("Insert test step ActionTitle= {0}, ActionExpectedResult= {1}, index= {2}", testStepToInsert.ActionTitle, testStepToInsert.ActionExpectedResult, 0);
         this.ObservableTestSteps.Insert(0, testStepToInsert);
     }
     else if (selectedIndex != -1)
     {
         this.ObservableTestSteps.Insert(selectedIndex + 1, testStepToInsert);
         log.InfoFormat("Insert test step ActionTitle= {0}, ActionExpectedResult= {1}, index= {2}", testStepToInsert.ActionTitle, testStepToInsert.ActionExpectedResult, selectedIndex + 1);
     }
     else
     {
         this.ObservableTestSteps.Add(testStepToInsert);
         selectedIndex = this.ObservableTestSteps.Count - 1;
         log.InfoFormat("Insert test step ActionTitle= {0}, ActionExpectedResult= {1}, end of test case", testStepToInsert.ActionTitle, testStepToInsert.ActionExpectedResult);
     }
     UndoRedoManager.Instance().Push((r, i) => this.RemoveTestStepFromObservableCollection(r, i), testStepToInsert, selectedIndex);
     TestStepManager.UpdateGenericSharedSteps(this.ObservableTestSteps);
     return(selectedIndex);
 }
        /// <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>
 /// Filters the initialization test steps.
 /// </summary>
 private void InitializeTestSteps(List <TestStep> testSteps)
 {
     foreach (var curretTestStep in testSteps)
     {
         if (!TestStepManager.IsInitializationTestStep(curretTestStep))
         {
             this.ObservableTestSteps.Add(curretTestStep);
         }
     }
 }
 /// <summary>
 /// Refreshes the shared step collections.
 /// </summary>
 public void RefreshSharedStepCollections(System.Windows.Threading.Dispatcher uiDispatcher, CancellationToken cancellationToken)
 {
     do
     {
         if (cancellationToken != null && cancellationToken.IsCancellationRequested)
         {
             return;
         }
         if (this.EditViewContext.IsInitialized && !this.EditViewContext.IsSharedStep)
         {
             List <ISharedStep> sharedStepList = TestStepManager.GetAllSharedSteps();
             List <SharedStep>  sharedSteps    = new List <BusinessLogic.Entities.SharedStep>();
             sharedStepList.ForEach(s =>
             {
                 sharedSteps.Add(new SharedStep(s));
             });
             sharedSteps.Sort();
             Action action = new Action(() =>
             {
                 if (this.ObservableSharedSteps != null && this.InitialSharedStepCollection != null)
                 {
                     this.ObservableSharedSteps.Clear();
                     sharedSteps.ForEach(s =>
                     {
                         this.ObservableSharedSteps.Add(s);
                     });
                     this.InitialSharedStepCollection.Clear();
                     sharedSteps.ForEach(s =>
                     {
                         this.InitialSharedStepCollection.Add(s);
                     });
                     this.InitializeInitialSharedStepCollection();
                     this.SharedStepsRefreshEvent(this, EventArgs.Empty);
                 }
             });
             try
             {
                 uiDispatcher.Invoke(action);
             }
             catch (AggregateException e)
             {
                 log.Error(e);
                 foreach (var innerException in e.InnerExceptions)
                 {
                     log.Error(innerException);
                 }
             }
         }
         Thread.Sleep(30000);
     }while (true);
 }
Exemple #7
0
        /// <summary>
        /// Initializes the test steps for export.
        /// </summary>
        /// <param name="testSteps">The test steps.</param>
        /// <returns>reinitialized test steps for export</returns>
        private List <TestStep> InitializeTestStepsForExport(List <TestStep> testSteps)
        {
            List <TestStep> testStepsForExport = new List <TestStep>();

            foreach (var curretTestStep in testSteps)
            {
                if (!TestStepManager.IsInitializationTestStep(curretTestStep))
                {
                    testStepsForExport.Add(curretTestStep);
                }
            }

            return(testStepsForExport);
        }
Exemple #8
0
        /// <summary>
        /// Gets all full test cases for observable test cases.
        /// </summary>
        /// <param name="testPlan">The test plan.</param>
        /// <param name="selectedTestCases">The selected test cases.</param>
        /// <returns>
        /// list of full test cases
        /// </returns>
        private List <TestCaseFull> GetAllFullTestCasesForObservableTestCases(List <TestCase> selectedTestCases)
        {
            List <TestCaseFull> fullTestCases = new List <TestCaseFull>();

            foreach (TestCase currentTestCase in selectedTestCases)
            {
                string          mostRecentResult = TestCaseManager.GetMostRecentTestCaseResult(ExecutionContext.Preferences.TestPlan, currentTestCase.Id);
                string          executionComment = TestCaseManager.GetMostRecentExecutionComment(ExecutionContext.Preferences.TestPlan, currentTestCase.Id);
                List <TestStep> currentTestSteps = TestStepManager.GetTestStepsFromTestActions(ExecutionContext.TestManagementTeamProject, currentTestCase.ITestCase.Actions);
                fullTestCases.Add(new TestCaseFull(currentTestCase, currentTestSteps, mostRecentResult, executionComment));
            }

            return(fullTestCases);
        }
        /// <summary>
        /// Initializes the observable shared steps.
        /// </summary>
        private void InitializeObservableSharedSteps()
        {
            List <ISharedStep> sharedStepList = TestStepManager.GetAllSharedSteps();
            List <SharedStep>  sharedSteps    = new List <BusinessLogic.Entities.SharedStep>();

            sharedStepList.ForEach(s =>
            {
                sharedSteps.Add(new SharedStep(s));
            });
            sharedSteps.Sort();
            sharedSteps.ForEach(s =>
            {
                this.ObservableSharedSteps.Add(s);
            });
        }
        /// <summary>
        /// Inserts the new shared step.
        /// </summary>
        /// <param name="currentSharedStep">The current shared step.</param>
        /// <param name="selectedIndex">Index of the selected test step.</param>
        /// <returns>return the index of the last inserted step</returns>
        public int InsertSharedStep(SharedStep currentSharedStep, int selectedIndex)
        {
            List <TestStep> innerTestSteps = TestStepManager.GetAllTestStepsInSharedStep(currentSharedStep.ISharedStep);

            log.InfoFormat("Insert Shared Step Title= {0}, SelectedIndex= {1}", currentSharedStep.Title, selectedIndex);
            int j = 0;
            int finalInsertedStepIndex = 0;

            for (int i = selectedIndex; i < innerTestSteps.Count + selectedIndex; i++)
            {
                finalInsertedStepIndex = this.InsertTestStepInTestCase(innerTestSteps[j], i, false);
                j++;
            }

            return(finalInsertedStepIndex);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SharedStep"/> class.
        /// </summary>
        /// <param name="sharedStepCore">The shared step core object.</param>
        public SharedStep(ISharedStep sharedStepCore)
        {
            this.ISharedStep = sharedStepCore;
            List <TestStep> allTestSteps = TestStepManager.GetAllTestStepsInSharedStep(sharedStepCore);

            this.StepsToolTip = TestStepManager.GenerateTestStepsText(allTestSteps);
            this.Title        = sharedStepCore.Title;
            this.Area         = sharedStepCore.Area;
            this.Priority     = (Priority)sharedStepCore.Priority;
            this.TeamFoundationIdentityName = new TeamFoundationIdentityName(sharedStepCore.OwnerTeamFoundationId, sharedStepCore.OwnerName);
            this.OwnerDisplayName           = sharedStepCore.OwnerName;
            this.TeamFoundationId           = sharedStepCore.OwnerTeamFoundationId;
            this.DateCreated   = sharedStepCore.DateCreated;
            this.DateModified  = sharedStepCore.DateModified;
            base.isInitialized = true;
            this.Id            = sharedStepCore.Id;
            this.CreatedBy     = sharedStepCore.WorkItem.CreatedBy;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TestCaseDetailedViewModel"/> class.
        /// </summary>
        /// <param name="testCaseId">The test case unique identifier.</param>
        /// <param name="suiteId">The suite unique identifier.</param>
        public TestCaseDetailedViewModel(int testCaseId, int suiteId)
        {
            ITestCase      testCaseCore      = ExecutionContext.TestManagementTeamProject.TestCases.Find(testCaseId);
            ITestSuiteBase testSuiteBaseCore = null;

            if (suiteId != -1)
            {
                testSuiteBaseCore = ExecutionContext.TestManagementTeamProject.TestSuites.Find(suiteId);
            }

            this.TestCase    = new TestCase(testCaseCore, testSuiteBaseCore, ExecutionContext.Preferences.TestPlan);
            this.TestActions = new List <ITestAction>();
            this.TestCase.ITestCase.Actions.ToList().ForEach(x => this.TestActions.Add(x));
            this.ObservableTestSteps = new ObservableCollection <TestStep>();
            List <TestStep> testSteps = TestStepManager.GetTestStepsFromTestActions(ExecutionContext.TestManagementTeamProject, this.TestActions);

            this.AssociatedAutomation = this.TestCase.ITestCase.GetAssociatedAutomation();
            TestStepManager.UpdateGenericSharedSteps(testSteps);
            this.InitializeTestSteps(testSteps);
        }
Exemple #13
0
        /// <summary>
        /// Finds the and replace information test case/shared step.
        /// </summary>
        /// <param name="entityToReplaceIn">The test case/shared step to replace in.</param>
        private void FindAndReplaceInEntityInternal(Object entityToReplaceIn)
        {
            TestCase   currentTestCase   = null;
            SharedStep currentSharedStep = null;

            if (entityToReplaceIn is TestCase)
            {
                currentTestCase           = entityToReplaceIn as TestCase;
                currentTestCase.ITestCase = ExecutionContext.TestManagementTeamProject.TestCases.Find(currentTestCase.ITestCase.Id);
                log.InfoFormat("Find and Replace in test case with Title= \"{0}\" id= \"{1}\"", currentTestCase.Title, currentTestCase.Id);
                List <TestStep> testSteps = TestStepManager.GetTestStepsFromTestActions(ExecutionContext.TestManagementTeamProject, currentTestCase.ITestCase.Actions.ToList());
                this.ReplaceTestCaseTitle(currentTestCase);
                this.ChangeTestCasePriority(currentTestCase);
                this.ChangeTestCaseOwner(currentTestCase);
                this.ReplaceStepsInTestCase(currentTestCase, testSteps);

                currentTestCase.ITestCase.Actions.Add(currentTestCase.ITestCase.CreateTestStep());
                currentTestCase.ITestCase.Flush();
                currentTestCase.ITestCase.Save();

                currentTestCase.ITestCase.Actions.RemoveAt(currentTestCase.ITestCase.Actions.Count - 1);
                currentTestCase.ITestCase.Save();
            }
            else
            {
                currentSharedStep             = entityToReplaceIn as SharedStep;
                currentSharedStep.ISharedStep = ExecutionContext.TestManagementTeamProject.SharedSteps.Find(currentSharedStep.ISharedStep.Id);
                log.InfoFormat("Find and Replace in shared step with Title= \"{0}\" id= \"{1}\"", currentSharedStep.Title, currentSharedStep.Id);
                List <TestStep> testSteps = TestStepManager.GetTestStepsFromTestActions(ExecutionContext.TestManagementTeamProject, currentSharedStep.ISharedStep.Actions.ToList());
                this.ReplaceSharedStepTitle(currentSharedStep);
                this.ChangeSharedStepPriority(currentSharedStep);
                this.ChangeSharedStepOwner(currentSharedStep);
                this.ReplaceStepsInSharedStep(currentSharedStep, testSteps);

                currentSharedStep.ISharedStep.Actions.Add(currentSharedStep.ISharedStep.CreateTestStep());
                currentSharedStep.ISharedStep.Flush();
                currentSharedStep.ISharedStep.Save();
                currentSharedStep.ISharedStep.Actions.RemoveAt(currentSharedStep.ISharedStep.Actions.Count - 1);
                currentSharedStep.ISharedStep.Save();
            }
        }
Exemple #14
0
        /// <summary>
        /// Duplicates the test case/shared Step.
        /// </summary>
        /// <param name="entityToBeDuplicated">The test case/shared step to be duplicated.</param>
        private void DuplicateEntityInternal(Object entityToBeDuplicated)
        {
            SharedStep currentSharedStep = null;

            if (entityToBeDuplicated is TestCase)
            {
                TestCase  testCaseToBeDuplicated = entityToBeDuplicated as TestCase;
                ITestCase testCaseCore           = ExecutionContext.TestManagementTeamProject.TestCases.Create();
                TestCase  currentTestCase        = new TestCase(testCaseCore, testCaseToBeDuplicated.ITestSuiteBase, ExecutionContext.Preferences.TestPlan);
                currentTestCase.ITestCase.Area  = testCaseToBeDuplicated.ITestCase.Area;
                currentTestCase.ITestCase.Title = testCaseToBeDuplicated.ITestCase.Title;
                //currentTestCase.ITestCase = ExecutionContext.TestManagementTeamProject.TestCases.Find(currentTestCase.ITestCase.Id);
                log.InfoFormat("Duplicate test case with Title= \"{0}\" id= \"{1}\"", currentTestCase.Title, currentTestCase.Id);
                List <TestStep> testSteps = TestStepManager.GetTestStepsFromTestActions(ExecutionContext.TestManagementTeamProject, testCaseToBeDuplicated.ITestCase.Actions.ToList());
                this.ReplaceTestCaseTitle(currentTestCase);
                this.ChangeTestCasePriority(currentTestCase);
                this.ChangeTestCaseOwner(currentTestCase);
                this.ReplaceStepsInTestCase(currentTestCase, testSteps);

                currentTestCase.ITestCase.Flush();
                currentTestCase.ITestCase.Save();
                this.AddTestCaseToSuite(currentTestCase);
            }
            else
            {
                SharedStep  sharedStepToBeDuplicated = entityToBeDuplicated as SharedStep;
                ISharedStep sharedStepCore           = ExecutionContext.TestManagementTeamProject.SharedSteps.Create();
                currentSharedStep = new SharedStep(sharedStepCore);
                currentSharedStep.ISharedStep.Area = sharedStepToBeDuplicated.ISharedStep.Area;
                log.InfoFormat("Duplicate shared step with Title= \"{0}\" id= \"{1}\"", currentSharedStep.Title, currentSharedStep.Id);
                List <TestStep> testSteps = TestStepManager.GetTestStepsFromTestActions(ExecutionContext.TestManagementTeamProject, currentSharedStep.ISharedStep.Actions.ToList());
                this.ReplaceSharedStepTitle(currentSharedStep);
                this.ChangeSharedStepPriority(currentSharedStep);
                this.ChangeSharedStepOwner(currentSharedStep);
                this.ReplaceStepsInSharedStep(currentSharedStep, testSteps);

                currentSharedStep.ISharedStep.Flush();
                currentSharedStep.ISharedStep.Save();
            }
        }
Exemple #15
0
        /// <summary>
        /// Exports the test cases.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="selectedTestCases">The selected test cases.</param>
        public void ExportTestCases(string fileName, List <TestCase> selectedTestCases)
        {
            List <TestCaseFull> fullTestCases = this.GetAllFullTestCasesForObservableTestCases(selectedTestCases);

            foreach (TestCaseFull currentFullTestCase in fullTestCases)
            {
                TestStepManager.UpdateGenericSharedSteps(currentFullTestCase.TestSteps);
                currentFullTestCase.TestSteps = this.InitializeTestStepsForExport(currentFullTestCase.TestSteps);
            }

            HtmlTestCaseExportTemplate htmlTestCaseExportTemplate = new HtmlTestCaseExportTemplate();

            htmlTestCaseExportTemplate.Session = new Dictionary <string, object>();
            htmlTestCaseExportTemplate.Session.Add("FullTestCases", fullTestCases);
            htmlTestCaseExportTemplate.Initialize();
            string       currentSvcFileContent = htmlTestCaseExportTemplate.TransformText();
            StreamWriter writer = new StreamWriter(fileName, false, System.Text.Encoding.UTF8);

            using (writer)
            {
                writer.WriteLine(currentSvcFileContent);
            }
        }
        /// <summary>
        /// Migrates the test cases from source to destination.
        /// </summary>
        public void MigrateTestCasesFromSourceToDestinationInternal()
        {
            if (!string.IsNullOrEmpty(this.MigrationTestCasesRetryJsonPath) && File.Exists(this.MigrationTestCasesRetryJsonPath))
            {
                this.testCasesMigrationLogManager = new MigrationLogManager(this.MigrationTestCasesRetryJsonPath);
                this.testCasesMigrationLogManager.LoadCollectionFromExistingFile();
                this.testCasesMapping = this.testCasesMigrationLogManager.GetProssedItemsMappings();
            }
            else
            {
                this.testCasesMigrationLogManager = new MigrationLogManager("testCases", this.DefaultJsonFolder);
            }

            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);

            TestCaseManager.AddTestCasesWithoutSuites(this.sourceTeamProject, this.sourcePreferences.TestPlan, sourceTestCases);
            foreach (TestCase currentSourceTestCase in sourceTestCases)
            {
                if (this.executionCancellationToken.IsCancellationRequested)
                {
                    break;
                }

                // If it's already processed skip it
                if (this.testCasesMigrationLogManager.MigrationEntries.Count(e => e.SourceId.Equals(currentSourceTestCase.ITestCase.Id) && e.IsProcessed.Equals(true)) > 0)
                {
                    continue;
                }
                string infoMessage = String.Empty;
                try
                {
                    infoMessage = String.Format("Start Migrating Test Case with Source Id= {0}", currentSourceTestCase.Id);
                    log.Info(infoMessage);
                    this.ProgressConcurrentQueue.Enqueue(infoMessage);

                    //Don't migrate the test case if its suite is in the exclusion list
                    if (currentSourceTestCase.ITestSuiteBase != null && this.ObservableSuitesToBeSkipped.Count(t => t != null && t.NewText != null && t.NewText.Equals(currentSourceTestCase.ITestSuiteBase.Title)) > 0)
                    {
                        continue;
                    }
                    List <TestStep> currentSourceTestCaseTestSteps = TestStepManager.GetTestStepsFromTestActions(this.sourceTeamProject, currentSourceTestCase.ITestCase.Actions);
                    bool            shouldCreateTestCase           = true;
                    foreach (TestStep currentTestStep in currentSourceTestCaseTestSteps)
                    {
                        if (currentTestStep.IsShared)
                        {
                            //If the test step is shared we change the current shared step id with the newly created shared step in the destination team project
                            if (this.sharedStepsMapping.ContainsKey(currentTestStep.SharedStepId))
                            {
                                currentTestStep.SharedStepId = this.sharedStepsMapping[currentTestStep.SharedStepId];
                            }
                            else
                            {
                                // Don't save if the required shared steps are missing
                                shouldCreateTestCase = false;
                            }
                        }
                    }
                    if (shouldCreateTestCase)
                    {
                        TestCase newTestCase = currentSourceTestCase.Save(this.destinationTeamProject, this.destinationPreferences.TestPlan, true, null, currentSourceTestCaseTestSteps, false, isMigration: true);
                        this.testCasesMapping.Add(currentSourceTestCase.ITestCase.Id, newTestCase.ITestCase.Id);
                        this.testCasesMigrationLogManager.Log(currentSourceTestCase.ITestCase.Id, newTestCase.ITestCase.Id, true);
                        infoMessage = String.Format("Test Case Migrated SUCCESSFULLY: Source Id= {0}, Destination Id= {1}", currentSourceTestCase.ITestCase.Id, newTestCase.ITestCase.Id);
                        log.Info(infoMessage);
                        this.ProgressConcurrentQueue.Enqueue(infoMessage);
                    }
                }
                catch (Exception ex)
                {
                    if (currentSourceTestCase != null)
                    {
                        this.testCasesMigrationLogManager.Log(currentSourceTestCase.ITestCase.Id, -1, false, ex.Message);
                        log.Error(ex);
                        this.ProgressConcurrentQueue.Enqueue(ex.Message);
                    }
                }
                finally
                {
                    this.testCasesMigrationLogManager.Save();
                    this.MigrationTestCasesRetryJsonPath = this.testCasesMigrationLogManager.FullResultFilePath;
                }
            }
        }
        /// <summary>
        /// Initializes the test case test steps from attribute test case actions.
        /// </summary>
        private void InitializeTestCaseTestStepsFromITestCaseActions()
        {
            List <TestStep> testSteps = TestStepManager.GetTestStepsFromTestActions(TestCaseManagerCore.ExecutionContext.TestManagementTeamProject, this.TestCase.ITestCase.Actions);

            this.AddTestStepsToObservableCollection(testSteps);
        }