• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# WebTestRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中WebTestRequest的典型用法代码示例。如果您正苦于以下问题:C# WebTestRequest类的具体用法?C# WebTestRequest怎么用?C# WebTestRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WebTestRequest类属于命名空间,在下文中一共展示了WebTestRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetRequestEnumerator

        public override IEnumerator<WebTestRequest> GetRequestEnumerator()
        {
            WebTestRequest logonRequest = new WebTestRequest(Utilities.BaseUrl + Constants.LogonPageUrlSuffix);
            logonRequest.ExpectedResponseUrl = Utilities.BaseUrl + Constants.LogonPageUrlSuffix;
            ExtractHiddenFields extractionRule1 = ValidationRuleHelper.GetDefaultExtractHiddenFields();
            logonRequest.ExtractValues += new EventHandler<ExtractionEventArgs>(extractionRule1.Extract);
            yield return logonRequest;
            logonRequest = null;

            //Send a post request with the appropriate form parameters for crednetials.
            WebTestRequest logonPostRequest = new WebTestRequest(Utilities.BaseUrl + Constants.LogonPageUrlSuffix);
            logonPostRequest.Method = "POST";
            logonPostRequest.ExpectedResponseUrl = Utilities.BaseUrl;
            FormPostHttpBody request10Body = new FormPostHttpBody();
            request10Body.FormPostParameters.Add("__RequestVerificationToken", this.Context["$HIDDEN1.__RequestVerificationToken"].ToString());
            request10Body.FormPostParameters.Add(Constants.UserNameOrEmailFormField, this.Context["LogOnCredentials.LogonCredentials#csv.UserNameOrEmail"].ToString());
            request10Body.FormPostParameters.Add(Constants.PasswordFormField, this.Context["LogOnCredentials.LogonCredentials#csv.Password"].ToString());
            logonPostRequest.Body = request10Body;
            WebTestRequest request10Dependent1 = new WebTestRequest(Utilities.BaseUrl + Constants.StatsPageUrlSuffix);
            logonPostRequest.DependentRequests.Add(request10Dependent1);
            if ((this.Context.ValidationLevel >= Microsoft.VisualStudio.TestTools.WebTesting.ValidationLevel.High))
            {
                //After logon, the user name should appear as a hyperlink the reponse URL
                ValidateHtmlTagInnerText loggedOnUserNameValidationRule = ValidationRuleHelper.GetValidationRuleForHtmlTagInnerText(HtmlTextWriterTag.A.ToString(), HtmlTextWriterAttribute.Href.ToString(), "/account", "NugetTestAccount");
                logonPostRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(loggedOnUserNameValidationRule.Validate);
            }
            yield return logonPostRequest;
            logonPostRequest = null;
        }
开发者ID:bhuvak,项目名称:NuGetGallery,代码行数:29,代码来源:LogonTest.cs


示例2: GetHttpRequestForUrl

 /// <summary>
 /// Returns a WebRequest for the given Url.
 /// </summary>
 /// <param name="url"></param>
 /// <returns></returns>
 public static WebTestRequest GetHttpRequestForUrl(string url)
 {
     var getRequest = new WebTestRequest(url);
     var extractionRule = GetDefaultExtractHiddenFields();
     getRequest.ExtractValues += extractionRule.Extract;
     return getRequest;
 }
开发者ID:skorunka,项目名称:NuGetGallery,代码行数:12,代码来源:AssertAndValidationHelper.cs


示例3: GetRequestEnumerator

        public override IEnumerator<WebTestRequest> GetRequestEnumerator()
         {
             //send a request to home page and check for security headers.
             WebTestRequest homePageRequest = new WebTestRequest(UrlHelper.BaseUrl);
             homePageRequest.ParseDependentRequests = false;
             ValidationRuleFindHeaderText homePageTextValidationRule = new ValidationRuleFindHeaderText(
 @"X-Frame-Options: deny
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000");               
             homePageRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(homePageTextValidationRule.Validate);         
             yield return homePageRequest;
             homePageRequest = null;
 
             //send a request to Packages page and check for security headers.
             WebTestRequest packagesPageRequest = new WebTestRequest(UrlHelper.PackagesPageUrl);
             packagesPageRequest.ParseDependentRequests = false;
             ValidationRuleFindHeaderText packagesPageTextValidationRule = new ValidationRuleFindHeaderText(
 @"X-Frame-Options: deny
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000");    
            packagesPageRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(packagesPageTextValidationRule.Validate);
            yield return packagesPageRequest;
            packagesPageRequest = null;


        }
开发者ID:ashuthinks,项目名称:webnuget,代码行数:28,代码来源:SecurityHeaderTest.cs


示例4: GetRequestEnumerator

        public override IEnumerator<WebTestRequest> GetRequestEnumerator()
        {
            // Инициализация правил проверки, применяемых ко всем запросам в веб-тесте
            if ((this.Context.ValidationLevel >= Microsoft.VisualStudio.TestTools.WebTesting.ValidationLevel.High))
            {
                ValidationRuleRequiredTag validationRule1 = new ValidationRuleRequiredTag();
                validationRule1.RequiredTagName = "User";
                validationRule1.MinOccurrences = 1;
                this.ValidateResponse += new EventHandler<ValidationEventArgs>(validationRule1.Validate);
            }
            if ((this.Context.ValidationLevel >= Microsoft.VisualStudio.TestTools.WebTesting.ValidationLevel.High))
            {
                ValidationRuleRequestTime validationRule2 = new ValidationRuleRequestTime();
                validationRule2.MaxRequestTime = 1000;
                this.ValidateResponse += new EventHandler<ValidationEventArgs>(validationRule2.Validate);
            }

            WebTestRequest request1 = new WebTestRequest("http://193.226.64.163/SANDBOXWebServiceDev/Service1.asmx");
            request1.Timeout = 3;
            request1.Method = "POST";
            request1.Encoding = System.Text.Encoding.GetEncoding("utf-8");
            request1.Headers.Add(new WebTestRequestHeader("SOAPAction", "http://tempuri.org/GetAllUsers"));
            StringHttpBody request1Body = new StringHttpBody();
            request1Body.ContentType = "text/xml";
            request1Body.InsertByteOrderMark = false;
            request1Body.BodyString = @"<?xml version=""1.0"" encoding=""utf-8""?>
            <soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
              <soap:Body>
            <GetAllUsers xmlns=""http://tempuri.org/"" />
              </soap:Body>
            </soap:Envelope>";
            request1.Body = request1Body;
            yield return request1;
            request1 = null;
        }
开发者ID:Alkazar250,项目名称:Sandbox-Testing,代码行数:35,代码来源:GetAllUsersCoded.cs


示例5: GetRequestEnumerator

        public override IEnumerator<WebTestRequest> GetRequestEnumerator()
        {
            WebTestRequest registerPageRequest = new WebTestRequest(Utilities.BaseUrl +   Constants.RegisterPageUrlSuffix);
            registerPageRequest.ThinkTime = 31;
            ExtractHiddenFields extractionRule1 = new ExtractHiddenFields();
            extractionRule1.Required = true;
            extractionRule1.HtmlDecode = true;
            extractionRule1.ContextParameterName = "1";
            registerPageRequest.ExtractValues += new EventHandler<ExtractionEventArgs>(extractionRule1.Extract);
            yield return registerPageRequest;
            registerPageRequest = null;

            WebTestRequest registerPagePostRequest = new WebTestRequest(Utilities.BaseUrl + Constants.RegisterPageUrlSuffix);
            registerPagePostRequest.Method = "POST";
            registerPagePostRequest.ExpectedResponseUrl = Utilities.BaseUrl + Constants.RegistrationPendingPageUrlSuffix;
            //create a form and set the UserName, Email and password as form post parameters.
            //We just need to set some unique user name and Email.
            FormPostHttpBody registerNewUserFormPost = new FormPostHttpBody();
            registerNewUserFormPost.FormPostParameters.Add("__RequestVerificationToken", this.Context["$HIDDEN1.__RequestVerificationToken"].ToString());
            registerNewUserFormPost.FormPostParameters.Add(Constants.EmailAddressFormField, DateTime.Now.Ticks.ToString() + "@gmail.com");
            registerNewUserFormPost.FormPostParameters.Add(Constants.UserNameFormField, DateTime.Now.Ticks.ToString());
            registerNewUserFormPost.FormPostParameters.Add(Constants.PasswordFormField, "xxxxxxx");
            registerNewUserFormPost.FormPostParameters.Add(Constants.ConfirmPasswordFormField, "xxxxxxx");
            registerPagePostRequest.Body = registerNewUserFormPost;
            //Validate the response to make sure that it has the pending confirmation text in it.
            if ((this.Context.ValidationLevel >= Microsoft.VisualStudio.TestTools.WebTesting.ValidationLevel.High))
            {
                ValidationRuleFindText PendingConfirmationTextRule = ValidationRuleHelper.GetValidationRuleForFindText(Constants.PendingConfirmationText);
                registerPagePostRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(PendingConfirmationTextRule.Validate);
            }
            yield return registerPagePostRequest;
            registerPagePostRequest = null;
        }
开发者ID:bhuvak,项目名称:NuGetGallery,代码行数:33,代码来源:RegisterNewUserTest.cs


示例6: GetRequestEnumerator

        public override IEnumerator<WebTestRequest> GetRequestEnumerator()
        {
          
            ExtractHiddenFields defaultExtractionRule = AssertAndValidationHelper.GetDefaultExtractHiddenFields();

            //Do initial login
            WebTestRequest logonGet = AssertAndValidationHelper.GetLogonGetRequest();
            yield return logonGet;
            logonGet = null;

            WebTestRequest logonPost = AssertAndValidationHelper.GetLogonPostRequest(this);
            yield return logonPost;
            logonPost = null;            

            WebTestRequest uploadRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl);       
            yield return uploadRequest;
            uploadRequest = null;

            // The API key is part of the nuget.config file that is present under the solution dir.
            string packageId = DateTime.Now.Ticks.ToString();
            string packageFullPath = PackageCreationHelper.CreatePackage(packageId);

            WebTestRequest uploadPostRequest = AssertAndValidationHelper.GetUploadPostRequestForPackage(this, packageFullPath);
            yield return uploadPostRequest;
            uploadPostRequest = null;

            WebTestRequest verifyUploadRequest = new WebTestRequest(UrlHelper.VerifyUploadPageUrl);
            verifyUploadRequest.ExtractValues += new EventHandler<ExtractionEventArgs>(defaultExtractionRule.Extract);
            yield return verifyUploadRequest;
            verifyUploadRequest = null;

            WebTestRequest verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(this, packageId, "1.0.0");              
            yield return verifyUploadPostRequest;
            verifyUploadPostRequest = null;      
        }
开发者ID:KuduApps,项目名称:NuGetGallery,代码行数:35,代码来源:UploadPackageFromUI.cs


示例7: GetHttpRequestForUrl

 /// <summary>
 /// Returns a WebRequest for the given Url. 
 /// </summary>
 /// <param name="url"></param>
 /// <returns></returns>
 public static WebTestRequest GetHttpRequestForUrl(string url)
 {
     WebTestRequest getRequest = new WebTestRequest(url);
     ExtractHiddenFields extractionRule1 = AssertAndValidationHelper.GetDefaultExtractHiddenFields();
     getRequest.ExtractValues += new EventHandler<ExtractionEventArgs>(extractionRule1.Extract);
     return getRequest;
 }
开发者ID:SaqibS,项目名称:NuGetGallery,代码行数:12,代码来源:AssertAndValidationHelper.cs


示例8: GetRequestEnumerator

        public override IEnumerator<WebTestRequest> GetRequestEnumerator()
        {
            //run this test only if read-only mode is set. This is to avoid false failures while doing Run all tests locally.
            if (EnvironmentSettings.ReadOnlyMode.Equals("True", StringComparison.OrdinalIgnoreCase))
            {
                var registerPageRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.LogonPageUrl);
                yield return registerPageRequest;

                var registerPagePostRequest = new WebTestRequest(UrlHelper.RegisterPageUrl);
                registerPagePostRequest.Method = "POST";
                registerPagePostRequest.ExpectedResponseUrl = UrlHelper.RegistrationPendingPageUrl;

                // Create a form and set the UserName, Email and password as form post parameters.
                // We just need to set some unique user name and Email.
                var registerNewUserFormPost = new FormPostHttpBody();
                registerNewUserFormPost.FormPostParameters.Add("__RequestVerificationToken", Context["$HIDDEN1.__RequestVerificationToken"].ToString());
                registerNewUserFormPost.FormPostParameters.Add("LinkingAccount", "false");
                registerNewUserFormPost.FormPostParameters.Add(Constants.EmailAddressFormField, DateTime.Now.Ticks + "@live.com"); //add a dummy mail account. This will be fixed once we incorporate the logic to delete user.
                registerNewUserFormPost.FormPostParameters.Add(Constants.UserNameFormField, DateTime.Now.Ticks + "NewAccount");
                registerNewUserFormPost.FormPostParameters.Add(Constants.RegisterPasswordFormField, "xxXxx1xx");
                registerPagePostRequest.Body = registerNewUserFormPost;
                registerPagePostRequest.ExpectedHttpStatusCode = 503;
                // Validate the response to make sure that it shows the error message for read-only mode.
                var readOnlyModeTextRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.ReadOnlyModeError);
                registerPagePostRequest.ValidateResponse += readOnlyModeTextRule.Validate;
                yield return registerPagePostRequest;
            }
        }
开发者ID:rhysawilliams2010,项目名称:NuGetGallery,代码行数:28,代码来源:RegisterNewUserInReadOnlyModeTest.cs


示例9: GetRequestEnumerator

        public override IEnumerator<WebTestRequest> GetRequestEnumerator()
        {
            WebTestRequest registerPageRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.LogonPageUrl);
            yield return registerPageRequest;
            registerPageRequest = null;

            WebTestRequest registerPagePostRequest = new WebTestRequest(UrlHelper.RegisterPageUrl);
            registerPagePostRequest.Method = "POST";
            registerPagePostRequest.ExpectedResponseUrl = UrlHelper.RegistrationPendingPageUrl;
            //create a form and set the UserName, Email and password as form post parameters.
            //We just need to set some unique user name and Email.
            FormPostHttpBody registerNewUserFormPost = new FormPostHttpBody();
            registerNewUserFormPost.FormPostParameters.Add("__RequestVerificationToken", this.Context["$HIDDEN1.__RequestVerificationToken"].ToString());
            registerNewUserFormPost.FormPostParameters.Add(Constants.EmailAddressFormField, DateTime.Now.Ticks.ToString() + "@live.com"); //add a dummy mail account. This will be fixed once we incorporate the logic to delete user.
            registerNewUserFormPost.FormPostParameters.Add(Constants.UserNameFormField, DateTime.Now.Ticks.ToString() + "NewAccount");
            registerNewUserFormPost.FormPostParameters.Add(Constants.PasswordFormField, "xxxxxxx");
            registerNewUserFormPost.FormPostParameters.Add(Constants.ConfirmPasswordFormField, "xxxxxxx");
            registerNewUserFormPost.FormPostParameters.Add(Constants.AcceptTermsField, "true");
            registerPagePostRequest.Body = registerNewUserFormPost;
            //Validate the response to make sure that it has the pending confirmation text in it.           
            ValidationRuleFindText PendingConfirmationTextRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.RegisterNewUserPendingConfirmationText);
            registerPagePostRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(PendingConfirmationTextRule.Validate);
            yield return registerPagePostRequest;
            registerPagePostRequest = null;
        }
开发者ID:projectkudu,项目名称:NuGetGallery,代码行数:25,代码来源:InvalidLogonTest.cs


示例10: GetRequestEnumerator

        public override IEnumerator<WebTestRequest> GetRequestEnumerator()
        {
            WebTestRequest registerPageRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.LogonPageUrl);
            yield return registerPageRequest;
            registerPageRequest = null;

            WebTestRequest registerPagePostRequest = new WebTestRequest(UrlHelper.SignInPageUrl);
            registerPagePostRequest.Method = "POST";
            registerPagePostRequest.ExpectedResponseUrl = UrlHelper.SignInPageUrl;
            //create a form and set the UserName, Email and password as form post parameters.
            //We just need to set some unique user name and Email.
            FormPostHttpBody registerNewUserFormPost = new FormPostHttpBody();
            registerNewUserFormPost.FormPostParameters.Add("__RequestVerificationToken", Context["$HIDDEN1.__RequestVerificationToken"].ToString());
            registerNewUserFormPost.FormPostParameters.Add("ReturnUrl", "/");
            registerNewUserFormPost.FormPostParameters.Add("LinkingAccount", "false");
            registerNewUserFormPost.FormPostParameters.Add(Constants.UserNameOrEmailFormField, DateTime.Now.Ticks.ToString() + "@live.com");
            registerNewUserFormPost.FormPostParameters.Add(Constants.PasswordFormField, EnvironmentSettings.TestAccountPassword);

            registerPagePostRequest.Body = registerNewUserFormPost;
            //Validate the response to make sure that it doesn't have the pending confirmation text in it.           
            ValidationRuleFindText PendingConfirmationTextRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.RegisterNewUserPendingConfirmationText, false);
            registerPagePostRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(PendingConfirmationTextRule.Validate);
            yield return registerPagePostRequest;
            registerPagePostRequest = null;
        }
开发者ID:segilbert,项目名称:NuGetGallery,代码行数:25,代码来源:InvalidLogonTest.cs


示例11: GetRequestEnumerator

        public override IEnumerator<WebTestRequest> GetRequestEnumerator()
        {
            WebTestRequest request1 = new WebTestRequest(Common.userDomain + "GetUserProfile");
            request1.Encoding = System.Text.Encoding.GetEncoding("utf-8");
            request1.QueryStringParameters.Add("userId", "aaf9a5a7-1f18-4a2d-b108-3ba3a978bdf6", false, false);
            request1.ValidateResponse += new EventHandler<ValidationEventArgs>(request1_ValidateResponse);
            yield return request1;
            request1 = null;

            WebTestRequest request2 = new WebTestRequest(Common.userDomain + "GetFriendList");
            request2.Encoding = System.Text.Encoding.GetEncoding("utf-8");
            request2.QueryStringParameters.Add("userId", "aaf9a5a7-1f18-4a2d-b108-3ba3a978bdf6", false, false);
            request2.ValidateResponse += new EventHandler<ValidationEventArgs>(request2_ValidateResponse);
            yield return request2;
            request2 = null;

            WebTestRequest request3 = new WebTestRequest(Common.userDomain + "IsLegalUserName");
            request3.Encoding = System.Text.Encoding.GetEncoding("utf-8");
            request3.QueryStringParameters.Add("userName", "testtest", false, false);
            request3.ValidateResponse += new EventHandler<ValidationEventArgs>(request3_ValidateResponse);
            yield return request3;
            request3 = null;

            WebTestRequest request4 = new WebTestRequest(Common.userDomain + "IsLegalUserName");
            request4.Encoding = System.Text.Encoding.GetEncoding("utf-8");
            request4.QueryStringParameters.Add("userName", "userwhichnotexist", false, false);
            request4.ValidateResponse += new EventHandler<ValidationEventArgs>(request4_ValidateResponse);
            yield return request4;
            request4 = null;
        }
开发者ID:sirtristancomtedeartois,项目名称:note,代码行数:30,代码来源:UserServiceTestCoded.cs


示例12: GetRequestEnumerator

        public override IEnumerator<WebTestRequest> GetRequestEnumerator()
        {
            ExtractHiddenFields defaultExtractionRule = AssertAndValidationHelper.GetDefaultExtractHiddenFields();
            
            //Upload a new package.   
            string packageId = this.Name + DateTime.Now.Ticks.ToString();
            string version = "1.0.0";
            AssertAndValidationHelper.UploadNewPackageAndVerify(packageId, version);

            //Do initial login to be able to perform edit.
            WebTestRequest logonGet = AssertAndValidationHelper.GetLogonGetRequest();
            yield return logonGet;
            logonGet = null;
            WebTestRequest logonPost = AssertAndValidationHelper.GetLogonPostRequest(this);
            yield return logonPost;
            logonPost = null;

            WebTestRequest uploadRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl);
            yield return uploadRequest;
            if (this.LastResponse.ResponseUri.ToString().Contains("verify-upload"))
            {
                WebTestRequest cancelGet = AssertAndValidationHelper.GetCancelGetRequest();
                yield return cancelGet;
                cancelGet = null;
                uploadRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl);
                yield return uploadRequest;
            }
            uploadRequest = null;

            // The API key is part of the nuget.config file that is present under the solution dir.
            string packageFullPath = PackageCreationHelper.CreatePackage(packageId);

            WebTestRequest uploadPostRequest = AssertAndValidationHelper.GetUploadPostRequestForPackage(this, packageFullPath);
            yield return uploadPostRequest;
            uploadPostRequest = null;

            WebTestRequest verifyUploadRequest = new WebTestRequest(UrlHelper.VerifyUploadPageUrl);
            yield return verifyUploadRequest;
            verifyUploadRequest = null;

            WebTestRequest verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(this, packageId, "1.0.0");
            yield return verifyUploadPostRequest;
            verifyUploadPostRequest = null;

            WebTestRequest verifyEditRequest = AssertAndValidationHelper.GetEditGetRequestForPackage(packageId, "1.0.0");
            verifyEditRequest.ExtractValues += new EventHandler<ExtractionEventArgs>(defaultExtractionRule.Extract);
            yield return verifyEditRequest;
            verifyEditRequest = null;

            // TO DO:  Post isn't weorking and I need to investigate why.  I'll investigate more later, but the current verification is still 
            // useful in the meantime. [clayco 11/13/2013]
            WebTestRequest verifyEditPostRequest = AssertAndValidationHelper.GetEditPackagePostRequest(this, packageId, "1.0.0", description: "This is a new description.");
            ValidationRuleFindText newDescriptionValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText(@"This is a new description.");
            //ValidationRuleFindText pendingEditValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText(@"An edit is pending for this package version. You are seeing the <em>edited</em> package description now.");
            verifyEditPostRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(newDescriptionValidationRule.Validate);
            //verifyEditPostRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(pendingEditValidationRule.Validate);
            yield return verifyEditPostRequest;
            verifyEditPostRequest = null;
        }
开发者ID:SaqibS,项目名称:NuGetGallery,代码行数:59,代码来源:EditPackageTest.cs


示例13: GetRequestEnumerator

 public override IEnumerator<WebTestRequest> GetRequestEnumerator()
 {
     // Send a request to home page and check for default home page text.
     var homePageRequest = new WebTestRequest(UrlHelper.BaseUrl);
     var homePageTextValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.HomePageText);
     homePageRequest.ValidateResponse += homePageTextValidationRule.Validate;
     yield return homePageRequest;
 }
开发者ID:ZhiYuanHuang,项目名称:NuGetGallery,代码行数:8,代码来源:HomePageValidationTest.cs


示例14: GetRequestEnumerator

 public override IEnumerator<WebTestRequest> GetRequestEnumerator()
 {
     //send a request to home page and check for default home page text.
     WebTestRequest homePageRequest = new WebTestRequest(UrlHelper.BaseUrl);           
     ValidationRuleFindText homePageTextValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText(Constants.HomePageText);               
     homePageRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(homePageTextValidationRule.Validate);         
     yield return homePageRequest;
     homePageRequest = null;          
 }
开发者ID:jonstelly,项目名称:NuGetGallery,代码行数:9,代码来源:HomePageValidationTest.cs


示例15: GetRequestEnumerator

 public override IEnumerator<WebTestRequest> GetRequestEnumerator()
 {            
     WebTestRequest uploadPackageRequest = new WebTestRequest(UrlHelper.UploadPageUrl);
     uploadPackageRequest.ExpectedResponseUrl = UrlHelper.LogonPageUrlOnPackageUpload;
     ValidateHtmlTagInnerText logOnFormValidationRule = AssertAndValidationHelper.GetValidationRuleForHtmlTagInnerText(HtmlTextWriterTag.Label.ToString(), HtmlTextWriterAttribute.For.ToString(), "SignIn_UserNameOrEmail", "Username or Email");               
     uploadPackageRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(logOnFormValidationRule.Validate);          
     yield return uploadPackageRequest;
     uploadPackageRequest = null;
 }
开发者ID:segilbert,项目名称:NuGetGallery,代码行数:9,代码来源:UploadPackageWithoutLoginTest.cs


示例16: GetRequestEnumerator

        public override IEnumerator<WebTestRequest> GetRequestEnumerator()
        {
            // Инициализация правил проверки, применяемых ко всем запросам в веб-тесте
            if ((this.Context.ValidationLevel >= Microsoft.VisualStudio.TestTools.WebTesting.ValidationLevel.Low))
            {
                ValidateResponseUrl validationRule1 = new ValidateResponseUrl();
                this.ValidateResponse += new EventHandler<ValidationEventArgs>(validationRule1.Validate);
            }
            if ((this.Context.ValidationLevel >= Microsoft.VisualStudio.TestTools.WebTesting.ValidationLevel.Low))
            {
                ValidationRuleResponseTimeGoal validationRule2 = new ValidationRuleResponseTimeGoal();
                validationRule2.Tolerance = 0D;
                this.ValidateResponseOnPageComplete += new EventHandler<ValidationEventArgs>(validationRule2.Validate);
            }

            WebTestRequest request1 = new WebTestRequest("http://localhost:2489/");
            yield return request1;
            request1 = null;

            WebTestRequest request2 = new WebTestRequest("http://localhost:2489/Account/Login");
            request2.ThinkTime = 9;
            ExtractHiddenFields extractionRule1 = new ExtractHiddenFields();
            extractionRule1.Required = true;
            extractionRule1.HtmlDecode = true;
            extractionRule1.ContextParameterName = "1";
            request2.ExtractValues += new EventHandler<ExtractionEventArgs>(extractionRule1.Extract);
            yield return request2;
            request2 = null;

            WebTestRequest request3 = new WebTestRequest("http://localhost:2489/Account/Login");
            request3.ThinkTime = 13;
            request3.Method = "POST";
            request3.ExpectedResponseUrl = GetExpectedReturnUrl();
            FormPostHttpBody request3Body = new FormPostHttpBody();
            request3Body.FormPostParameters.Add("__RequestVerificationToken", this.Context["$HIDDEN1.__RequestVerificationToken"].ToString());
            request3Body.FormPostParameters.Add("Email", this.Context["LogInTestData.LogInTestData#csv.Login"].ToString());
            request3Body.FormPostParameters.Add("Password", this.Context["LogInTestData.LogInTestData#csv.Password"].ToString());
            request3Body.FormPostParameters.Add("RememberMe", this.Context["$HIDDEN1.RememberMe"].ToString());
            request3.Body = request3Body;
            if ((this.Context.ValidationLevel >= Microsoft.VisualStudio.TestTools.WebTesting.ValidationLevel.High))
            {
                ValidationRuleFindText validationRule3 = new ValidationRuleFindText();
                validationRule3.FindText = this.Context["LogInTestData.LogInTestData#csv.Text"].ToString();
                validationRule3.IgnoreCase = false;
                validationRule3.UseRegularExpression = false;
                validationRule3.PassIfTextFound = true;
                request3.ValidateResponse += new EventHandler<ValidationEventArgs>(validationRule3.Validate);
            }
            ExtractHiddenFields extractionRule2 = new ExtractHiddenFields();
            extractionRule2.Required = true;
            extractionRule2.HtmlDecode = true;
            extractionRule2.ContextParameterName = "1";
            request3.ExtractValues += new EventHandler<ExtractionEventArgs>(extractionRule2.Extract);
            yield return request3;
            request3 = null;
        }
开发者ID:rsemenov,项目名称:unicoV2,代码行数:56,代码来源:LogInWebTestCoded.cs


示例17: GetRequestEnumerator

        public override IEnumerator<WebTestRequest> GetRequestEnumerator()
        {
            ExtractHiddenFields defaultExtractionRule = AssertAndValidationHelper.GetDefaultExtractHiddenFields();

            //Do initial login
            WebTestRequest logonGet = AssertAndValidationHelper.GetLogonGetRequest();
            yield return logonGet;
            logonGet = null;

            WebTestRequest logonPost = AssertAndValidationHelper.GetLogonPostRequest(this);
            yield return logonPost;
            logonPost = null;

            WebTestRequest uploadRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl);
            yield return uploadRequest;
            if (this.LastResponse.ResponseUri.ToString().Contains("verify-upload"))
            {
                WebTestRequest cancelGet = AssertAndValidationHelper.GetCancelGetRequest();
                yield return cancelGet;
                cancelGet = null;
                uploadRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl);
                yield return uploadRequest;
            }
            uploadRequest = null;

            string packageId = DateTime.Now.Ticks.ToString();
            string packageFullPath = PackageCreationHelper.CreatePackage(packageId);

            WebTestRequest uploadPostRequest = AssertAndValidationHelper.GetUploadPostRequestForPackage(this, packageFullPath);
            yield return uploadPostRequest;
            uploadPostRequest = null;

            WebTestRequest verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(this, packageId, "1.0.0");
            yield return verifyUploadPostRequest;
            verifyUploadPostRequest = null; 

            System.Threading.Thread.Sleep(60000);
            WebTestRequest packageRequest = new WebTestRequest(UrlHelper.GetPackagePageUrl(packageId));    
            ValidationRuleFindText findTextRule = AssertAndValidationHelper.GetValidationRuleForFindText("Contact Us");
            packageRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(findTextRule.Validate);
            yield return packageRequest;
            packageRequest = null;

            // Log off
            WebTestRequest logOffGet = AssertAndValidationHelper.GetLogOffGetRequest();
            yield return logOffGet;
            logOffGet = null;

            packageRequest = new WebTestRequest(UrlHelper.GetPackagePageUrl(packageId));
            //Rule to check manage my packages contains a html link to the newly uploaded package.     
            ValidationRuleFindText reportAbuseValidationRule = AssertAndValidationHelper.GetValidationRuleForFindText("Report Abuse");
            packageRequest.ValidateResponse += new EventHandler<ValidationEventArgs>(reportAbuseValidationRule.Validate);
            yield return packageRequest;
            packageRequest = null;   

        }
开发者ID:kl4w,项目名称:NuGetGallery,代码行数:56,代码来源:ContactUsAndReportAbuseLinkTest.cs


示例18: GetRequestEnumerator

 public override IEnumerator<WebTestRequest> GetRequestEnumerator()
 {
     WebTestRequest request1 = new WebTestRequest("http://simple-service.cloudapp.net//Service/Service.svc/simpleService/sayHello");
     string user = "ELS";
     request1.Timeout = 5;
     request1.ExpectedHttpStatusCode = 200;
     request1.QueryStringParameters.Add("name", user, false, false);
     yield return request1;
     request1 = null;
 }
开发者ID:Grassman,项目名称:simple-service,代码行数:10,代码来源:WebTest1Coded.cs


示例19: PingWebTestConfiguration

 public PingWebTestConfiguration(string url, int? expectedHttpStatusCode = 200)
 {
     _webTest = new DeclarativeWebTest { Proxy = "default" };
     var webTestRequest = new WebTestRequest(url)
     {
         ExpectedHttpStatusCode = expectedHttpStatusCode == null ? 0 : expectedHttpStatusCode.Value,
         IgnoreHttpStatusCode = expectedHttpStatusCode == null
     };
     _webTest.Items.Add(webTestRequest);
 }
开发者ID:cnq,项目名称:insights-poc,代码行数:10,代码来源:PingWebTestConfiguration.cs


示例20: GetWebRequestForAggregateStats

        private WebTestRequest GetWebRequestForAggregateStats()
        {
            //send a request to the stats/totals.
            WebTestRequest statsRequestBeforeDownload = new WebTestRequest(UrlHelper.AggregateStatsPageUrl);
            //Extract the download count value from the response.
            ExtractText extractDownLoadCount = GetExtractionRuleForDownloadCount();
            statsRequestBeforeDownload.ExtractValues += new EventHandler<ExtractionEventArgs>(extractDownLoadCount.Extract);
            return statsRequestBeforeDownload;

        }
开发者ID:henrycomein,项目名称:NuGetGallery,代码行数:10,代码来源:AggregateStatsAfterDownload.cs



注:本文中的WebTestRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# WebView类代码示例发布时间:2022-05-24
下一篇:
C# WebSortOrder类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap