示例#1
0
        public void Valid_Credentials_GetsResults(string testId) //commented after testing to save api calls during futher tests
        {
            IWebPageTester gtMetrixObject = new GtMetrixTester("79833eef2ccd3c70f03a7de88b2009e9", "*****@*****.**");
            var            testResults    = gtMetrixObject.GetResult(testId);

            Assert.AreEqual(testResults.Success, true);
        }
示例#2
0
        public void InValid_Credentials_Fails_To_GetsResults(string testId) //commented after testing to save api calls during futher tests
        {
            IWebPageTester gtMetrixObject = new GtMetrixTester("asdf", "asdf");
            var            testResults    = gtMetrixObject.GetResult(testId);

            Assert.AreEqual(testResults.HttpStatusCode, HttpStatusCode.Unauthorized);
        }
示例#3
0
        static void TestGetMetrix(string url)
        {
            IWebPageTester gtMetrixObject = new GtMetrixTester(_gtMetrixApiKey, _gtMetrixUserName);
            var            request        = new TestRequestParameter(url);
            var            resposne       = gtMetrixObject.SubmitTest(request);

            Console.WriteLine($"Success:{resposne.Success}");
            Console.WriteLine($"HttpStatusCode: {resposne.HttpStatusCode}");
            Console.WriteLine($"PollStateUrl: {resposne.PollStateUrl ?? string.Empty}");
            Console.WriteLine($"Error: {resposne.Error ?? string.Empty}");
            Console.WriteLine($"Id: {resposne.TestId ?? string.Empty}");
            Console.WriteLine($"Status: {resposne.Status ?? string.Empty}");
            Console.WriteLine($"------------------------------------------------------------");
            var          testId = resposne.TestId;
            TestResponse result = null;

            do
            {
                result = gtMetrixObject.GetResult(testId);
                Console.WriteLine($"Success:{result.Success}. Code: {result.HttpStatusCode}");
                Console.WriteLine($"Task Status:{result.TaskStatus}.");
                if (result.Success && result.TestCompelted)
                {
                    break;
                }
                Console.WriteLine($".....Sleeping for two seconds.....");
                Thread.Sleep(2000);
            }while (!result.TestCompelted && result.Success);
            Console.WriteLine($"Task Status:{result.TaskStatus}");
            Console.WriteLine($"resposne.Success:{result.Success}");
            Console.WriteLine($"PageBytes:{result.PageBytes}");
            Console.WriteLine($"PageLoadTime:{result.PageLoadTime}");
            Console.WriteLine($"PageElements:{result.PageElements}");
            Console.WriteLine($"ScreenshotUrl:{result.ScreenShotUrl}");
            Console.WriteLine($"ReportUrl:{result.ReportUrl}");
        }