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


C# AdminController.Delete方法代码示例

本文整理汇总了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));
        }
开发者ID:KuuuPER,项目名称:RussianTeaClubSite,代码行数:15,代码来源:UnitTest1.cs

示例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));
 }
开发者ID:TimHanes,项目名称:OB,代码行数:19,代码来源:AdminTests.cs

示例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));
 }
开发者ID:kademat,项目名称:FoodStore,代码行数:19,代码来源:AdminTests.cs


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