Beispiel #1
0
        public PresentationWebResourceTestDto GetTest(int testId)
        {
            try
            {
                PresentationAutomapperConfig.Configure();

                WebResourceTest test = this.dataUnit.GetRepository <WebResourceTest>().GetById(testId);

                PresentationWebResourceTestDto presentationTestResults = new PresentationWebResourceTestDto();

                presentationTestResults = Mapper.Map <WebResourceTest, PresentationWebResourceTestDto>(test);

                presentationTestResults.TotalTestsCount      = presentationTestResults.Tests.Sum(res => res.TestsCount);
                presentationTestResults.TotalWrongTestsCount = presentationTestResults.Tests.Sum(res => res.WrongTestsCount);
                presentationTestResults.WrongUrls            = presentationTestResults.Tests.Where(res => res.WrongTestsCount == res.TestsCount).Count();
                presentationTestResults.SuccessfulUrls       = presentationTestResults.Tests.Where(res => res.WrongTestsCount == 0).Count();
                presentationTestResults.TotalUrls            = presentationTestResults.Tests.Count();

                return(presentationTestResults);
            }
            catch
            {
                throw;
            }
        }
Beispiel #2
0
        public void RunTest(int testId, int timeout, int testsCount, CancellationToken token, string connectionId, bool dynamicMode)
        {
            try
            {
                PresentationAutomapperConfig.Configure();
                if (timeout == 0)
                {
                    timeout = ConnectionSettings.GetTimeout();
                }
                if (testsCount == 0)
                {
                    testsCount = ConnectionSettings.GetTestsCount();
                }
                double interval = ConnectionSettings.GetInterval();

                WebResourceTest webResourceTest;

                webResourceTest = this.dataUnit.GetRepository <WebResourceTest>().GetById(testId);

                string globalUrl = webResourceTest.WebResource.Url;

                if (!dynamicMode)
                {
                    IEnumerable <string> urls = this.tester.Reader.GetSitemapUrls(globalUrl);

                    if (urls.Count() > 1)
                    {
                        this.RunSitemapTest(webResourceTest, urls, timeout, testsCount, interval, token, connectionId);
                    }
                    else
                    {
                        this.RunHtmlTest(webResourceTest, timeout, interval, testsCount, token, connectionId);
                    }
                }
                else
                {
                    this.RunHtmlTest(webResourceTest, timeout, interval, testsCount, token, connectionId);
                }
            }
            catch
            {
            }
            this.TestDone(connectionId);
        }