當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。