/// <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>
        /// 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);
        }
Beispiel #3
0
        /// <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;
        }