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


C# AdminController.Edit方法代码示例

本文整理汇总了C#中AdminController.Edit方法的典型用法代码示例。如果您正苦于以下问题:C# AdminController.Edit方法的具体用法?C# AdminController.Edit怎么用?C# AdminController.Edit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AdminController的用法示例。


在下文中一共展示了AdminController.Edit方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CanEditArticle

        public void CanEditArticle()
        {
            var articleIds = GetArticleIds();

            var mock = new Mock<IArticleRepository>();
            mock.Setup(m => m.Articles).Returns(GetArticles(articleIds));

            var controller = new AdminController(mock.Object);

            var article1 = controller.Edit(articleIds[0]).ViewData.Model as Article;
            var article2 = controller.Edit(articleIds[1]).ViewData.Model as Article;
            var article3 = controller.Edit(articleIds[2]).ViewData.Model as Article;

            Assert.AreEqual(articleIds[0], article1.ArticleId);
            Assert.AreEqual(articleIds[1], article2.ArticleId);
            Assert.AreEqual(articleIds[2], article3.ArticleId);
        }
开发者ID:KuuuPER,项目名称:RussianTeaClubSite,代码行数:17,代码来源:UnitTest1.cs

示例2: Cannot_Edit_Nonexistent_Client

 public void Cannot_Edit_Nonexistent_Client()
 {
     // 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"},
     new Client {ClientId = 2, ContractNumber = "L2"},
     new Client {ClientId = 3, ContractNumber = "L3"},
       }.AsQueryable());
     // Arrange - create the controller
     AdminController target = new AdminController(mock.Object);
     // Act
     Client result = (Client)target.Edit(4).ViewData.Model;
     // Assert
     Assert.IsNull(result);
 }
开发者ID:TimHanes,项目名称:OB,代码行数:16,代码来源:AdminTests.cs

示例3: Cannot_Save_Invalid_Changes

 public void Cannot_Save_Invalid_Changes()
 {
     // Arrange - create mock repository
     Mock<IClientRepository> mock = new Mock<IClientRepository>();
     // Arrange - create the controller
     AdminController target = new AdminController(mock.Object);
     // Arrange - create a client
     Client client = new Client { ContractNumber = "Test" };
     // Arrange - add an error to the model state
     target.ModelState.AddModelError("error", "error");
     // Act - try to save the client
     ActionResult result = target.Edit(client);
     // Assert - check that the repository was not called
     mock.Verify(m => m.SaveClient(It.IsAny<Client>()), Times.Never());
     // Assert - check the method result type
     Assert.IsInstanceOfType(typeof(ViewResult), result);
 }
开发者ID:TimHanes,项目名称:OB,代码行数:17,代码来源:AdminTests.cs

示例4: Cannot_Save_Invalid_Changes

 public void Cannot_Save_Invalid_Changes()
 {
     // Arrange - create mock repository
     Mock<IProductRepository> mock = new Mock<IProductRepository>();
     // Arrange - create the controller
     AdminController target = new AdminController(mock.Object);
     // Arrange - create a product
     Product product = new Product {Name = "Test"};
     // Arrange - add an error to the model state
     target.ModelState.AddModelError("error", "error");
     // Act - try to save the product
     ActionResult result = target.Edit(product);
     // Assert - check that the repository was not called
     mock.Verify(m => m.SaveProduct(It.IsAny<Product>()), Times.Never());
     // Assert - check the method result type
     Assert.IsInstanceOfType(result, typeof (ViewResult));
 }
开发者ID:kademat,项目名称:FoodStore,代码行数:17,代码来源:AdminTests.cs

示例5: Cannot_Edit_Nonexistent_Product

 public void Cannot_Edit_Nonexistent_Product()
 {
     // 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"},
         new Product {ProductID = 2, Name = "P2"},
         new Product {ProductID = 3, Name = "P3"},
     });
     // Arrange - create the controller
     AdminController target = new AdminController(mock.Object);
     // Act
     Product result = (Product) target.Edit(4).ViewData.Model;
     // Assert
     Assert.IsNull(result);
 }
开发者ID:kademat,项目名称:FoodStore,代码行数:17,代码来源:AdminTests.cs

示例6: CannotEditNonexistenceArticle

        public void CannotEditNonexistenceArticle()
        {
            var articleIds = GetArticleIds();

            var mock = new Mock<IArticleRepository>();
            mock.Setup(m => m.Articles).Returns(GetArticles(articleIds));

            var controller = new AdminController(mock.Object);

            var result = controller.Edit(Guid.Parse("E3D32116-62DF-4830-8005-CAEEB6D34892")).ViewData.Model as Article;

            Assert.IsNull(result);
        }
开发者ID:KuuuPER,项目名称:RussianTeaClubSite,代码行数:13,代码来源:UnitTest1.cs

示例7: Can_Edit_Client

 public void Can_Edit_Client()
 {
     // 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"},
     new Client {ClientId = 2, ContractNumber = "L2"},
     new Client {ClientId = 3, ContractNumber = "L3"}
       }.AsQueryable());
     // Arrange - create the controller
     AdminController target = new AdminController(mock.Object);
     // Act
     Client l1 = target.Edit(1).ViewData.Model as Client;
     Client l2 = target.Edit(2).ViewData.Model as Client;
     Client l3 = target.Edit(3).ViewData.Model as Client;
     // Assert
     Assert.AreEqual(1, l1.ClientId);
     Assert.AreEqual(2, l2.ClientId);
     Assert.AreEqual(3, l3.ClientId);
 }
开发者ID:TimHanes,项目名称:OB,代码行数:20,代码来源:AdminTests.cs

示例8: Can_Save_Valid_Changes

        public void Can_Save_Valid_Changes()
        {
            // Arrange - create mock repository
            Mock<IClientRepository> mock = new Mock<IClientRepository>();
            // Arrange - create the controller
            AdminController target = new AdminController(mock.Object);
            // Arrange - create a client
            Client client = new Client { ContractNumber = "Test" };
            // Act - try to save the client
            ActionResult result = target.Edit(client);
            // Assert - check that the repository was called
            mock.Verify(m => m.SaveClient(client));
            // Assert - check the method result type

            Assert.IsNotInstanceOfType( typeof(ViewResult), result);
        }
开发者ID:TimHanes,项目名称:OB,代码行数:16,代码来源:AdminTests.cs

示例9: Can_Edit_Product

 public void Can_Edit_Product()
 {
     // 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"},
         new Product {ProductID = 2, Name = "P2"},
         new Product {ProductID = 3, Name = "P3"},
     });
     // Arrange - create the controller
     AdminController target = new AdminController(mock.Object);
     // Act
     Product p1 = target.Edit(1).ViewData.Model as Product;
     Product p2 = target.Edit(2).ViewData.Model as Product;
     Product p3 = target.Edit(3).ViewData.Model as Product;
     // Assert
     Assert.AreEqual(1, p1.ProductID);
     Assert.AreEqual(2, p2.ProductID);
     Assert.AreEqual(3, p3.ProductID);
 }
开发者ID:kademat,项目名称:FoodStore,代码行数:21,代码来源:AdminTests.cs

示例10: Can_Save_Valid_Changes

 public void Can_Save_Valid_Changes()
 {
     // Arrange - create mock repository
     Mock<IProductRepository> mock = new Mock<IProductRepository>();
     // Arrange - create the controller
     AdminController target = new AdminController(mock.Object);
     // Arrange - create a product
     Product product = new Product {Name = "Test"};
     // Act - try to save the product
     ActionResult result = target.Edit(product);
     // Assert - check that the repository was called
     mock.Verify(m => m.SaveProduct(product));
     // Assert - check the method result type
     Assert.IsNotInstanceOfType(result, typeof (ViewResult));
 }
开发者ID:kademat,项目名称:FoodStore,代码行数:15,代码来源:AdminTests.cs


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