DownloadPackageAndVerify() public static method

Downloads a package to local folder and see if the download is successful. Used to individual tests which extend the download scenarios.
public static DownloadPackageAndVerify ( string packageId, string version = "1.0.0" ) : void
packageId string
version string
return void
Exemplo n.º 1
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            //send a request to the stats/totals to get the initial count.
            WebTestRequest statsRequestBeforeDownload = GetWebRequestForAggregateStats();

            yield return(statsRequestBeforeDownload);

            statsRequestBeforeDownload = null;

            int aggregateStatsBeforeDownload = GetAggregateStatsFromContext();

            //upload a new package and download it.
            string packageId = DateTime.Now.Ticks.ToString() + this.Name;

            AssertAndValidationHelper.UploadNewPackageAndVerify(packageId);
            AssertAndValidationHelper.DownloadPackageAndVerify(packageId);

            //wait either the download count changes or till 5 minutes which ever is earlier.
            int waittime = 0;
            int aggregateStatsAfterDownload = aggregateStatsBeforeDownload;

            while (aggregateStatsAfterDownload == aggregateStatsBeforeDownload && waittime <= 300)
            {
                //send a request stats to keep polling the new download count.
                statsRequestBeforeDownload = GetWebRequestForAggregateStats();
                yield return(statsRequestBeforeDownload);

                statsRequestBeforeDownload = null;

                aggregateStatsAfterDownload = GetAggregateStatsFromContext();
                System.Threading.Thread.Sleep(30 * 1000);//sleep for 30 seconds.
                waittime += 30;
            }

            //send a request to home page and check aggregate stats numbers.
            WebTestRequest         pageRequest = new WebTestRequest(UrlHelper.BaseUrl);
            ValidationRuleFindText homePageTextValidationRuleAggStats = AssertAndValidationHelper.GetValidationRuleForFindText(aggregateStatsAfterDownload.ToString("N0"));

            pageRequest.ValidateResponse += new EventHandler <ValidationEventArgs>(homePageTextValidationRuleAggStats.Validate);
            yield return(pageRequest);

            pageRequest = null;

            //check download count. New download count should be old one + 1.
            Assert.IsTrue(aggregateStatsBeforeDownload < aggregateStatsAfterDownload, "Aggregate stats count is not increased by 1 after downloading. Aggregate stats before download :{0}. Stats after download : {1}", aggregateStatsBeforeDownload, aggregateStatsAfterDownload);
        }
Exemplo n.º 2
0
        public override IEnumerator <WebTestRequest> GetRequestEnumerator()
        {
            //send a request to the stats/totals to get the initial count.
            WebTestRequest statsRequestBeforeDownload = GetWebRequestForAggregateStats();

            yield return(statsRequestBeforeDownload);

            statsRequestBeforeDownload = null;

            int aggregateStatsBeforeDownload = GetAggregateStatsFromContext();

            //upload a new package and download it.
            string packageId = DateTime.Now.Ticks.ToString() + this.Name;

            AssertAndValidationHelper.UploadNewPackageAndVerify(packageId);
            AssertAndValidationHelper.DownloadPackageAndVerify(packageId);

            //wait either the download count changes or till 5 minutes which ever is earlier.
            int waittime = 0;
            int aggregateStatsAfterDownload = aggregateStatsBeforeDownload;

            while (aggregateStatsAfterDownload == aggregateStatsBeforeDownload && waittime <= 300)
            {
                //send a request stats to keep polling the new download count.
                statsRequestBeforeDownload = GetWebRequestForAggregateStats();
                yield return(statsRequestBeforeDownload);

                statsRequestBeforeDownload = null;

                aggregateStatsAfterDownload = GetAggregateStatsFromContext();
                System.Threading.Thread.Sleep(30 * 1000);//sleep for 30 seconds.
                waittime += 30;
            }

            //check download count. New download count should be old one + 1.
            Assert.IsTrue(aggregateStatsBeforeDownload == (aggregateStatsAfterDownload - 1), "Aggregate stats count is not increased by 1 after downloading. Aggregate stats before download :{0}. Stats after download : {1}", aggregateStatsBeforeDownload, aggregateStatsAfterDownload);
        }
Exemplo n.º 3
0
        public void DownloadPackageWithNuGetCoreTest()
        {
            string packageId = Constants.TestPackageId; //try to down load a pre-defined test package - BaseTestPackage.

            AssertAndValidationHelper.DownloadPackageAndVerify(packageId);
        }