本文整理汇总了C#中System.Net.WebClient.Should方法的典型用法代码示例。如果您正苦于以下问题:C# WebClient.Should方法的具体用法?C# WebClient.Should怎么用?C# WebClient.Should使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.WebClient
的用法示例。
在下文中一共展示了WebClient.Should方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FakeServer_ExpectGetReturnsString_ResponseMatchesExpectation
public void FakeServer_ExpectGetReturnsString_ResponseMatchesExpectation()
{
const string expectedResult = "Some String Data";
const string url = "/some-url";
using (var fakeServer = new FakeServer())
{
fakeServer.Expect.Get(url).Returns(expectedResult);
fakeServer.Start();
var baseAddress = fakeServer.BaseUri;
var result = new WebClient().DownloadString(new Uri(baseAddress + url));
result.Should().Be(expectedResult);
}
}
示例2: FakeServer_ExpectDeleteReturnsString_ResponseMatchesExpectation
public void FakeServer_ExpectDeleteReturnsString_ResponseMatchesExpectation()
{
const string expectedResult = "Some String Data";
const string baseAddress = "http://localhost:12354";
const string url = "/some-url";
using (var fakeServer = new FakeServer(12354))
{
fakeServer.Expect.Delete(url).Returns(expectedResult);
fakeServer.Start();
var result = new WebClient().UploadString(new Uri(baseAddress + url), "DELETE", string.Empty);
result.Should().Be(expectedResult);
}
}
示例3: FakeServer_ExpectGetWithQueryParametersReturnsString_ResponseMatchesExpectation
public void FakeServer_ExpectGetWithQueryParametersReturnsString_ResponseMatchesExpectation()
{
const string expectedResult = "Some String Data";
const string baseAddress = "http://localhost:12354";
const string url = "/some-url?id=1234";
using (var fakeServer = new FakeServer(12354))
{
fakeServer.Expect.Get(url).Returns(expectedResult);
fakeServer.Start();
var uri = new Uri(baseAddress + url);
var result = new WebClient().DownloadString(uri);
result.Should().Be(expectedResult);
}
}
示例4: FakeServer_ShouldExecuteResponseExpectationCallback_ReturnExpectedData
public void FakeServer_ShouldExecuteResponseExpectationCallback_ReturnExpectedData()
{
const string expectedResult = "Some String Data";
const string baseAddress = "http://localhost:12354";
const string url = "/some-url?id=1234";
using (var fakeServer = new FakeServer(12354))
{
fakeServer.Expect.Get(url).Callback(() => new HttpResponseExpectation(HttpStatusCode.OK, expectedResult));
fakeServer.Start();
var result = new WebClient().DownloadString(new Uri(baseAddress + url));
result.Should().Be(expectedResult);
}
}
示例5: FakeServer_ShouldHandleMultipleRegistrationOnSameEndPoint_WithDifferentBodies_ReturnExpectedData
public void FakeServer_ShouldHandleMultipleRegistrationOnSameEndPoint_WithDifferentBodies_ReturnExpectedData()
{
var expectedResultA = "1234";
var expectedResultB = "5678";
const string baseAddress = "http://localhost:12354";
const string fakeurl = "/some-url";
using (var fakeServer = new FakeServer(12354))
{
fakeServer.Expect.Post(fakeurl, "messageA").Returns(HttpStatusCode.OK, expectedResultA);
fakeServer.Expect.Post(fakeurl, "messageB").Returns(HttpStatusCode.OK, expectedResultB);
fakeServer.Start();
var resultA = new WebClient().UploadString(new Uri(baseAddress + fakeurl), "POST", "messageA");
var resultB = new WebClient().UploadString(new Uri(baseAddress + fakeurl), "POST", "messageB");
resultA.Should().Be(expectedResultA);
resultB.Should().Be(expectedResultB);
}
}
示例6: Should_return_the_resource_by_url
public void Should_return_the_resource_by_url()
{
var page = new WebClient().DownloadString(URL + "js/app.js");
page.Should().Contain("/* Zaz Server Portal */");
}
示例7: Should_return_the_home_page_by_default_url
public void Should_return_the_home_page_by_default_url()
{
var page = new WebClient().DownloadString(URL);
page.Should().Contain("<!-- Zaz Command Bus Portal -->");
}
示例8: should_get_index_html
public void should_get_index_html()
{
var text = new WebClient().DownloadString(RootUrl);
text.Should().NotBeNullOrWhiteSpace();
}
示例9: Then_json_should_contain_Hello_Demis
public void Then_json_should_contain_Hello_Demis()
{
var json = new WebClient().UploadString(SetUpFixture.BasePath + "hello/Demis?format=json", new Hello { Name = "Demis" }.ToJson());
json.Should().Contain(@"""Result"":""Hello, Demis""");
}
开发者ID:JonCanning,项目名称:ServiceStackIntegrationTesting,代码行数:5,代码来源:When_requesting_a_hello_for_Demis.cs