Exemplo n.º 1
0
 public static Ranking AddOrUpdateRanking(Ranking ranking)
 {
     using (ES1AutomationEntities context = new ES1AutomationEntities())
     {
         Ranking existingRanking = context.Rankings.Where(r=>r.Name.ToLower() == ranking.Name.ToLower()).FirstOrDefault();
         if (existingRanking != null)
         {
             existingRanking.Description = ranking.Description;
             context.Entry(existingRanking).State = System.Data.Entity.EntityState.Modified;
             context.SaveChanges();
             return existingRanking;
         }
         else
         {
             context.Rankings.Add(ranking);
             context.SaveChanges();
             return ranking;
         }
     }
 }
Exemplo n.º 2
0
        public void SyncAllTestCase()
        {
            try
            {

                ATFEnvironment.Log.logger.Info("RQM Login");

                RQMServer.UserAuthentication(Username, Password);

                ATFEnvironment.Log.logger.Info("RQM Sync Test Cases Start");

                // disable all test cases of this provider
                TestCase.DisableTestCases(this.Provider.ProviderId);

                Product product = GetProductOfTestCaseProvider();//Product.GetProductByName(RQMProjectProductMapping["SourceOne+%28Quality+Management%29"]);

                if (product != null)
                {
                    //update the test suite hierarchy
                    var root = TestSuite.GetRootNodeOfAllTestCases();
                    CreateOrUpdateProjectLevelSuite(root);

                    //the leaf node of test suite
                    //var testSuites = TestSuite.GetTestSuitesByProviderId(Provider.ProviderId).Where(ts => ts.SubSuites == null && ts.IsActive == true && ts.Type == (int)SuiteType.Static).ToList();
                    var testSuites = TestSuite.GetAllSubSuites(root, true).Where(
                        ts => ts.SubSuites == null &&
                            ts.IsActive == true &&
                            ts.Type == (int)SuiteType.Static &&
                            ts.ProviderId == this.Provider.ProviderId
                            ).ToList();
                    //remove all the test case children of the leaf node of test suite
                    foreach (var testSuite in testSuites)
                    {
                        testSuite.CreateBy = 0;
                        testSuite.ModityBy = 0;
                        testSuite.TestCases = string.Empty;
                    }

                    foreach (var rqmTestCase in RQMServer.GetTestCasesByProject(ProjectAlias))
                    {
                        string ranking = rqmTestCase.Categories.ContainsKey("Ranking") ? rqmTestCase.Categories["Ranking"] : null;
                        string release = rqmTestCase.Categories.ContainsKey("Release") ? rqmTestCase.Categories["Release"] : null;
                        string features = rqmTestCase.Categories.ContainsKey("Features") ? rqmTestCase.Categories["Features"] : string.Empty;
                        string module = rqmTestCase.Categories.ContainsKey("Module") ? rqmTestCase.Categories["Module"] : null;
                        string platform = rqmTestCase.Categories.ContainsKey("Platform") ? rqmTestCase.Categories["Platform"] : null;
                        string runtime = rqmTestCase.Categories.ContainsKey("RunTime") ? rqmTestCase.Categories["RunTime"] : null;
                        if (string.IsNullOrEmpty(runtime))
                        {
                            //This is to fix the issue that the category of "RunTime" in SourceOne project is called "RunTIme" but in Supervisor Project, it's called "Runtime"
                            runtime = rqmTestCase.Categories.ContainsKey("Runtime") ? rqmTestCase.Categories["Runtime"] : null;
                        }
                        bool isAutomated = rqmTestCase.Categories.ContainsKey("IsAutomated") ? bool.Parse(rqmTestCase.Categories["IsAutomated"]) : false;

                        if (ranking != null)
                        {
                            Ranking rankingtemp = new Ranking
                            {
                                Name = ranking,
                                Description = ranking,

                            };
                            Ranking.AddOrUpdateRanking(rankingtemp);
                        }

                        if (release != null)
                        {
                            Release tempRelease = new Release
                            {
                                Name = release,
                                Description = release,
                                Path = string.Empty,
                                Type = (int)SyncSourceType.FromRQM,
                                ProductId = product.ProductId,
                            };

                            Release.AddOrUpdateRelease(tempRelease);
                        }

                        if (isAutomated)
                        {
                            var testCase = TestCase.CreateOrUpdateTestCase
                                (
                                    new TestCase
                                    {
                                        ProviderId = this.Provider.ProviderId,
                                        SourceId = rqmTestCase.WebId,
                                        Name = string.Format("[{0, 6}]:{1}", rqmTestCase.WebId, rqmTestCase.Title),
                                        Feature = features,
                                        Description = string.Format("WebId={0}, Release={1}, Ranking={2}, Module={3}, Feature={4}, RunTime={5}, Platform={6}, IsAutomated={7}", rqmTestCase.WebId, release, ranking, module, features, runtime, platform, isAutomated),
                                        ProductId = product.ProductId,
                                        Weight = rqmTestCase.Weight,
                                        Ranking = ranking,
                                        Release = release,
                                        IsAutomated = isAutomated,
                                        IsActive = true,
                                    }
                                );

                            // update test suite
                            // here we have a assumption that the feature names under different modules of projects should be unique.
                            foreach (var testSuite in testSuites)
                            {
                                if (rqmTestCase.Categories.Keys.Contains("Features") && rqmTestCase.Categories["Features"] == testSuite.Name)
                                {
                                    if (string.IsNullOrWhiteSpace(testSuite.TestCases))
                                    {
                                        testSuite.TestCases = testCase.TestCaseId.ToString();
                                    }
                                    else
                                    {
                                        testSuite.TestCases = testSuite.TestCases + "," + testCase.TestCaseId.ToString();
                                    }
                                }
                            }
                        }
                    }

                    TestSuite.CreateUpdateAllTestSuites(testSuites);
                }

                RQMServer.Logout();

                ATFEnvironment.Log.logger.Info("Logout RQM server");

                ATFEnvironment.Log.logger.Info("RQM Sync Test Cases Finish");
            }
            catch (Exception ex)
            {
                ATFEnvironment.Log.logger.Error("Met error while sync the test cases from RQM server.", ex);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Invoked when <see cref="ToEntity"/> operation is about to return.
        /// </summary>
        /// <param name="entity"><see cref="Ranking"/> converted from <see cref="RankingDTO"/>.</param>
partial         static void OnEntity(this RankingDTO dto, Ranking entity);
Exemplo n.º 4
0
        /// <summary>
        /// Converts this instance of <see cref="RankingDTO"/> to an instance of <see cref="Ranking"/>.
        /// </summary>
        /// <param name="dto"><see cref="RankingDTO"/> to convert.</param>
        public static Ranking ToEntity(this RankingDTO dto)
        {
            if (dto == null) return null;

            var entity = new Ranking();

            entity.RankingId = dto.RankingId;
            entity.Name = dto.Name;
            entity.Description = dto.Description;

            dto.OnEntity(entity);

            return entity;
        }