コード例 #1
0
ファイル: ResultsParser.cs プロジェクト: RajaBellebon/helper
        //RB: This function gets the sections name and ID for a specific suite
        public static Dictionary <string, string> GetSections(object project, Dictionary <string, string> dictNameSuite, string suiteName)
        {
            RArray = TestExporter.Get1("get_sections/" + AppSettings[project.ToString()] + "&suite_id=" + dictNameSuite[suiteName]);
            Dictionary <string, string> dictNameSections = new Dictionary <string, string>();

            foreach (var item in RArray.Children())
            {
                var obj = JObject.Parse(item.ToString());
                dictNameSections.Add((string)obj.SelectToken("name"), (string)obj.SelectToken("id"));
            }
            return(dictNameSections);
        }
コード例 #2
0
ファイル: ResultsParser.cs プロジェクト: RajaBellebon/helper
        //RB: This function allows to add cases for a dedicated project, suite, section
        public static void AddCases(Dictionary <string, Tuple <int, string> > dict, string path, string testType, object project, object suiteName, object sectionName, string sectionId)
        {
            var           dictNameSuite    = GetSuites(project);
            var           dictNameSections = GetSections(project, dictNameSuite, suiteName.ToString());
            List <string> TestRailLists    = new List <string>();

            RArray = TestExporter.Get1("get_cases/" +
                                       AppSettings[project.ToString()] + "&suite_id=" +
                                       dictNameSuite[suiteName.ToString()] + "&section_id=" +
                                       dictNameSections[sectionName.ToString()]);
            if (RArray.Count == 0)
            {
                foreach (string key in dict.Keys)
                {
                    JObject  r = TestExporter.CreateTestName("add_case/" + sectionId, key);
                    JToken   s = r.First;
                    string[] t = (s.ToString()).Split(':');
                }
            }
            else
            {
                if (RArray.Count() != dict.Count())
                {
                    //In this step, add any tests not present in TestRail in case of 429 exception, you can keep adding tests
                    foreach (var item in RArray.Children())
                    {
                        var obj   = JObject.Parse(item.ToString());
                        var title = (string)obj.SelectToken("title");
                        TestRailLists.Add(title.Trim());
                    }
                    foreach (var elem in dict.Keys.ToList())
                    {
                        if (!TestRailLists.Contains(elem.Trim()))
                        {
                            JObject r = TestExporter.CreateTestName("add_case/" + sectionId, elem);
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Test Cases have been already added");
                }
            }
        }
コード例 #3
0
ファイル: ResultsParser.cs プロジェクト: RajaBellebon/helper
        //RB: This function gets the suites name and ID for a specific project
        public static Dictionary <string, string> GetSuites(object project)
        {
            // Load  AppSettings from embedded resource (saves distributing the config)
            using (var stream = typeof(RunandResults).Assembly.GetManifestResourceStream("ResultsParser.appSettings.config"))
            {
                var doc = XDocument.Load(stream);
                foreach (var a in doc.Element("appSettings").Elements("add"))
                {
                    AppSettings[a.Attribute("key").Value] = a.Attribute("value").Value;
                }
            }
            RArray = TestExporter.Get1("get_suites/" + AppSettings[project.ToString()]);
            Dictionary <string, string> dictNameSuite = new Dictionary <string, string>();

            foreach (var item in RArray.Children())
            {
                var obj = JObject.Parse(item.ToString());
                dictNameSuite.Add((string)obj.SelectToken("name"), (string)obj.SelectToken("id"));
            }
            return(dictNameSuite);
        }