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


C# WebClient.Should方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:shaynevanasperen,项目名称:JustFakeIt,代码行数:17,代码来源:FakeServerScenarios.cs

示例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);
            }
        }
开发者ID:bitoiu,项目名称:JustFakeIt,代码行数:17,代码来源:FakeServerScenarios.cs

示例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);
            }
        }
开发者ID:kate-r,项目名称:JustFakeIt,代码行数:19,代码来源:FakeServerScenarios.cs

示例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);
            }
        }
开发者ID:kate-r,项目名称:JustFakeIt,代码行数:18,代码来源:FakeServerScenarios.cs

示例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);
            }
        }
开发者ID:kate-r,项目名称:JustFakeIt,代码行数:22,代码来源:FakeServerScenarios.cs

示例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 */");
 }
开发者ID:JustApplications,项目名称:zaz,代码行数:5,代码来源:When_connecting_to_server.cs

示例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 -->");
 }
开发者ID:JustApplications,项目名称:zaz,代码行数:5,代码来源:When_connecting_to_server.cs

示例8: should_get_index_html

 public void should_get_index_html()
 {
     var text = new WebClient().DownloadString(RootUrl);
     text.Should().NotBeNullOrWhiteSpace();
 }
开发者ID:mike-tesch,项目名称:Sonarr,代码行数:5,代码来源:IndexHtmlFixture.cs

示例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


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