当前位置: 首页>>代码示例>>C#>>正文


C# Browser.Post方法代码示例

本文整理汇总了C#中Browser.Post方法的典型用法代码示例。如果您正苦于以下问题:C# Browser.Post方法的具体用法?C# Browser.Post怎么用?C# Browser.Post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Browser的用法示例。


在下文中一共展示了Browser.Post方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Should_pass_default_headers_in_post_request_when_using_configurable_bootstrapper_ctor

 public void Should_pass_default_headers_in_post_request_when_using_configurable_bootstrapper_ctor()
 {
     // Given
     var sut = new Browser(with => with.Module(this.captureRequestModule), defaults: to => to.Accept(this.expected));
     
     // When
     sut.Post("/");
     
     // Then
     this.captureRequestModule.CapturedRequest.Headers.Accept.First().Item1.ShouldEqual(this.expected);
 }
开发者ID:JulianRooze,项目名称:Nancy,代码行数:11,代码来源:BrowserDefaultsFixture.cs

示例2: FileUploadWorks

 public void FileUploadWorks()
 {
     using (var browser = new Browser())
     {
         var form = new Dictionary<string, object>(2);
         form["Name"] = "bob";
         form["File"] = new FormUpload.FileParameter(
             Encoding.UTF8.GetBytes("Hello World!"),
             "filename.txt",
             "text/plain");
         var formBytes = FormUpload.GetMultipartFormData(form, "boundary");
         var formString = Encoding.UTF8.GetString(formBytes);
         var result = browser.Post("/upload", formString, FormUpload.HttpEncoding + "; boundary=boundary");
         Assert.Equal("file-content=Hello World!;name=bob", result.ResponseText);
     }
 }
开发者ID:bunsen32,项目名称:typed-url-routing,代码行数:16,代码来源:RoutingTests.cs

示例3: Should_not_find_matching_method

        public void Should_not_find_matching_method()
        {
            // Given
            var cache = new FakeRouteCache(with =>
            {
                with.AddGetRoute("/path", "modulekey");
            });

            var bootstrapper = new ConfigurableBootstrapper(with =>
            {
                with.RouteCache(cache);
            });

            var browser = new Browser(bootstrapper);

            // When
            var timer = new Stopwatch();
            timer.Start();

            for (var i = 0; i < numberOfTimesToResolveRoute; i++)
            {
                var result = browser.Post("/path");
                result.StatusCode.ShouldEqual(HttpStatusCode.MethodNotAllowed);
            }

            timer.Stop();

            // Then
            Debug.WriteLine(" took {0} to execute {1} times", timer.Elapsed, numberOfTimesToResolveRoute);
        }
开发者ID:felbus,项目名称:Nancy,代码行数:30,代码来源:DefaultRouteResolverPerformanceFixture.cs

示例4: PostStringResultOrNull

 protected string PostStringResultOrNull(string relativePath, NameValueCollection form)
 {
     using (var browser = new Browser())
     {
         browser.AppendHeader("Accept-Language", "en-GB,en");
         var result = browser.Post("/" + relativePath, form);
         if (result.StatusCode == 404 || result.ResponseText.Contains("The resource cannot be found")) return null;
         Assert.Equal(200, result.StatusCode);
         return result.ResponseText;
     }
 }
开发者ID:bunsen32,项目名称:typed-url-routing,代码行数:11,代码来源:RoutingTests.cs

示例5: Should_pass_default_headers_in_post_request_when_using_inancybootstrapper_ctor

 public async Task Should_pass_default_headers_in_post_request_when_using_inancybootstrapper_ctor()
 {
     // Given
     var bootstrapper = new ConfigurableBootstrapper(with => with.Module(this.captureRequestModule));
     var sut = new Browser(bootstrapper, defaults: to => to.Accept(this.expected));
     
     // When
     await sut.Post("/");
     
     // Then
     this.captureRequestModule.CapturedRequest.Headers.Accept.First().Item1.ShouldEqual(this.expected);
 }
开发者ID:jeremymeng,项目名称:Nancy,代码行数:12,代码来源:BrowserDefaultsFixture.cs


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