當前位置: 首頁>>代碼示例>>C#>>正文


C# Browser.Put方法代碼示例

本文整理匯總了C#中Nancy.Testing.Browser.Put方法的典型用法代碼示例。如果您正苦於以下問題:C# Browser.Put方法的具體用法?C# Browser.Put怎麽用?C# Browser.Put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nancy.Testing.Browser的用法示例。


在下文中一共展示了Browser.Put方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: When_no_email_is_passed

 public When_no_email_is_passed()
 {
     _Api = new Mock<IApiService>(MockBehavior.Strict);
     _Browser = Testing.CreateBrowser<SecuredPagesModule>(with =>
     {
         with.LoggedInUser();
         with.Api(_Api);
     });
     _Response = _Browser.Put("/Sites/testsite/Notifications/Email");
 }
開發者ID:nterry,項目名稱:Apphbify,代碼行數:10,代碼來源:When_no_email_is_passed.cs

示例2: ForRequest_should_return_204_for_request_with_unit_response

        public void ForRequest_should_return_204_for_request_with_unit_response()
        {
            // Given
            var bootstrapper = new Bootstrapper();
            var browser = new Browser(bootstrapper);

            // When
            var result = browser.Put("/testmessage", with => {
                with.HttpRequest();
            });

            // Then
            result.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.NoContent);
        }
開發者ID:dcomartin,項目名稱:Nancy.MediatR,代碼行數:14,代碼來源:EndToEndTests.cs

示例3: TestPut

        public void TestPut()
        {
            //Arrange
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);

            //Act
            var result = browser.Put("/routes", with => {
                with.HttpRequest();
            });

            //Assert
            Assert.AreEqual (HttpStatusCode.OK, result.StatusCode);
            Assert.AreEqual ("Response with Put\n", result.Body.AsString());
        }
開發者ID:rlbisbe,項目名稱:nancyfxfromsinatra,代碼行數:15,代碼來源:RoutesTest.cs

示例4: When_creating_the_hook_fails

        public When_creating_the_hook_fails()
        {
            _Api = new Mock<IApiService>(MockBehavior.Strict);
            _Api.Setup(d => d.CreateServicehook(It.IsAny<string>(), It.IsAny<string>())).Returns(new CreateResult { Status = CreateStatus.Undefined });

            _Browser = Testing.CreateBrowser<SecuredPagesModule>(with =>
            {
                with.LoggedInUser();
                with.Api(_Api);
            });
            _Response = _Browser.Put("/Sites/testsite/Notifications/Email", ctx =>
            {
                ctx.FormValue("email", "[email protected]");
            });
        }
開發者ID:nterry,項目名稱:Apphbify,代碼行數:15,代碼來源:When_creating_the_hook_fails.cs

示例5: ExecuteInternal

 protected override BrowserResponse ExecuteInternal(Browser browser)
 {
     return browser.Put(Path, OnContext);
 }
開發者ID:jbrahy,項目名稱:derp.sales,代碼行數:4,代碼來源:UserAgent.cs

示例6: TestPutUpdatesDefaultGraph

        public void TestPutUpdatesDefaultGraph()
        {
            var mockJobInfo = new Mock<IJobInfo>();
            mockJobInfo.Setup(m => m.JobCompletedOk).Returns(true);
            var brightstar = new Mock<IBrightstarService>();
            brightstar.Setup(s => s.DoesStoreExist("foo")).Returns(true);
            brightstar.Setup(s => s.ExecuteUpdate("foo",
                It.Is<string>(p=>SpaceNormalizedStringsAreEqual(@"DROP SILENT DEFAULT; INSERT DATA { <http://example.org/s> <http://example.org/p> <http://example.org/o> . }", p)),
                true, It.IsAny<string>())).Returns(mockJobInfo.Object).Verifiable();

            var app = new Browser(new FakeNancyBootstrapper(brightstar.Object));
            var response = app.Put("/foo/graphs", with =>
            {
                with.Query("default", "");
                with.Header("Content-Type", RdfFormat.NTriples.MediaTypes.First());
                with.Body("<http://example.org/s> <http://example.org/p> <http://example.org/o> .");
            });
            Assert.That(response, Is.Not.Null);
            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NoContent));
            brightstar.Verify();
        }
開發者ID:jaensen,項目名稱:BrightstarDB,代碼行數:21,代碼來源:GraphsUrlSpec.cs

示例7: AddRealEstate_should_return_201

        public void AddRealEstate_should_return_201()
        {
            var browser = new Browser(cfg =>
            {
                cfg.Module<AddModule>();
                cfg.Dependency<IRepository>(_repositoryMock.Object);
                cfg.Dependency<IAddCorporationManager>(_filterAddManager.Object);
            }, to => to.Accept("application/json"));

            var response = browser.Put(@"http://localhost:59536/AddRealEstate/564db279b99f725971d81658", with =>
            {
                with.HttpRequest();
                with.FormValue("code", "12345");
                with.FormValue("street", "MockStreet");
                with.FormValue("city", "MockCity");
                with.FormValue("state", "MockState");
                with.FormValue("zip", "112345");
                with.Accept(new MediaRange("application/json"));
            });

            var bodyResponse = response.Body.AsString();

            Assert.AreEqual(Nancy.HttpStatusCode.OK, response.StatusCode);
        }
開發者ID:Koaleo,項目名稱:IntegrationSpike,代碼行數:24,代碼來源:RepositoryTest.cs

示例8: UpdateCorporation_ShouldReturn200

        public void UpdateCorporation_ShouldReturn200()
        {
            var browser = new Browser(cfg =>
            {
                cfg.Module<AddModule>();
                cfg.Dependency<IRepository>(_repositoryMock.Object);
                cfg.Dependency<IAddCorporationManager>(_filterAddManager.Object);
            }, to => to.Accept("application/json"));

            var response = browser.Put(@"http://localhost:59536/UpdateCorporation/564db279b99f725971d81658", with =>
            {
                with.HttpRequest();
                with.FormValue("Name", "MockNameUpdated");
                with.Accept(new MediaRange("application/json"));
            });

            var x = response.Body.AsString();
            Assert.AreEqual(Nancy.HttpStatusCode.OK, response.StatusCode);
        }
開發者ID:Koaleo,項目名稱:IntegrationSpike,代碼行數:19,代碼來源:RepositoryTest.cs

示例9: Should_Return_Unauthorized_If_InvalidUser_Updating

        public void Should_Return_Unauthorized_If_InvalidUser_Updating()
        {
            var fakePostRepository = new Mock<IPostRepository>();
            fakePostRepository.Setup(x => x.Update(It.IsAny<Post>())).Returns(Task.FromResult((Post)null));

            var browser = new Browser(
                cfg =>
                {
                    cfg.Module<BlogModule>();
                    cfg.Dependencies<IPostRepository>(fakePostRepository.Object);
                });

            var result = browser.Put("/1", with =>
            {
                with.HttpRequest();
                with.FormValue("Content", "Test Content");
            });

            Assert.Equal(HttpStatusCode.Unauthorized, result.StatusCode);
        }
開發者ID:chenzuo,項目名稱:MicroBlog,代碼行數:20,代碼來源:BlogModuleTest.cs

示例10: Should_Return_ServerError_If_Cannot_Updated

        public void Should_Return_ServerError_If_Cannot_Updated()
        {
            var fakePostRepository = new Mock<IPostRepository>();
            fakePostRepository.Setup(x => x.Update(It.IsAny<Post>())).Returns(Task.FromResult((Post)null));

            var browser = new Browser(
                cfg =>
                {
                    cfg.Module<BlogModule>();
                    cfg.Dependencies<IPostRepository>(fakePostRepository.Object);
                    cfg.RequestStartup((container, pipelines, context) =>
                    {
                        context.CurrentUser = new UserIdentity { UserName = "Test" };
                    });
                });

            var result = browser.Put("/999", with =>
            {
                with.HttpRequest();
                with.FormValue("Content", "Test Content");
            });

            Assert.Equal(HttpStatusCode.InternalServerError, result.StatusCode);
        }
開發者ID:chenzuo,項目名稱:MicroBlog,代碼行數:24,代碼來源:BlogModuleTest.cs

示例11: TestPutCreatesNewNamedGraph

        public void TestPutCreatesNewNamedGraph()
        {
            IEnumerable<string> existingGraphs = new String [] { };
            var mockJobInfo = new Mock<IJobInfo>();
            mockJobInfo.Setup(m => m.JobCompletedOk).Returns(true);
            var brightstar = new Mock<IBrightstarService>();
            brightstar.Setup(s => s.DoesStoreExist("foo")).Returns(true);
            brightstar.Setup(s => s.ListNamedGraphs("foo")).Returns(existingGraphs);
            brightstar.Setup(s => s.ExecuteUpdate("foo",
                @"DROP SILENT GRAPH <http://example.org/g>; INSERT DATA { GRAPH <http://example.org/g> { <http://example.org/s> <http://example.org/p> <http://example.org/o> .
 } }", true, It.IsAny<string>())).Returns(mockJobInfo.Object).Verifiable();

            var app = new Browser(new FakeNancyBootstrapper(brightstar.Object));
            var response = app.Put("/foo/graphs", with =>
            {
                with.Query("graph", "http://example.org/g");
                with.Header("Content-Type", RdfFormat.NTriples.MediaTypes.First());
                with.Body("<http://example.org/s> <http://example.org/p> <http://example.org/o> .");
            });
            Assert.That(response, Is.Not.Null);
            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.Created));
            brightstar.Verify();
        }
開發者ID:jamescoffman23,項目名稱:BrightstarDB,代碼行數:23,代碼來源:GraphsUrlSpec.cs

示例12: TestRequestValidation

        public void TestRequestValidation()
        {
            // given
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper, defaults: to => to.Accept("application/json"));
            ApiBootstrapper.AddOrUpdate("mock", new ApiMock());

            // when incorrect instance request
            var result = browser.Put("notmock/routing/", with =>
            {
                with.Body(string.Empty);
                with.Header("content-type", "application/json");
                with.HttpRequest();
            });

            // then not found
            Assert.AreEqual(HttpStatusCode.NotFound, result.StatusCode);

            // when empty request
            result = browser.Get("mock/routing/", with =>
            {
                with.Body(string.Empty);
                with.Header("content-type", "application/json");
                with.HttpRequest();
            });

            // then not acceptable
            Assert.AreEqual(HttpStatusCode.NotAcceptable, result.StatusCode);

            // when request with incorrect locations.
            result = browser.Get("mock/routing", with =>
            {
                with.Body(string.Empty);
                with.Header("content-type", "application/json");
                with.Query("vehicle", "car");
                with.Query("loc", "1,1");
                with.HttpRequest();
            });

            // then not acceptable
            Assert.AreEqual(HttpStatusCode.NotAcceptable, result.StatusCode);

            // when request with incorrect locations.
            result = browser.Get("mock/routing", with =>
            {
                with.Body(string.Empty);
                with.Header("content-type", "application/json");
                with.Query("vehicle", "car");
                with.Query("loc", "1;1");
                with.HttpRequest();
            });

            // then not acceptable
            Assert.AreEqual(HttpStatusCode.NotAcceptable, result.StatusCode);

            // when request with incorrect locations.
            result = browser.Get("mock/routing", with =>
            {
                with.Body(string.Empty);
                with.Header("content-type", "application/json");
                with.Query("vehicle", "car");
                with.Query("loc", "a,1");
                with.Query("loc", "1,1");
                with.HttpRequest();
            });

            // then not acceptable
            Assert.AreEqual(HttpStatusCode.NotAcceptable, result.StatusCode);

            // when request with incorrect vehicle.
            result = browser.Get("mock/routing", with =>
            {
                with.Body(string.Empty);
                with.Header("content-type", "application/json");
                with.Query("vehicle", "novehiclehere");
                with.Query("loc", "1,1");
                with.Query("loc", "1,1");
                with.HttpRequest();
            });

            // then not acceptable
            Assert.AreEqual(HttpStatusCode.NotAcceptable, result.StatusCode);

            // when request with 0 locations.
            var request = new Domain.Request()
            {
                locations = new double[][] {
                    new double[] {1, 1}
                },
                profile = new Domain.Profile()
                {
                    vehicle = "car"
                }
            };
            result = browser.Get("mock/routing", with =>
            {
                with.JsonBody(request);
                with.HttpRequest();
            });

//.........這裏部分代碼省略.........
開發者ID:nagyistoce,項目名稱:OsmSharp-routing-api,代碼行數:101,代碼來源:RoutingModuleTests.cs


注:本文中的Nancy.Testing.Browser.Put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。