本文整理汇总了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());
}
示例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);
}
示例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));
}
示例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));
}
示例5: ExecuteInternal
protected override BrowserResponse ExecuteInternal(Browser browser)
{
return browser.Delete(Path, OnContext);
}
示例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();
}
示例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();
}
示例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);
}
示例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));
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}