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


C# Browser.Delete方法代码示例

本文整理汇总了C#中Nancy.Testing.Browser.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# Browser.Delete方法的具体用法?C# Browser.Delete怎么用?C# Browser.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nancy.Testing.Browser的用法示例。


在下文中一共展示了Browser.Delete方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: can_delete_a_book

        public void can_delete_a_book()
        {
            var bootstrapper = new DefaultNancyBootstrapper();
            var browser = new Browser(bootstrapper);
            var result = browser.Delete("/books/destroy/1", with => with.HttpRequest());

            Assert.AreEqual(HttpStatusCode.OK.ToString(), result.StatusCode.ToString());
        }
开发者ID:shawnewallace,项目名称:r-and-d,代码行数:8,代码来源:Class1.cs

示例2: TestNotFound

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

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

            //Assert
            Assert.AreEqual (HttpStatusCode.MethodNotAllowed, result.StatusCode);
        }
开发者ID:rlbisbe,项目名称:nancyfxfromsinatra,代码行数:14,代码来源:RoutesTest.cs

示例3: AppReturnsBadRequestWhenCancelingPaidOrder

        public void AppReturnsBadRequestWhenCancelingPaidOrder()
        {
            var app = new Browser(new Bootstrapper());

              var createdResponse = CreatedOrder(app);
              var orderPath = GetOrderPath(createdResponse);

              var paymentResponse = app.Post(orderPath + "/payment/",
                                     with =>
                                     {
                                       with.HttpRequest();
                                       var xmlString = new PaymentRepresentation { CardNumber = "321", CardOwner = "Jose" }.ToXmlString();
                                       with.Body(xmlString);
                                     });
              Assert.That(paymentResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));

              var cancelResponse = app.Delete(orderPath);
              Assert.That(cancelResponse.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
        }
开发者ID:grahamrhay,项目名称:Restbucks-on-Nancy,代码行数:19,代码来源:IntegrationSmokeTests.cs

示例4: AppCanCreateAndDeleteOrder

        public void AppCanCreateAndDeleteOrder()
        {
            var app = new Browser(new Bootstrapper());

              var createdResponse = CreatedOrder(app);

              Assert.That(createdResponse.StatusCode, Is.EqualTo(HttpStatusCode.Created));
              Assert.That(createdResponse.Headers.Keys, Contains.Item("Location"));

              var orderPath = GetOrderPath(createdResponse);

              var getOrderResponse = app.Get(orderPath);
              Assert.That(getOrderResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK), string.Format("order at {0} not found", orderPath));

              var deletedResponse = app.Delete(orderPath);
              Assert.That(deletedResponse.StatusCode, Is.EqualTo(HttpStatusCode.NoContent));

              var getDeletedOrderResponse = app.Get(orderPath);
              Assert.That(getDeletedOrderResponse.StatusCode, Is.EqualTo(HttpStatusCode.MovedPermanently));
        }
开发者ID:grahamrhay,项目名称:Restbucks-on-Nancy,代码行数:20,代码来源:IntegrationSmokeTests.cs

示例5: ExecuteInternal

 protected override BrowserResponse ExecuteInternal(Browser browser)
 {
     return browser.Delete(Path, OnContext);
 }
开发者ID:jbrahy,项目名称:derp.sales,代码行数:4,代码来源:UserAgent.cs

示例6: TestDeleteDefaultGraph

 public void TestDeleteDefaultGraph()
 {
     var mockJobInfo = new Mock<IJobInfo>();
     mockJobInfo.Setup(m => m.JobCompletedOk).Returns(true);
     IEnumerable<string> graphs = new string[] { "http://example.org/g1", "http://example.org/g2" };
     var brightstar = new Mock<IBrightstarService>();
     brightstar.Setup(s => s.DoesStoreExist("foo")).Returns(true).Verifiable();
     brightstar.Setup(s => s.ExecuteUpdate("foo", "DROP DEFAULT", true, "Drop Default Graph"))
         .Returns(mockJobInfo.Object).Verifiable();
     var app = new Browser(new FakeNancyBootstrapper(brightstar.Object));
     var response = app.Delete("foo/graphs", with => with.Query("default", ""));
     Assert.That(response, Is.Not.Null);
     Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NoContent));
     brightstar.Verify();
 }
开发者ID:jaensen,项目名称:BrightstarDB,代码行数:15,代码来源:GraphsUrlSpec.cs

示例7: TestDeleteUnknownNamedGraphReturnsNotFound

 public void TestDeleteUnknownNamedGraphReturnsNotFound()
 {
     IEnumerable<string> graphs = new string[] {"http://example.org/g1", "http://example.org/g2"};
     var brightstar = new Mock<IBrightstarService>();
     brightstar.Setup(s => s.DoesStoreExist("foo")).Returns(true).Verifiable();
     brightstar.Setup(s => s.ListNamedGraphs("foo")).Returns(graphs).Verifiable();
     var app = new Browser(new FakeNancyBootstrapper(brightstar.Object));
     var response = app.Delete("foo/graphs", with => with.Query("graph", "http://example.org/g"));
     Assert.That(response, Is.Not.Null);
     Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
     brightstar.Verify();
 }
开发者ID:jaensen,项目名称:BrightstarDB,代码行数:12,代码来源:GraphsUrlSpec.cs

示例8: DeleteCorporation_ShouldReturn200

        public void DeleteCorporation_ShouldReturn200()
        {
            var boostrapper = new Bootstrapper();
            var browser = new Browser(boostrapper, to => to.Accept("application/json"));
            var response = browser.Delete(@"http://localhost:59536/DeleteCorporation/564db279b99f725971d81658", with =>
            {
                with.HttpRequest();
                with.Accept(new MediaRange("application/json"));
            });

            var x = response.ReasonPhrase;

            Assert.AreEqual(Nancy.HttpStatusCode.OK, response.StatusCode);
        }
开发者ID:Koaleo,项目名称:IntegrationSpike,代码行数:14,代码来源:RepositoryTest.cs

示例9: TestDeleteRequiresStoreAdminPermission

        public void TestDeleteRequiresStoreAdminPermission()
        {
            var brightstar = new Mock<IBrightstarService>();
            var storePermissions = new Mock<AbstractStorePermissionsProvider>();

            storePermissions.Setup(s => s.HasStorePermission(null, "foo", StorePermissions.Admin)).Returns(false).Verifiable();
            var app = new Browser(new FakeNancyBootstrapper(brightstar.Object, storePermissions.Object));

            // Execute
            var response = app.Delete("/foo");

            // Assert
            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized));
        }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:14,代码来源:StoreUrlSpec.cs

示例10: TestDeleteHtmlResponse

        public void TestDeleteHtmlResponse()
        {
            var brightstar = new Mock<IBrightstarService>();
            brightstar.Setup(s=>s.DoesStoreExist("foo")).Returns(true).Verifiable();
            brightstar.Setup(s => s.DeleteStore("foo")).Verifiable();
            var app = new Browser(new FakeNancyBootstrapper(brightstar.Object));

            var response = app.Delete("/foo", c => c.Accept(MediaRange.FromString("text/html")));

            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
            Assert.That(response.Body.AsString(), Contains.Substring("Store 'foo' deleted successfully."));
            brightstar.Verify();
            
        }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:14,代码来源:StoreUrlSpec.cs

示例11: TestDeleteReturnsOk

        public void TestDeleteReturnsOk()
        {
            var brightstar = new Mock<IBrightstarService>();
            brightstar.Setup(s=>s.DoesStoreExist("foo")).Returns(true).Verifiable();
            brightstar.Setup(s=>s.DeleteStore("foo")).Verifiable();
            var app = new Browser(new FakeNancyBootstrapper(brightstar.Object));

            var response = app.Delete("/foo", c=>c.Accept(MediaRange.FromString("application/json")));

            Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
            brightstar.Verify();
        }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:12,代码来源:StoreUrlSpec.cs

示例12: Should_Return_Unauthorized_If_InvalidUser_Deleting

        public void Should_Return_Unauthorized_If_InvalidUser_Deleting()
        {
            var fakePostRepository = new Mock<IPostRepository>();
            fakePostRepository.Setup(x => x.Delete(It.IsAny<int>())).Returns(false);

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

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

            Assert.Equal(HttpStatusCode.Unauthorized, result.StatusCode);
        }
开发者ID:chenzuo,项目名称:MicroBlog,代码行数:20,代码来源:BlogModuleTest.cs

示例13: Should_Return_ServerError_If_Cannot_Delete

        public void Should_Return_ServerError_If_Cannot_Delete()
        {
            var fakePostRepository = new Mock<IPostRepository>();
            fakePostRepository.Setup(x => x.Delete(It.IsAny<int>())).Returns(false);

            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.Delete("/999", with =>
            {
                with.HttpRequest();
                with.FormValue("Content", "Test Content");
            });

            Assert.Equal(HttpStatusCode.InternalServerError, result.StatusCode);
        }
开发者ID:chenzuo,项目名称:MicroBlog,代码行数:24,代码来源:BlogModuleTest.cs


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