本文整理汇总了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);
}
示例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);
}
}
示例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);
}
示例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;
}
}
示例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);
}