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