public async Task<IHttpActionResult> PutType(int id, TestCaseManager.Models.Type type)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != type.TypeId)
            {
                return BadRequest();
            }

            db.Entry(type).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TypeExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
        public async Task<IHttpActionResult> PostType(TestCaseManager.Models.Type type)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Types.Add(type);
            await db.SaveChangesAsync();

            return CreatedAtRoute("DefaultApi", new { id = type.TypeId }, type);
        }
Exemple #3
0
        public void TestLoadParameters()
        {
            IParameters parameters = ParameterFactory.CreateParameters();
            string      testCase   = TestCaseManager.GetTestCasePath(GetType(), "Parameters");
            XmlDocument doc        = new XmlDocument();

            doc.Load(testCase);

            parameters.Load(doc.DocumentElement);

            IParameters parameters2 = GetParameters();

            Assert.AreEqual(parameters.ToString(), parameters2.ToString());
        }
        public void TestKLineDataStore_SaveLoad()
        {
            IKLineData klineData = MockDataLoader.GetKLineData("m1005", 20100107, 20100120, KLinePeriod.KLinePeriod_1Minute);

            String path = TestCaseManager.GetTestCasePath(GetType(), "output_20100107_20100120");
            KLineDataStore_File_Single store = new KLineDataStore_File_Single(path);

            store.Save(klineData);

            KLineDataStore_File_Single store2 = new KLineDataStore_File_Single(path);
            KLineData klineData2 = store.LoadAll();

            AssertUtils.AssertEqual_KLineData(klineData, klineData2);
            File.Delete(path);
        }
Exemple #5
0
        public void GetSelectedTestcases()
        {
            TestCaseManager tcm  = new TestCaseManager();
            TreeView        tree = new TreeView();
            TreeNode        node = new TreeNode();

            tree.Nodes.Add(node);

            tcm.PopulateTreeView(node);

            node.ChildNodes[0].ChildNodes[0].Checked = true;
            IList <Testcase> tests = tcm.GetSelectedTestCases(tree);

            UnitTestAssert.AreEqual(1, tests.Count);
        }
Exemple #6
0
        /// <summary>
        /// Adds the test cases subsuites.
        /// </summary>
        /// <param name="suiteTestCaseCollection">The suite test case collection.</param>
        public void AddTestCasesSubsuites(List <TestCase> suiteTestCaseCollection)
        {
            int selectedSuiteId = RegistryManager.Instance.GetSelectedSuiteId();

            if (this.ShowSubSuitesTestCases)
            {
                List <TestCase> testCasesList = new List <TestCase>();
                ITestSuiteBase  currentSuite  = TestSuiteManager.GetTestSuiteById(ExecutionContext.TestManagementTeamProject, ExecutionContext.Preferences.TestPlan, selectedSuiteId);
                if (currentSuite is IStaticTestSuite)
                {
                    testCasesList = TestCaseManager.GetAllTestCasesFromSuiteCollection(ExecutionContext.Preferences.TestPlan, (currentSuite as IStaticTestSuite).SubSuites);
                    testCasesList.ForEach(x => suiteTestCaseCollection.Add(x));
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// Adds the test cases automatic observable collection.
        /// </summary>
        /// <param name="list">The list.</param>
        public void AddTestCasesToObservableCollection(Suite suiteToPasteIn, int?parentSuiteId)
        {
            suiteToPasteIn.IsSelected = true;
            if (parentSuiteId != null)
            {
                Suite parentSuite = this.GetSuiteById(this.Suites, parentSuiteId);
                parentSuite.IsSelected = false;
            }

            List <TestCase> testCasesList = TestCaseManager.GetAllTestCaseFromSuite(ExecutionContext.Preferences.TestPlan, suiteToPasteIn.Id);

            this.ObservableTestCases.Clear();
            testCasesList.ForEach(t => this.ObservableTestCases.Add(t));
            this.InitializeInitialTestCaseCollection(this.ObservableTestCases);
        }
Exemple #8
0
        public void TestTradingDaySaveLoad()
        {
            string     path        = TestCaseManager.GetTestCasePath(GetType(), "output_TradingDay");
            List <int> tradingDays = MockDataLoader.GetAllTradingDays();

            TradingDayStore_File store = new TradingDayStore_File(path);

            store.Save(tradingDays);

            TradingDayStore_File newstore     = new TradingDayStore_File(path);
            List <int>           tradingDays2 = newstore.Load();

            AssertUtils.AssertEqual_List(tradingDays, tradingDays2);
            File.Delete(path);
        }
        public void TestKLineDataStore_LoadByDate()
        {
            string path = TestCaseManager.GetTestCasePath(GetType(), "output_20100107_20100120");

            IKLineData data = MockDataLoader.GetKLineData("m1005", 20100107, 20100120, KLinePeriod.KLinePeriod_1Minute);
            KLineDataStore_File_Single store = new KLineDataStore_File_Single(path);

            store.Save(data);

            KLineDataStore_File_Single store2 = new KLineDataStore_File_Single(path);
            IKLineData data2 = store2.Load(20100107, 20120111);

            AssertUtils.PrintKLineData(data2);
            File.Delete(path);
        }
        public void TestAccountFeeStore()
        {
            String outputPath     = TestCaseManager.GetTestCasePath(GetType(), "accountfee");
            string instrumentPath = TestCaseManager.GetTestCasePath(GetType(), "Store_AccountFee");

            AccountFeeInfoStore_File store = new AccountFeeInfoStore_File(instrumentPath);
            List <AccountFeeInfo>    codes = store.LoadAllAccountFee();

            AccountFeeInfoStore_File store2 = new AccountFeeInfoStore_File(outputPath);

            store2.SaveAccountFee(codes);
            List <AccountFeeInfo> codes2 = store2.LoadAllAccountFee();

            AssertUtils.AssertEqual_List_ToString(codes, codes2);
            File.Delete(outputPath);
        }
Exemple #11
0
        public void TestLoadConnectionInfo()
        {
            string connectInfoStr = TestCaseManager.LoadTestCaseFile(GetType(), "ConnectionInfo");//,Encoding.GetEncoding("GBK"));
            //Console.WriteLine(connectInfoStr);
            //ConnectionInfo c = new ConnectionInfo();
            //c.AddValue("12", "22");
            //c.AddValue("22", "33");
            //Console.WriteLine(c.ToJsJson());

            ConnectionInfo connectInfo = ConnectionInfo.LoadFrom(connectInfoStr);

            //Console.WriteLine(connectInfo.ToJsJson());
            Assert.AreEqual("SIMNOW1", connectInfo.Id);
            Assert.AreEqual("SimuNow模拟CTP1", connectInfo.Name);
            Assert.AreEqual("SimuNow模拟CTP,一号线", connectInfo.Description);
        }
Exemple #12
0
        public void TestInstrumentsSaveLoad()
        {
            string          path        = TestCaseManager.GetTestCasePath(GetType(), "CsvUtils_Instruments");
            List <CodeInfo> instruments = CsvUtils_Code.Load(path);

            string outputPath = TestCaseManager.GetTestCasePath(GetType(), "Instruments_Output.csv");

            CsvUtils_Code.Save(outputPath, instruments);

            List <CodeInfo> newInstruments = CsvUtils_Code.Load(outputPath);

            AssertUtils.AssertEqual_List(instruments, newInstruments);
            //TestCaseManager.SaveTestCaseFile(GetType(),)
            //List<InstrumentInfo> instruments = MockDataLoader.GetAllInstruments();
            //AssertUtils.AssertEqual_List("CsvUtils_Instruments", GetType(), instruments);
        }
Exemple #13
0
        public void TestInstrumentsSaveLoad()
        {
            String outputPath     = TestCaseManager.GetTestCasePath(GetType(), "codes");
            string instrumentPath = TestCaseManager.GetTestCasePath(GetType(), "Store_Code");

            InstrumentStore_File store = new InstrumentStore_File(instrumentPath);
            List <CodeInfo>      codes = store.Load();

            InstrumentStore_File store2 = new InstrumentStore_File(outputPath);

            store2.Save(codes);
            List <CodeInfo> codes2 = store2.Load();

            AssertUtils.AssertEqual_List_ToString(codes, codes2);
            File.Delete(outputPath);
        }
Exemple #14
0
        public void TestKLineDataSaveLoad()
        {
            String filename = "KLineData_Output.csv";

            string[]   lines     = TestCaseManager.LoadTestCaseFile(GetType(), "CsvUtils_KLineData").Split('\r');
            IKLineData klineData = CsvUtils_KLineData.LoadByLines(lines);

            string testCasePath = TestCaseManager.GetTestCasePath(GetType(), filename);

            CsvUtils_KLineData.Save(testCasePath, klineData);
            IKLineData newklineData = CsvUtils_KLineData.Load(testCasePath);

            File.Delete(testCasePath);

            AssertUtils.AssertEqual_KLineData(klineData, newklineData);
        }
        private static CacheUtils_TradingDay GetTradingDayCache()
        {
            if (tradingDayCache != null)
            {
                return(tradingDayCache);
            }

            String[]   lines     = TestCaseManager.LoadTestCaseFile(typeof(TestTradingDayCache), "OpenDate_Cache").Split('\r');
            List <int> openDates = new List <int>(lines.Length);

            for (int i = 0; i < lines.Length; i++)
            {
                openDates.Add(int.Parse(lines[i].Trim()));
            }
            tradingDayCache = new CacheUtils_TradingDay(openDates);
            return(tradingDayCache);
        }
Exemple #16
0
        /// <summary>
        /// Filters the suites without suite.
        /// </summary>
        public void FilterSuitesWithoutSuite()
        {
            if (ExecutionContext.Preferences.TestPlan.RootSuite.SubSuites.FirstOrDefault() == null)
            {
                return;
            }
            List <TestCase> testCasesWithSuite = TestCaseManager.GetAllTestCasesFromSuiteCollection(ExecutionContext.Preferences.TestPlan, ExecutionContext.Preferences.TestPlan.RootSuite.SubSuites);
            List <TestCase> filteredTestCases  = new List <TestCase>();

            foreach (TestCase currentTestCase in this.ObservableTestCases)
            {
                if (!testCasesWithSuite.Contains(currentTestCase))
                {
                    filteredTestCases.Add(currentTestCase);
                }
            }

            this.InitialTestCaseCollection.Clear();
            filteredTestCases.ForEach(x => this.InitialTestCaseCollection.Add(x));
        }
Exemple #17
0
        public void Filter_EqualWithoutMatch_EmptyContent()
        {
            var manager = new TestCaseManager();

            //Setup content;
            manager.Content.Columns.Add(new DataColumn("columnName"));
            manager.Variables.Add("columnName");
            var nonMatchingRow1 = manager.Content.NewRow();

            nonMatchingRow1[0] = "abc";
            var nonMatchingRow2 = manager.Content.NewRow();

            nonMatchingRow2[0] = "xyz";
            manager.Content.Rows.Add(nonMatchingRow1);
            manager.Content.Rows.Add(nonMatchingRow2);
            manager.Content.AcceptChanges();

            //Setup filter
            manager.Filter("columnName", Operator.Equal, false, "matching");

            Assert.That(manager.Content.Rows, Has.Count.EqualTo(0));
        }
Exemple #18
0
        public void Filter_LikeEnd_CorrectNewContent()
        {
            var manager = new TestCaseManager();

            //Setup content;
            manager.Content.Columns.Add(new DataColumn("columnName"));
            manager.Variables.Add("columnName");
            var matchingRow = manager.Content.NewRow();

            matchingRow[0] = "matching";
            var nonMatchingRow = manager.Content.NewRow();

            nonMatchingRow[0] = "xyz";
            manager.Content.Rows.Add(matchingRow);
            manager.Content.Rows.Add(nonMatchingRow);
            manager.Content.AcceptChanges();

            //Setup filter
            manager.Filter("columnName", Operator.Like, false, "%ing");

            Assert.That(manager.Content.Rows, Has.Count.EqualTo(1));
            Assert.That(manager.Content.Rows[0][0], Is.EqualTo("matching"));
        }
Exemple #19
0
        public void TestKLineDataStore_Append()
        {
            IKLineData klineData  = MockDataLoader.GetKLineData("m1005", 20100107, 20100114, KLinePeriod.KLinePeriod_1Minute);
            IKLineData klineData2 = MockDataLoader.GetKLineData("m1005", 20100115, 20100120, KLinePeriod.KLinePeriod_1Minute);

            List <IKLineData> ks = new List <IKLineData>();

            ks.Add(klineData);
            ks.Add(klineData2);
            IKLineData klineData_Merge = KLineData.Merge(ks);

            String path = TestCaseManager.GetTestCasePath(GetType(), "output_append");
            KLineDataStore_File_Single store = new KLineDataStore_File_Single(path);

            store.Save(klineData);
            store.Append(klineData2);

            IKLineData klineData_Merge2 = store.LoadAll();

            AssertUtils.AssertEqual_KLineData(klineData_Merge, klineData_Merge2);

            File.Delete(path);
        }
Exemple #20
0
        /// <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;
        }
Exemple #21
0
        private KLineData GetKLineData_1Min()
        {
            string path = TestCaseManager.GetTestCasePath(GetType(), "KLineData_M01_1Minute");

            return((KLineData)CsvUtils_KLineData.Load(path));
        }
Exemple #22
0
        public void TestClassesGetLoadsTests()
        {
            TestCaseManager tcm = new TestCaseManager();

            UnitTestAssert.AreEqual(1, tcm.TestClasses.Length);
        }
        /// <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;
                }
            }
        }
        /// <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;
                }
            }
        }
Exemple #25
0
        public void TestMethodsGetLoadsMethods()
        {
            TestCaseManager tcm = new TestCaseManager();

            UnitTestAssert.AreEqual(2, tcm.TestMethods.Length);
        }