示例#1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="str"></param>
 /// <returns></returns>
 public string Evaluate(string str)
 {
     return(PropertiesReader.Evaluate(str, this.GetByKey, this.ContainsKey));
 }
示例#2
0
 public void Load(FileInfo globalConfigFile)
 {
     s_props = this;
     PropertiesReader.Read(globalConfigFile, PropertyRead);
 }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="config"></param>
        public bool PopulateLexerConfig(ILexerConfig config)
        {
            /*--------------------------------------- styles ---------------------------------------
             * The lexers determine a style number for each lexical type, such as keyword, comment or number. These settings
             * determine the visual style to be used for each style number of each lexer.
             * The value of each setting is a set of ',' separated fields, some of which have a subvalue after a ':'. The fields
             * are font, size, fore, back, italics, notitalics, bold, notbold, eolfilled, noteolfilled, underlined,
             * notunderlined, and case. The font field has a subvalue which is the name of the font, the fore and back
             * have colour subvalues, the size field has a numeric size subvalue, the case field has a subvalue of 'm',
             * 'u', or 'l' for mixed, upper or lower case, and the bold, italics and eolfilled fields have no subvalue.
             * The value "fore:#FF0000,font:Courier,size:14" represents 14 point, red Courier text.
             * A global style can be set up using style.*.stylenumber. Any style options set in the global style will be
             * inherited by each lexer style unless overridden.
             * ----------------------------------------------------------------------------------------*/
            string      key, s, lexer = config.LexerName.ToLower();
            ILexerStyle style;
            bool        dataIsFound = false;
            Dictionary <string, string> dict;

            for (int i = 0; i < 128; i++)
            {
                if (config.Styles.ContainsKey(i))
                {
                    style = config.Styles[i];
                }
                else
                {
                    style = new LexerStyle(i);
                }

                dataIsFound = true;
                foreach (string lang in new string[] { "*", lexer })
                {
                    key = string.Format("style.{0}.{1}", lang, i);
                    if (properties.ContainsKey(key))
                    {
                        dataIsFound = true;

                        s    = this.Evaluate(properties[key]);
                        dict = PropertiesReader.GetKeyValuePairs(s);
                        foreach (string styleKey in dict.Keys)
                        {
                            s = dict[styleKey];
                            switch (styleKey)
                            {
                            case "font":
                                style.FontName = s;
                                break;

                            case "size":
                                style.FontSize = Convert.ToInt32(s);
                                break;

                            case "fore":
                                style.ForeColor = ColorTranslator.FromHtml(s);
                                break;

                            case "back":
                                style.BackColor = ColorTranslator.FromHtml(s);
                                break;

                            case "italics":
                                style.Italics = true;
                                break;

                            case "notitalics":
                                style.Italics = false;
                                break;

                            case "bold":
                                style.Bold = true;
                                break;

                            case "notbold":
                                style.Bold = false;
                                break;

                            case "eolfilled":
                                style.EOLFilled = true;
                                break;

                            case "noteolfilled":
                                style.EOLFilled = false;
                                break;

                            case "underlined":
                                style.Underline = true;
                                break;

                            case "notunderlined":
                                style.Underline = false;
                                break;

                            case "case":
                                style.CaseVisibility = ((s == "m") ? CaseVisible.Mixed : ((s == "u") ? CaseVisible.Upper : CaseVisible.Lower));
                                break;
                            }
                        }
                    }
                }

                if (dataIsFound)
                {
                    config.Styles[i] = style;
                }
            }
            return(true);
        }
示例#4
0
        public void CreateWordDocSuite(string userName, int planID, int suiteID, bool claims)
        {
            #region Boring stuff
            // Test Case Pull
            #region Pull Test Case from TFS
            PropertiesReader config = new PropertiesReader("config.txt");

            Properties props = new Properties();
            props.PersonalAccessToken = config.get("personalaccesstoken");
            props.TestPlanId          = Convert.ToInt32(config.get("testplanid"));
            props.TestSuiteId         = Convert.ToInt32(config.get("testsuiteid"));
            props.Project             = config.get("project");
            props.Uri                = config.get("server");
            props.SaveLocation       = config.get("saveLocation");
            props.FileName           = StringTools.addExtension(config.get("fileName"), "xlsx");;
            props.ExecutionSheetName = config.get("executionsheetname");
            props.ScriptSheetName    = config.get("scriptsheetname");
            props.TestPlanId         = Convert.ToInt32(config.get("testplanid"));
            props.TestSuiteId        = Convert.ToInt32(config.get("testsuiteid"));

            #endregion

            Color royalBlue = Color.FromName("RoyalBlue");
            Color white     = Color.FromName("White");

            string location = "C:\\Users\\" + userName + "\\Desktop\\EvidenceSuite " + suiteID;

            Logger logger = new Logger(location + "\\");

            props.Logger = logger;

            RequirementsTraceabilityJobs requirementsTraceabilityJob = new RequirementsTraceabilityJobs(props);
            System.IO.Directory.CreateDirectory(location);

            List <TestCase> cases = new List <TestCase>();
            cases = requirementsTraceabilityJob.GetTestCaseGivenPlanSuite(planID, suiteID);

            foreach (TestCase testCase in cases)
            {
                string fileName  = "";
                int    currentID = testCase.TestCaseId;
                string testName  = testCase.TestCaseId.ToString() + "_" + testCase.TestCaseName.Replace("<", "Less Than").Replace(">", "Greater Than").Replace(" ", "_").Replace(")", "_").Replace("(", "_").Replace("/", "_").Replace("\\", "_").Replace(" - ", "_").Replace("\"", "_").Replace("'", "_").Replace("▪", "_").Replace("*", "_");
                if (testName.Length > 150)
                {
                    fileName = testName.Substring(0, 150);
                }
                else
                {
                    fileName = testName;
                }

                DocX  doc          = DocX.Create(testName);
                var   columnWidths = new float[] { 225f, 225f, 400f };
                Table testSummary  = doc.AddTable(2, 3);
                //Test Objective table

                try
                {
                    string TestDescription = testCase.TestDescription.Replace("<br>&gt;", "\n >").Replace("&nbsp;", "").Replace("&nbsp", "").Replace("&gt", ">").Replace("&gt;", ">").Replace("<br> &nbsp ", "\n").Replace("condiditons", "conditions").Replace("&lt;", "<").Replace("<br>", "\n").Replace(";", "").Replace("	", " ");
                    doc.InsertParagraph("Test Objective").FontSize(16);
                    testSummary.Rows[0].Cells[0].Paragraphs.First().Append("#").Color(white);
                    testSummary.Rows[0].Cells[1].Paragraphs.First().Append("Title").Color(white);
                    testSummary.Rows[0].Cells[2].Paragraphs.First().Append("Test Objective").Color(white);
                    testSummary.Rows[0].Cells[0].FillColor = royalBlue;
                    testSummary.Rows[0].Cells[1].FillColor = royalBlue;
                    testSummary.Rows[0].Cells[2].FillColor = royalBlue;

                    testSummary.Rows[1].Cells[0].Paragraphs.First().Append(testCase.TestCaseId.ToString());
                    testSummary.Rows[1].Cells[1].Paragraphs.First().Append(TestDescription);
                    testSummary.Rows[1].Cells[2].Paragraphs.First().Append(testCase.TestObjective);
                }catch (NullReferenceException e)
                {
                    doc.InsertParagraph("Test Objective").FontSize(16);
                    testSummary.Rows[0].Cells[0].Paragraphs.First().Append("#").Color(white);
                    testSummary.Rows[0].Cells[1].Paragraphs.First().Append("Title").Color(white);
                    testSummary.Rows[0].Cells[2].Paragraphs.First().Append("Test Objective").Color(white);
                    testSummary.Rows[0].Cells[0].FillColor = royalBlue;
                    testSummary.Rows[0].Cells[1].FillColor = royalBlue;
                    testSummary.Rows[0].Cells[2].FillColor = royalBlue;

                    testSummary.Rows[1].Cells[0].Paragraphs.First().Append(testCase.TestCaseId.ToString());
                    testSummary.Rows[1].Cells[1].Paragraphs.First().Append("Test description is empty");
                    testSummary.Rows[1].Cells[2].Paragraphs.First().Append(testCase.TestObjective);
                }

                testSummary.SetWidths(columnWidths);
                doc.InsertTable(testSummary);


                doc.InsertParagraph("Steps to follow").FontSize(16);
                Table testActionResult;
                if (!claims)
                {
                    testActionResult = doc.AddTable(testCase.TestSteps.Count + 1, 3);
                    //Console.WriteLine("Create three rows");
                }
                else
                {
                    testActionResult = doc.AddTable(testCase.TestSteps.Count + 1, 4);
                    //Console.WriteLine("Create four rows");
                }
                testActionResult.SetWidths(columnWidths);
                testActionResult.Rows[0].Cells[0].Paragraphs.First().Append("Steps").Color(white);
                testActionResult.Rows[0].Cells[1].Paragraphs.First().Append("Action").Color(white);
                testActionResult.Rows[0].Cells[2].Paragraphs.First().Append("Expected Result").Color(white);
                testActionResult.Rows[0].Cells[0].FillColor = royalBlue;
                testActionResult.Rows[0].Cells[1].FillColor = royalBlue;
                testActionResult.Rows[0].Cells[2].FillColor = royalBlue;

                if (claims)
                {
                    testActionResult.Rows[0].Cells[3].Paragraphs.First().Append("Actual Result").Color(white);
                    testActionResult.Rows[0].Cells[3].FillColor = royalBlue;
                }
                int i = 0;

                if (testCase.TestSteps.Count <= 0)
                {
                    testSummary.Rows[1].Cells[0].Paragraphs.First().Append("Test ");
                    testSummary.Rows[1].Cells[1].Paragraphs.First().Append("Test ");
                    testSummary.Rows[1].Cells[2].Paragraphs.First().Append("Test ");
                    //if (claims)
                    //{
                    //    testSummary.Rows[1].Cells[3].Paragraphs.First().Append("Test ");
                    //}
                }
                else
                {
                    foreach (TestStep testStep in testCase.TestSteps)
                    {
                        i++;
                        string action   = Utility.RemoveTags(testStep.Action).Replace("<br>&gt;", "\n >").Replace("&nbsp;", "").Replace("&nbsp", "").Replace("&gt", ">").Replace("&gt;", ">").Replace("<br> &nbsp ", "\n").Replace("condiditons", "conditions").Replace("&lt;", "<").Replace("<br>", "\n").Replace(";", "").Replace("	", " ");
                        string expected = Utility.RemoveTags(testStep.Expected).Replace("<br>&gt;", "\n >").Replace("&nbsp;", "").Replace("&nbsp", "").Replace("&gt", ">").Replace("&gt;", ">").Replace("<br> &nbsp ", "\n").Replace("condiditons", "conditions").Replace("&lt;", "<").Replace("<br>", "\n").Replace(";", "").Replace("	", " ");

                        //Console.WriteLine("Test Step " + i);
                        testActionResult.Rows[i].Cells[0].Paragraphs[0].Append(testStep.StepNumber.ToString());
                        testActionResult.Rows[i].Cells[1].Paragraphs.First().Append(action);
                        testActionResult.Rows[i].Cells[2].Paragraphs.First().Append(expected);
                        if (claims)
                        {
                            testActionResult.Rows[i].Cells[3].Paragraphs.First();
                        }
                    }
                }

                doc.InsertTable(testActionResult);
                try
                {
                    doc.SaveAs(location + "//" + fileName + ".docx");
                }catch (Exception e)
                {
                    Console.WriteLine("Unable to make test case " + testCase.TestCaseId + " due to invalid name");
                }
            }
            ;
            #endregion
        }
示例#5
0
        public DocX CreateWordDoc(int testCaseId, int suiteID)
        {
            #region Pull Test Case from TFS
            PropertiesReader config = new PropertiesReader("config.txt");

            Properties props = new Properties();
            props.PersonalAccessToken = config.get("personalaccesstoken");
            props.TestPlanId          = Convert.ToInt32(config.get("testplanid"));
            props.TestSuiteId         = Convert.ToInt32(config.get("testsuiteid"));
            props.Project             = config.get("project");
            props.Uri                = config.get("server");
            props.SaveLocation       = config.get("saveLocation");
            props.FileName           = StringTools.addExtension(config.get("fileName"), "xlsx");;
            props.ExecutionSheetName = config.get("executionsheetname");
            props.ScriptSheetName    = config.get("scriptsheetname");
            props.TestPlanId         = Convert.ToInt32(config.get("testplanid"));
            props.TestSuiteId        = Convert.ToInt32(config.get("testsuiteid"));

            Logger logger = new Logger(props.SaveLocation);

            props.Logger = logger;

            TestCase thisTestCase = new TestCase();
            RequirementsTraceabilityJobs requirementsTraceabilityJob = new RequirementsTraceabilityJobs(props);
            thisTestCase = requirementsTraceabilityJob.GetSingleTestCase(testCaseId, suiteID);

            Color  royalBlue    = Color.FromName("RoyalBlue");
            Color  white        = Color.FromName("White");
            string testName     = thisTestCase.TestCaseId.ToString() + "_" + thisTestCase.TestCaseName.Replace(" ", "_") + ".docx";
            DocX   doc          = DocX.Create(testName);
            var    columnWidths = new float[] { 225f, 225f, 225f };
            Table  testSummary  = doc.AddTable(2, 3);
            //Test Objective table
            doc.InsertParagraph("Test Objective").FontSize(16);
            testSummary.Rows[0].Cells[0].Paragraphs.First().Append("#").Color(white);
            testSummary.Rows[0].Cells[1].Paragraphs.First().Append("Title").Color(white);
            testSummary.Rows[0].Cells[2].Paragraphs.First().Append("Test Objective").Color(white);
            testSummary.Rows[0].Cells[0].FillColor = royalBlue;
            testSummary.Rows[0].Cells[1].FillColor = royalBlue;
            testSummary.Rows[0].Cells[2].FillColor = royalBlue;

            testSummary.Rows[1].Cells[0].Paragraphs.First().Append(thisTestCase.TestCaseId.ToString());
            testSummary.Rows[1].Cells[1].Paragraphs.First().Append(thisTestCase.TestDescription);
            testSummary.Rows[1].Cells[2].Paragraphs.First().Append(thisTestCase.TestObjective);
            testSummary.SetWidths(columnWidths);
            doc.InsertTable(testSummary);
            doc.InsertParagraph("Steps to follow").FontSize(16);

            Table testActionResult = doc.AddTable(thisTestCase.TestSteps.Count + 1, 3);

            testActionResult.SetWidths(columnWidths);
            testActionResult.Rows[0].Cells[0].Paragraphs.First().Append("Steps").Color(white);
            testActionResult.Rows[0].Cells[1].Paragraphs.First().Append("Action").Color(white);
            testActionResult.Rows[0].Cells[2].Paragraphs.First().Append("Expected Result").Color(white);
            testActionResult.Rows[0].Cells[0].FillColor = royalBlue;
            testActionResult.Rows[0].Cells[1].FillColor = royalBlue;
            testActionResult.Rows[0].Cells[2].FillColor = royalBlue;

            int i = 0;
            foreach (TestStep testStep in thisTestCase.TestSteps)
            {
                i++;
                string action   = Utility.RemoveTags(testStep.Action);
                string expected = Utility.RemoveTags(testStep.Expected);

                testActionResult.Rows[i].Cells[0].Paragraphs.First().Append(testStep.StepNumber.ToString());
                testActionResult.Rows[i].Cells[1].Paragraphs.First().Append(action);
                testActionResult.Rows[i].Cells[2].Paragraphs.First().Append(expected);
            }

            doc.InsertTable(testActionResult);
            #endregion
            return(doc);
        }
 public void Setup()
 {
     reader   = new PropertiesReader();
     context  = new ReaderContext();
     document = new CircuitDiagramDocument();
 }
示例#7
0
        public void CreateWordDocSuite(string userName, int planID, int suiteID)
        {
            #region Boring stuff
            // Test Case Pull
            #region Pull Test Case from TFS
            PropertiesReader config = new PropertiesReader("config.txt");

            Properties props = new Properties();
            props.PersonalAccessToken = config.get("personalaccesstoken");
            props.TestPlanId          = Convert.ToInt32(config.get("testplanid"));
            props.TestSuiteId         = Convert.ToInt32(config.get("testsuiteid"));
            props.Project             = config.get("project");
            props.Uri                = config.get("server");
            props.SaveLocation       = config.get("saveLocation");
            props.FileName           = StringTools.addExtension(config.get("fileName"), "xlsx");;
            props.ExecutionSheetName = config.get("executionsheetname");
            props.ScriptSheetName    = config.get("scriptsheetname");
            props.TestPlanId         = Convert.ToInt32(config.get("testplanid"));
            props.TestSuiteId        = Convert.ToInt32(config.get("testsuiteid"));

            Logger logger = new Logger(props.SaveLocation);

            props.Logger = logger;
            #endregion
            Color royalBlue = Color.FromName("RoyalBlue");
            Color white     = Color.FromName("White");
            RequirementsTraceabilityJobs requirementsTraceabilityJob = new RequirementsTraceabilityJobs(props);
            string location = "C:\\Users\\" + userName + "\\Desktop\\Evidence Docs for Suite " + suiteID;
            System.IO.Directory.CreateDirectory(location);

            List <TestCase> cases = new List <TestCase>();
            cases = requirementsTraceabilityJob.GetTestCaseGivenPlanSuite(planID, suiteID);

            foreach (TestCase testCase in cases)
            {
                string testName     = testCase.TestCaseId.ToString() + "_" + testCase.TestCaseName.Replace(" ", "_").Replace(")", "_").Replace("(", "_").Replace("/", "_").Replace("\\", "_").Replace(" - ", "_").Replace("\"", "_").Replace("'", "_");
                DocX   doc          = DocX.Create(testName);
                var    columnWidths = new float[] { 225f, 225f, 225f };
                Table  testSummary  = doc.AddTable(2, 3);
                //Test Objective table

                string TestDescription = testCase.TestDescription.Replace("&nbsp", " ");
                doc.InsertParagraph("Test Objective").FontSize(16);
                testSummary.Rows[0].Cells[0].Paragraphs.First().Append("#").Color(white);
                testSummary.Rows[0].Cells[1].Paragraphs.First().Append("Title").Color(white);
                testSummary.Rows[0].Cells[2].Paragraphs.First().Append("Test Objective").Color(white);
                testSummary.Rows[0].Cells[0].FillColor = royalBlue;
                testSummary.Rows[0].Cells[1].FillColor = royalBlue;
                testSummary.Rows[0].Cells[2].FillColor = royalBlue;
                testSummary.Rows[1].Cells[0].Paragraphs.First().Append(testCase.TestCaseId.ToString());
                testSummary.Rows[1].Cells[1].Paragraphs.First().Append(testCase.TestDescription);
                testSummary.Rows[1].Cells[2].Paragraphs.First().Append(testCase.TestObjective);
                testSummary.SetWidths(columnWidths);
                doc.InsertTable(testSummary);


                doc.InsertParagraph("Steps to follow").FontSize(16);
                Table testActionResult = doc.AddTable(testCase.TestSteps.Count + 1, 3);
                testActionResult.SetWidths(columnWidths);
                testActionResult.Rows[0].Cells[0].Paragraphs.First().Append("Steps").Color(white);
                testActionResult.Rows[0].Cells[1].Paragraphs.First().Append("Action").Color(white);
                testActionResult.Rows[0].Cells[2].Paragraphs.First().Append("Expected Result").Color(white);
                testActionResult.Rows[0].Cells[0].FillColor = royalBlue;
                testActionResult.Rows[0].Cells[1].FillColor = royalBlue;
                testActionResult.Rows[0].Cells[2].FillColor = royalBlue;



                Console.WriteLine(testName);
                int i = 0;
                Console.WriteLine("Test Case Count " + testCase.TestSteps.Count);
                foreach (TestStep testStep in testCase.TestSteps)
                {
                    i++;
                    string action   = Utility.RemoveTags(testStep.Action);
                    string expected = Utility.RemoveTags(testStep.Expected);

                    testActionResult.Rows[i].Cells[0].Paragraphs[0].Append(testStep.StepNumber.ToString());
                    testActionResult.Rows[i].Cells[1].Paragraphs.First().Append(action);
                    testActionResult.Rows[i].Cells[2].Paragraphs.First().Append(expected);
                }

                doc.InsertTable(testActionResult);
                doc.SaveAs(location + "//" + testName + ".docx");
            }
            ;
            #endregion
        }
 public static string GetValue(string key)
 {
     return(PropertiesReader.GetValue(key));
 }
示例#9
0
        public void TestTFS()
        {
            #region Start up
            ExtentTest test = null;

            DateTime now      = DateTime.Now;
            string   testName = "TFSDoc";
            DocX     doc      = DocX.Create(testName);

            // Test Case Pull
            PropertiesReader config = new PropertiesReader("config.txt");

            Properties props = new Properties();
            props.PersonalAccessToken = config.get("personalaccesstoken");
            props.TestPlanId          = Convert.ToInt32(config.get("testplanid"));
            props.TestSuiteId         = Convert.ToInt32(config.get("testsuiteid"));
            props.Project             = config.get("project");
            props.Uri                = config.get("server");
            props.SaveLocation       = config.get("saveLocation");
            props.FileName           = StringTools.addExtension(config.get("fileName"), "xlsx");;
            props.ExecutionSheetName = config.get("executionsheetname");
            props.ScriptSheetName    = config.get("scriptsheetname");
            props.TestPlanId         = Convert.ToInt32(config.get("testplanid"));
            props.TestSuiteId        = Convert.ToInt32(config.get("testsuiteid"));

            Logger logger = new Logger(props.SaveLocation);

            props.Logger = logger;

            TestCase thisTestCase = new TestCase();
            RequirementsTraceabilityJobs requirementsTraceabilityJob = new RequirementsTraceabilityJobs(props);
            thisTestCase = requirementsTraceabilityJob.GetSingleTestCase(152599, 152048);
            foreach (TestStep testStep in thisTestCase.TestSteps)
            {
                string action   = testStep.Action;
                string expected = testStep.Expected;
            }
            #endregion

            using (context)
            {
                context.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
                context.Url = "http://somedomain/url_that_delays_loading";
                IWebElement myDynamicElement = context.FindElement(By.Id("someDynamicElement"));
            }
            using (context)
            {
                context.Url = "http://somedomain/url_that_delays_loading";
                WebDriverWait wait             = new WebDriverWait(context, TimeSpan.FromSeconds(10));
                IWebElement   myDynamicElement = wait.Until <IWebElement>(d => d.FindElement(By.Id("someDynamicElement")));
            }

            try
            {
                foreach (TestStep testStep in thisTestCase.TestSteps)
                {
                    string    action   = testStep.Action;
                    string    expected = testStep.Expected;
                    Paragraph par      = doc.InsertParagraph(action + ": " + expected);
                }
                doc.Save();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
示例#10
0
        public void CreateDoctest()
        {
            // Test Case Pull
            #region Pull Test Case from TFS
            PropertiesReader config  = new PropertiesReader("config.txt");
            Utility          utility = new Utility(context);
            Properties       props   = new Properties();
            props.PersonalAccessToken = config.get("personalaccesstoken");
            props.TestPlanId          = Convert.ToInt32(config.get("testplanid"));
            props.TestSuiteId         = Convert.ToInt32(config.get("testsuiteid"));
            props.Project             = config.get("project");
            props.Uri                = config.get("server");
            props.SaveLocation       = config.get("saveLocation");
            props.FileName           = StringTools.addExtension(config.get("fileName"), "xlsx");;
            props.ExecutionSheetName = config.get("executionsheetname");
            props.ScriptSheetName    = config.get("scriptsheetname");
            props.TestPlanId         = Convert.ToInt32(config.get("testplanid"));
            props.TestSuiteId        = Convert.ToInt32(config.get("testsuiteid"));

            Logger logger = new Logger(props.SaveLocation);

            props.Logger = logger;

            TestCase thisTestCase = new TestCase();
            RequirementsTraceabilityJobs requirementsTraceabilityJob = new RequirementsTraceabilityJobs(props);
            thisTestCase = requirementsTraceabilityJob.GetSingleTestCase(152501, 152045);

            List <TestCase> cases = new List <TestCase>();
            cases = requirementsTraceabilityJob.GetTestCaseGivenPlanSuite(149579, 152045);

            string testName     = thisTestCase.TestCaseId.ToString() + "_" + thisTestCase.TestCaseName.Replace(" ", "_");
            DocX   doc          = DocX.Create(testName);
            var    columnWidths = new float[] { 225f, 225f, 225f };
            Table  testSummary  = doc.AddTable(2, 3);
            //Test Objective table

            doc.InsertParagraph("Test Objective").FontSize(16);
            testSummary.Rows[0].Cells[0].Paragraphs.First().Append("#");
            testSummary.Rows[0].Cells[1].Paragraphs.First().Append("Title");
            testSummary.Rows[0].Cells[2].Paragraphs.First().Append("Test Objective");

            testSummary.Rows[1].Cells[0].Paragraphs.First().Append(thisTestCase.TestCaseId.ToString());
            testSummary.Rows[1].Cells[1].Paragraphs.First().Append(thisTestCase.TestDescription);
            testSummary.Rows[1].Cells[2].Paragraphs.First().Append(thisTestCase.TestObjective);
            testSummary.SetWidths(columnWidths);
            doc.InsertTable(testSummary);
            doc.InsertParagraph("Steps to follow").FontSize(16);

            Table testActionResult = doc.AddTable(thisTestCase.TestSteps.Count + 1, 3);
            testActionResult.SetWidths(columnWidths);
            testActionResult.Rows[0].Cells[0].Paragraphs.First().Append("Steps");
            testActionResult.Rows[0].Cells[1].Paragraphs.First().Append("Action");
            testActionResult.Rows[0].Cells[2].Paragraphs.First().Append("Expected Result");

            int i = 0;
            foreach (TestStep testStep in thisTestCase.TestSteps)
            {
                i++;
                string action   = Utility.RemoveTags(testStep.Action);
                string expected = Utility.RemoveTags(testStep.Expected);

                testActionResult.Rows[i].Cells[0].Paragraphs.First().Append(testStep.StepNumber.ToString());
                testActionResult.Rows[i].Cells[1].Paragraphs.First().Append(action);
                testActionResult.Rows[i].Cells[2].Paragraphs.First().Append(expected);
            }

            doc.InsertTable(testActionResult);
            doc.Save();
            Process.Start("WINWORD.EXE", testName);
            #endregion
        }
示例#11
0
        static void Main(string[] args)
        {
            //string pat = "7wwgihgjbgchepkpvn4adotkd7bmt3ewtwsr7u4grny7yisrwe3a";
            //string server = "http://10.3.28.4/";
            //string project = "APHP Virginia";
            string saveLocation          = "C:\\Users\\cody.hui\\Desktop\\";
            string fileName              = "Test Status Report_Metrics_07MAY19";
            string fileNameWithExtension = StringTools.addExtension(fileName, "xlsx");
            //string testExecutionSheetName = "Test Execution";
            //string testScriptSheetName = "Test Script";
            //string inputtedStartDateTime = "4/1/2019";
            //string inputtedEndDateTime = "5/6/2019";
            //int testplan = 142838;
            //int testsuite = 149850;

            PropertiesReader config = new PropertiesReader("config.txt");

            Logger logger = new Logger(config.get("saveLocation"));

            Properties props = new Properties();

            props.Logger = logger;
            props.PersonalAccessToken = config.get("personalaccesstoken");
            props.TestPlanId          = Convert.ToInt32(config.get("testplanid"));
            props.TestSuiteId         = Convert.ToInt32(config.get("testsuiteid"));
            props.Project             = config.get("project");
            props.Uri                = config.get("server");
            props.SaveLocation       = config.get("saveLocation");
            props.FileName           = StringTools.addExtension(config.get("fileName"), "xlsx");
            props.ExecutionSheetName = config.get("executionsheetname");
            props.ScriptSheetName    = config.get("scriptsheetname");

            string inputtedStartDateTime = config.get("startdate");
            string inputtedEndDateTime   = config.get("enddate");

            //if (!System.Diagnostics.Debugger.IsAttached)
            //{
            //    Console.Write("Enter file path: ");
            //    saveLocation = Console.ReadLine();

            //    Console.Write("Enter file name: ");
            //    fileName = Console.ReadLine();
            //    fileNameWithExtension = stringTool.addExtension(fileName, "xlsx");

            //    Console.Write("Enter Start Date: ");
            //    inputtedStartDateTime = Console.ReadLine();

            //    Console.Write("Enter End Date: ");
            //    inputtedEndDateTime = Console.ReadLine();
            //}

            ITFSReportingJobs reportingJobs = new TFSReportingJobs();

            //// If there is no Case ID for a Test Case on the Execution Input Data Sheet,
            //// then we will update the Test Case ID for that row (needs both Test Case Name and Test Suite ID)
            //reportingJobs.UpdateExcelTestCaseId(props);

            ////Gathers the 200 most recent Test Runs under the Test Plan ID and writes them to the DB
            //reportingJobs.GatherTestRunAndResultsAndWriteToDb(props);

            //// If the system sees that there are Test Cases in TFS for a certain iteration but it is not in the sheet,
            //// then we will add a row onto the spreadsheet for that single case.
            //// NOTE: It is possible to have duplicate Test Cases here if we have Test Cases without a Test Suite ID that
            //// match to a Test Case in TFS
            //reportingJobs.UpdateExcelExecutionInputData(props);

            // Update the Execution Actuals and Execution Input Data with the Test Results from the DB.
            reportingJobs.UpdateExcelDailyDefect(inputtedStartDateTime, inputtedEndDateTime, props);

            Console.WriteLine("All Tasks have finished...");
            Console.ReadLine();
        }
示例#12
0
        static void Main(string[] args)
        {
            //string pat = "7wwgihgjbgchepkpvn4adotkd7bmt3ewtwsr7u4grny7yisrwe3a";
            //string server = "http://10.3.28.4/";
            //string project = "APHP Virginia";
            string saveLocation          = "C:\\Users\\cody.hui\\Desktop\\";
            string fileName              = "Test Status Report_Metrics_07MAY19";
            string fileNameWithExtension = StringTools.addExtension(fileName, "xlsx");
            //string testExecutionSheetName = "Test Execution";
            //string testScriptSheetName = "Test Script";
            //string inputtedStartDateTime = "4/1/2019";
            //string inputtedEndDateTime = "5/6/2019";
            //int testplan = 142838;
            //int testsuite = 149850;

            PropertiesReader config = new PropertiesReader("config.txt");

            Logger logger = new Logger(config.get("saveLocation"));

            Properties props = new Properties();

            props.Logger = logger;
            props.PersonalAccessToken = config.get("personalaccesstoken");
            props.TestPlanId          = Convert.ToInt32(config.get("testplanid"));
            props.TestSuiteId         = Convert.ToInt32(config.get("testsuiteid"));
            props.Project             = config.get("project");
            props.Uri                               = config.get("server");
            props.SaveLocation                      = config.get("saveLocation");
            props.FileName                          = StringTools.addExtension(config.get("fileName"), "xlsx");
            props.ExecutionSheetName                = config.get("executionsheetname");
            props.ScriptSheetName                   = config.get("scriptsheetname");
            props.UseWebApi                         = Convert.ToInt32(config.get("usewebapi"));
            props.NumberOfTestRun                   = Convert.ToInt32(config.get("numberoftestruns"));
            props.FolderCountsSheetName             = config.get("folderCountsSheetName");
            props.TfsDefectsSheetName               = config.get("tfsDefectsSheetName");
            props.TfsTestCaseWithDefectSheetName    = config.get("tfsTestCaseWithDefectSheetName");
            props.TfsDefectsProposedSheetName       = config.get("tfsDefectsProposedSheetName");
            props.ReadyForTestCriticalHighSheetName = config.get("readyForTestCritialHighSheetName");
            props.ReadyForTestMediumLowSheetName    = config.get("readyForTestMediumLowSheetName");
            props.StartDate                         = DateTime.Parse(config.get("startdate"));
            props.EndDate                           = DateTime.Parse(config.get("enddate"));

            string inputtedStartDateTime = config.get("startdate");
            string inputtedEndDateTime   = config.get("enddate");

            //if (!System.Diagnostics.Debugger.IsAttached)
            //{
            //    Console.Write("Enter file path: ");
            //    saveLocation = Console.ReadLine();

            //    Console.Write("Enter file name: ");
            //    fileName = Console.ReadLine();
            //    fileNameWithExtension = stringTool.addExtension(fileName, "xlsx");

            //    Console.Write("Enter Start Date: ");
            //    inputtedStartDateTime = Console.ReadLine();

            //    Console.Write("Enter End Date: ");
            //    inputtedEndDateTime = Console.ReadLine();
            //}

            ITFSReportingJobs reportingJobs = new TFSReportingJobs(props);

            //// If there is no Case ID for a Test Case on the Execution Input Data bSheet,
            //// then we will update the Test Case ID for that row (needs both Test Case Name and Test Suite ID)
            //reportingJobs.UpdateExcelTestCaseId(props);

            //Gathers the 200 most recent Test Runs under the Test Plan ID and writes them to the DB
            // --> TFSTools
            // --> WebAPITools (not required)
            // --> ExcelTools
            if (config.get("GatherTestRunAndResultsAndWriteToDb") == "1")
            {
                Console.WriteLine("--------------------------------------------");
                Console.WriteLine("Starting GatherTestRunAndResultsAndWriteToDb");
                reportingJobs.GatherTestRunAndResultsAndWriteToDb();
                Console.WriteLine("Finished GatherTestRunAndResultsAndWriteToDb");
                Console.WriteLine("--------------------------------------------");
            }

            // If the system sees that there are Test Cases in TFS for a certain iteration but it is not in the sheet,
            // then we will add a row onto the spreadsheet for that single case.
            // NOTE: It is possible to have duplicate Test Cases here if we have Test Cases without a Test Suite ID that
            // match to a Test Case in TFS
            // --> TFSTools
            // --> WebAPITools (not required)
            // --> ExcelTools
            if (config.get("UpdateExcelExecutionInputData") == "1")
            {
                Console.WriteLine("--------------------------------------------");
                Console.WriteLine("Starting UpdateExcelExecutionInputData");
                reportingJobs.UpdateExcelExecutionInputData();
                Console.WriteLine("Finished UpdateExcelExecutionInputData");
                Console.WriteLine("--------------------------------------------");
            }

            // Update the Execution Actuals and Execution Input Data with the Test Results from the DB.
            // --> TFSTools
            // --> WebAPITools (not required)
            // --> ExcelTools
            if (config.get("UpdateExcelDailyTestCaseRun") == "1")
            {
                Console.WriteLine("--------------------------------------------");
                Console.WriteLine("Starting UpdateExcelDailyTestCaseRun");
                reportingJobs.UpdateExcelDailyTestCaseRun(inputtedStartDateTime, inputtedEndDateTime);
                Console.WriteLine("Finished UpdateExcelDailyTestCaseRun");
                Console.WriteLine("--------------------------------------------");
            }

            // Update the Daily Execution Status for the Overall and Daily Iteration status
            // --> WebAPITools
            // --> ExcelTools
            if (config.get("UpdateExcelDailyExecutionStatus") == "1")
            {
                Console.WriteLine("--------------------------------------------");
                Console.WriteLine("Starting UpdateExcelDailyExecutionStatus");
                reportingJobs.UpdateExcelDailyExecutionStatus();
                Console.WriteLine("Finished UpdateExcelDailyExecutionStatus");
                Console.WriteLine("--------------------------------------------");
            }

            // Update both the Defects With Test Case count as well as the Test Cases linked with Defect sheets.
            // --> TFSTools
            // --> WebAPITools (not required)
            // --> ExcelTools
            if (config.get("UpdateExcelDefectWithTestCaseCount") == "1")
            {
                Console.WriteLine("--------------------------------------------");
                Console.WriteLine("Starting UpdateExcelDefectWithTestCaseCount");
                reportingJobs.UpdateExcelDefectWithTestCaseCount();
                Console.WriteLine("Finished UpdateExcelDefectWithTestCaseCount");
                Console.WriteLine("--------------------------------------------");
            }

            // Update both of the Ready for Test Test Cases for Critical/High and Medium/Low defects.
            // --> WebAPITools
            // --> ExcelTools
            if (config.get("UpdateTestCasesReadyForTest") == "1")
            {
                Console.WriteLine("--------------------------------------------");
                Console.WriteLine("Starting UpdateTestCasesReadyForTest");
                reportingJobs.UpdateTestCasesReadyForTest();
                Console.WriteLine("Finished UpdateTestCasesReadyForTest");
                Console.WriteLine("--------------------------------------------");
            }

            // Update the Folder Counts sheet with the Failed with Minor Defects count
            // --> WebAPITools
            // --> ExcelTools
            if (config.get("UpdateExcelFolderCounts") == "1")
            {
                Console.WriteLine("--------------------------------------------");
                Console.WriteLine("Starting UpdateExcelFolderCounts");
                reportingJobs.UpdateExcelFolderCounts();
                Console.WriteLine("Finished UpdateExcelFolderCounts");
                Console.WriteLine("--------------------------------------------");
            }

            Console.WriteLine("All Tasks have finished...");
            Console.ReadLine();
        }