本文整理汇总了C#中AdminController.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# AdminController.Delete方法的具体用法?C# AdminController.Delete怎么用?C# AdminController.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdminController
的用法示例。
在下文中一共展示了AdminController.Delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanDeleteArticle
public void CanDeleteArticle()
{
var articleIds = GetArticleIds();
var mock = new Mock<IArticleRepository>();
mock.Setup(m => m.Articles).Returns(GetArticles(articleIds));
var controller = new AdminController(mock.Object);
var deletedArticleId = articleIds[3];
controller.Delete(deletedArticleId);
mock.Verify(m => m.DeleteArticle(deletedArticleId));
}
示例2: Can_Delete_Valid_Clients
public void Can_Delete_Valid_Clients()
{
// Arrange - create a client
Client cl = new Client { ClientId = 2, ContractNumber = "Test" };
// Arrange - create the mock repository
Mock<IClientRepository> mock = new Mock<IClientRepository>();
mock.Setup(m => m.Clients).Returns(new Client[] {
new Client {ClientId = 1, ContractNumber = "L1"},
cl,
new Client {ClientId = 3, ContractNumber = "L3"},
}.AsQueryable());
// Arrange - create the controller
AdminController target = new AdminController(mock.Object);
// Act - delete the client
target.Delete(cl.ClientId);
// Assert - ensure that the repository delete method was
// called with the correct client
mock.Verify(m => m.DeleteClient(cl.ClientId));
}
示例3: Can_Delete_Valid_Products
public void Can_Delete_Valid_Products()
{
// Arrange - create a Product
Product prod = new Product { ProductID = 2, Name = "Test" };
// Arrange - create the mock repository
Mock<IProductRepository> mock = new Mock<IProductRepository>();
mock.Setup(m => m.Products).Returns(new Product[] {
new Product {ProductID = 1, Name = "P1"},
prod,
new Product {ProductID = 3, Name = "P3"},
});
// Arrange - create the controller
AdminController target = new AdminController(mock.Object);
// Act - delete the product
target.Delete(prod.ProductID);
// Assert - ensure that the repository delete method was
// called with the correct Product
mock.Verify(m => m.DeleteProduct(prod.ProductID));
}