Example #1
0
        private static void ThreadedSpinoff(List <string> _pathList, string browser, string url)
        {
            if (browser.Contains("Firefox"))
            {
                browser = "Firefox";
            }
            else if (browser.Contains("Microsoft"))
            {
                browser = "Microsoft Edge";
            }
            else if (browser.Contains("Chrome"))
            {
                browser = "Chrome";
            }


            var gethods = new GeneralTestMethods();

            CFarmEmail cFarmEmail = new CFarmEmail(gethods);

            foreach (var path in _xmlPathList)
            {
                cFarmEmail = CreateTestObjects(path, cFarmEmail, gethods, browser, url);
            }

            cFarmEmail.SetSubject(browser);

            if (cFarmEmail.GetEmailList() != null)
            {
                gethods.SendEmail(cFarmEmail.GetSubject(), cFarmEmail.GetData(), cFarmEmail.GetEmailList());
            }
            gethods.PostResults(cFarmEmail.GetJson(), url);
        }
Example #2
0
        public void RunScheduledTest()
        {
            TextRange textRange = new TextRange(
                // TextPointer to the start of content in the RichTextBox.
                SiteAddress.Document.ContentStart,
                // TextPointer to the end of content in the RichTextBox.
                SiteAddress.Document.ContentEnd
                );

            // The Text property on a TextRange object returns a string
            // representing the plain text content of the TextRange.
            var InputBrowser = textRange.Text.Replace("\r\n", "");

            _url = InputBrowser;

            var url     = _url;
            var baseDir = System.IO.Directory.GetCurrentDirectory();
            var Path1   = "";

            if (_whichTest != "")
            {
                _xmlPathList = new List <String>();
                switch (_whichTest)
                {
                case "CFarmCroplands":
                    Path1 = Path.Combine(baseDir, "CFarm\\CroplandsScenarios");
                    foreach (var FileName in CroplandProjects)
                    {
                        _xmlPathList.Add(Path.Combine(Path1, FileName + ".xml"));
                    }



                    break;

                case "CFarmAnimalAg":
                    Path1 = Path.Combine(baseDir, "CFarm\\AnimalAgScenarios");
                    foreach (var FileName in AnimalAgProjects)
                    {
                        _xmlPathList.Add(Path.Combine(Path1, FileName + ".xml"));
                    }


                    break;

                case "CFarmAgroforestry":
                    Path1 = Path.Combine(baseDir, "CFarm\\AgroforestryScenarios");
                    foreach (var FileName in AgroForestryProject)
                    {
                        _xmlPathList.Add(Path.Combine(Path1, FileName + ".xml"));
                    }
                    break;


                case "CFarmForestry":
                    Path1 = Path.Combine(baseDir, "CFarm\\ForestryScenarios");
                    foreach (var FileName in ForestryProjects)
                    {
                        _xmlPathList.Add(Path.Combine(Path1, FileName + ".xml"));
                    }

                    break;


                case "CFarmComprehensive":
                    Path1 = Path.Combine(baseDir, "CFarm\\ComprehensiveScenarios");
                    foreach (var FileName in ComprehensiveProjects)
                    {
                        _xmlPathList.Add(Path.Combine(Path1, FileName + ".xml"));
                    }
                    break;

                case "BfuelComprehensive":

                    break;


                case "All Cfarm Tests":

                    Path1 = Path.Combine(baseDir, "CFarm\\CroplandsScenarios");
                    foreach (var FileName in CroplandProjects)
                    {
                        _xmlPathList.Add(Path.Combine(Path1, FileName + ".xml"));
                    }

                    Path1 = Path.Combine(baseDir, "CFarm\\AnimalAgScenarios");
                    foreach (var FileName in AnimalAgProjects)
                    {
                        _xmlPathList.Add(Path.Combine(Path1, FileName + ".xml"));
                    }

                    Path1 = Path.Combine(baseDir, "CFarm\\AgroforestryScenarios");
                    foreach (var FileName in AgroForestryProject)
                    {
                        _xmlPathList.Add(Path.Combine(Path1, FileName + ".xml"));
                    }
                    Path1 = Path.Combine(baseDir, "CFarm\\ForestryScenarios");
                    foreach (var FileName in ForestryProjects)
                    {
                        _xmlPathList.Add(Path.Combine(Path1, FileName + ".xml"));
                    }
                    Path1 = Path.Combine(baseDir, "CFarm\\ComprehensiveScenarios");
                    foreach (var FileName in ComprehensiveProjects)
                    {
                        _xmlPathList.Add(Path.Combine(Path1, FileName + ".xml"));
                    }
                    break;
                }
            }


            if (_whichBrowser.Contains("All")) //one email per browser
            {
                foreach (string BrowserString in BrowserList)
                {
                    Thread t = new Thread(() => ThreadedSpinoff(_xmlPathList, BrowserString, url));
                    t.Start();
                }
            }
            else
            {
                var gMethods = new GeneralTestMethods();

                CFarmEmail cFarmEmail = new CFarmEmail(gMethods);
                foreach (var path in _xmlPathList)
                {
                    cFarmEmail = CreateTestObjects(path, cFarmEmail, gMethods, _whichBrowser, url);
                }



                //


                cFarmEmail.SetSubject(_whichBrowser);

                if (cFarmEmail.GetEmailList() != null)
                {
                    gMethods.SendEmail(cFarmEmail.GetSubject(), cFarmEmail.GetData(), cFarmEmail.GetEmailList());
                }
                gMethods.PostResults(cFarmEmail.GetJson(), url);
            }
        }