当前位置: 首页>>代码示例>>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;未经允许,请勿转载。