示例#1
0
        public void TestALMOctaneUpload()
        {
            Console.WriteLine("File : " + filepath);

            var testcase = parser.Parse(filepath, 1);

            Console.WriteLine(testcase.Description);
            File.WriteAllText("testcase.txt", testcase.Description);

            ALMConvertor        export     = new ALMConvertor();
            var                 configFile = File.ReadAllLines("Config\\config.txt");
            ALMOctaneConnection con        = new ALMOctaneConnection(
                configFile[0], configFile[1], configFile[2], configFile[3], configFile[4]);

            ALMOctaneAPI api = new ALMOctaneAPI(con)
            {
                UserId = configFile[5]
            };
            var str    = export.ConvertToString(testcase);
            var testid = api.CreateTest(testcase.Title, export.ConvertDescriptionToString(testcase));

            api.UpdateTest(testid, str);
        }
示例#2
0
        private static void MainProgram()
        {
            Stopwatch watch = new Stopwatch();

            var ap         = new Application();
            var folderpath = ConfigurationManager.AppSettings["folderpath"];
            var files      = Directory.GetFiles(folderpath, "*");

            List <TestCase> testcases        = new List <TestCase>();
            int             iCurrentTestCase = 1;

            using (WordParser parser = new WordParser(ap))
            {
                foreach (var f in files)
                {
                    try
                    {
                        if (!f.Contains(".docx") || !f.Contains(".doc"))
                        {
                            throw new FileLoadException($"File '{f}' is not a doc or docx");
                        }

                        watch.Start();
                        Globals.Log("Loading tescase " + iCurrentTestCase + " " + f);

                        testcases.Add(parser.Parse(f, iCurrentTestCase));
                        watch.Stop();
                        Globals.Log("Time taken to parse : " + watch.ElapsedMilliseconds);
                        watch.Reset();

                        //test.PrintStats();
                        //test.PrintSequences();
                        //test.PrintHeights();
                    }
                    catch (FileLoadException fex)
                    {
                        Globals.Log("Error loading " + f);
                        Globals.Error(fex.Message);
                        Globals.Error(fex.StackTrace);
                    }
                    catch (WordParserException wex)
                    {
                        Globals.Log("Error parsing " + f);
                        Globals.Error(wex.Message);
                        Globals.Error(wex.StackTrace);
                        parser.CloseCurrentDoc();
                    }
                    catch (Exception ex)
                    {
                        Globals.Error(ex.Message);
                        Globals.Error(ex.StackTrace);
                        Console.WriteLine($"Unknown exception occurred on {f}. Press enter to close");
                        Console.Read();
                        break;
                    }
                    finally
                    {
                        watch.Stop();
                    }
                    iCurrentTestCase++;
                }
            }

            ALMConvertor        export = new ALMConvertor();
            ALMOctaneConnection con    = new ALMOctaneConnection(
                ConfigurationManager.AppSettings["webAppUrl"],
                ConfigurationManager.AppSettings["userName"],
                ConfigurationManager.AppSettings["password"],
                ConfigurationManager.AppSettings["sharedSpaceId"],
                ConfigurationManager.AppSettings["workspaceId"]);

            ALMOctaneAPI api = new ALMOctaneAPI(con)
            {
                UserId = ConfigurationManager.AppSettings["userId"]
            };



            foreach (var tcs in testcases)
            {
                var str    = export.ConvertToString(tcs);
                var testid = api.CreateTest(tcs.Title, tcs.Description);
                api.UpdateTest(testid, str);
                Globals.Log(str, true);
            }
        }