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


C# AdminController.Index方法代码示例

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


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

示例1: Index_contains_all_products

        public void Index_contains_all_products()
        {
            var controller = new AdminController(CreateRepositoryMock().Object);

            var result = ((IEnumerable<Product>)controller.Index().ViewData.Model).ToArray();

            Assert.AreEqual(3, result.Length);
            Assert.AreEqual("P1", result[0].Name);
        }
开发者ID:vcaraulean,项目名称:Pro-ASP-NET-MVC-SportsStore,代码行数:9,代码来源:AdminControllerTests.cs

示例2: AdminController_IndexAction_Retuns_Products

        public void AdminController_IndexAction_Retuns_Products()
        {
            //Arrange
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(products.AsQueryable());
            AdminController target = new AdminController(mock.Object);

            //Act
            Product[] result = ((IEnumerable<Product>)target.Index().Model).ToArray();

            //Assert
            Assert.AreEqual(6, result.Length);
            Assert.AreEqual(1, result[0].ProductID);
        }
开发者ID:najamsk,项目名称:SportsStore,代码行数:14,代码来源:AdminControllerTest.cs

示例3: Index_Contains_All_Products

 public void Index_Contains_All_Products()
 {
     var mock = new Mock<IProductRepository>();
     mock.Setup(x => x.Products).Returns(new List<Product>
     {
         new Product {Name = "P1", ProductId = 1, Category = "Apples"},
         new Product {Name = "P2", ProductId = 2, Category = "Apples"},
         new Product {Name = "P3", ProductId = 3, Category = "Plum"},
     });
     var target = new AdminController(mock.Object);
     var result = (target.Index().ViewData.Model as IEnumerable<Product>).ToArray();
     Assert.AreEqual(result.Length, 3);
     Assert.AreEqual(result[0].Name, "P1");
     Assert.AreEqual(result[1].Name, "P2");
     Assert.AreEqual(result[2].Name, "P3");
 }
开发者ID:trupak,项目名称:SportsStore,代码行数:16,代码来源:AdminTests.cs

示例4: Index_Contains_All_Products

        public void Index_Contains_All_Products()
        {
            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"},
            }.AsQueryable());
            AdminController target = new AdminController(mock.Object);

            Product[] result = ((IEnumerable<Product>)target.Index().ViewData.Model).ToArray();

            Assert.AreEqual(result.Length, 3);
            Assert.AreEqual("P1", result[0].Name);
            Assert.AreEqual("P2", result[1].Name);
            Assert.AreEqual("P3", result[2].Name);
        }
开发者ID:pavlove,项目名称:SportsStore,代码行数:17,代码来源:AdminTests.cs

示例5: Index_Contains_All_Products

        public void Index_Contains_All_Products()
        {
            //Arrange create repository
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(p => p.Products).Returns(new Product[]
                {
                    new Product {ProductID = 1, Name = "P1"},
                    new Product {ProductID = 2, Name = "P2"},
                    new Product {ProductID = 3, Name = "P3"},               
                
                });
            AdminController controller = new AdminController(mock.Object);
            Product[] result = ((IEnumerable<Product>)controller.Index().Model).ToArray();


            Assert.AreEqual(result[0].Name, "P1");
            Assert.AreEqual(result[1].Name, "P2");
            Assert.AreEqual(result[2].Name, "P3");
        }
开发者ID:KannugoPrithvi,项目名称:SportStore,代码行数:19,代码来源:AdminTests.cs

示例6: Index_Contains_All_Products

        public void Index_Contains_All_Products()
        {
            // Arrange
            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"}
                                                    }.AsQueryable());

            AdminController target = new AdminController(mock.Object);

            // Act
            List<Product> result = ((IEnumerable<Product>)target.Index().Model).ToList();

            // Assert
            Assert.AreEqual(3, result.Count);
            Assert.AreEqual("P2", result[1].Name);
        }
开发者ID:tenzinkabsang,项目名称:SportsStoreKnockoutified,代码行数:20,代码来源:AdminControllerTests.cs

示例7: Index_Contains_All_Products

        public void Index_Contains_All_Products()
        {
            // Arrange
            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"},
                }.AsQueryable());

            AdminController target = new AdminController(mock.Object);

            // Act
            Product[] products = ((IEnumerable<Product>)target.Index().Model).ToArray();

            // Assert
            Assert.AreEqual(3, products.Length);
            Assert.AreEqual("p1", products[0].Name);
            Assert.AreEqual("p2", products[1].Name);
            Assert.AreEqual("p3", products[2].Name);
        }
开发者ID:djandreski,项目名称:SportsStore,代码行数:21,代码来源:AdminTest.cs

示例8: Index_Contains_All_Products

        public void Index_Contains_All_Products()
        {
            // 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" },
                }.AsQueryable());

            AdminController target = new AdminController(mock.Object);

            // Act
            Product[] result = ((ProductsListViewModel)target.Index().ViewData.Model).Products.ToArray();

            // Assert
            Assert.AreEqual(3, result.Length);
            Assert.AreEqual("P1", result[0].Name);
            Assert.AreEqual("P2", result[1].Name);
            Assert.AreEqual("P3", result[2].Name);
        }
开发者ID:eugeniomiro,项目名称:SportsStore,代码行数:23,代码来源:ControllersTests.cs

示例9: IndexContainsAllProducts

        public void IndexContainsAllProducts()
        {
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(new Product[]
            {
                new Product(){Id = 1, Name = "P1"},
                new Product(){Id = 2, Name = "P2"},
                new Product(){Id = 3, Name = "P3"}
            });
            AdminController controller = new AdminController(mock.Object);

            Product[] result = ((IEnumerable<Product>)((ViewResult)controller.Index()).ViewData.Model).ToArray();

            Assert.AreEqual(result.Length, 3);
            Assert.AreEqual("P1", result[0].Name);
            Assert.AreEqual("P2", result[1].Name);
            Assert.AreEqual("P3", result[2].Name);
        }
开发者ID:MichalZawadzki,项目名称:SportsStore,代码行数:18,代码来源:AdminTests.cs

示例10: Index_Contains_All_Products

        public void Index_Contains_All_Products()
        {
            // Arrange - create a mock repository
            var mock = InitializeMock();

            AdminController target = new AdminController(mock.Object);

            //Action
            Product[] result = ((IEnumerable<Product>)target.Index().ViewData.Model).ToArray();

            // assert
            Assert.AreEqual(result.Length, 3);
            Assert.AreEqual("P1", result[0].Name);
            Assert.AreEqual("P2", result[1].Name);
            Assert.AreEqual("P3", result[2].Name);
        }
开发者ID:jvvpabalan,项目名称:SportsStore,代码行数:16,代码来源:AdminTests.cs

示例11: Index_Contains_All_Products

        public void Index_Contains_All_Products()
        {
            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"},
               new Product{ ProductID = 4, Name = "P4"},
               new Product{ ProductID = 5, Name = "P5"}}.AsQueryable());

            AdminController controller = new AdminController(mock.Object);

            Product[] products = ((IEnumerable<Product>)controller.Index().ViewData.Model).ToArray();

            Assert.AreEqual(5, products.Length);
        }
开发者ID:CacoDurban,项目名称:SportsStore,代码行数:17,代码来源:AdminControllerTest.cs

示例12: Index_Contains_All_Products

        public void Index_Contains_All_Products()
        {
            // 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 a controller
            AdminController target = new AdminController(mock.Object);

            // Action
            var result = ((IEnumerable<Product>) target.Index().ViewData.Model).ToArray();

            // Assert
            Assert.AreEqual(result.Length, 3);
            Assert.AreEqual("P1", result[0].Name);
            Assert.AreEqual("P2", result[1].Name);
            Assert.AreEqual("P3", result[2].Name);
        }
开发者ID:denozavr,项目名称:SportStore,代码行数:22,代码来源:AdminTest.cs

示例13: Index_Contains_All_Products

        public void Index_Contains_All_Products()
        {
            // arrange - create the mock repository
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(new[]
            {
                new Product {ProductID = 1, Name = "p1"}, new Product {ProductID = 2, Name = "p2"},
                new Product {ProductID = 3, Name = "p3"}
            });

            // arrange - create a controller
            AdminController target = new AdminController(mock.Object);

            // action
            // example of what worked elsewhere - (CartIndexViewModel)target.Index(cart, "myUrl").ViewData.Model;

            Product[] results = ((IEnumerable<Product>)target.Index().ViewData.Model).ToArray();

            // Assert
            Assert.AreEqual(results.Length, 3);
            Assert.AreEqual("p1", results[0].Name);
            Assert.AreEqual("p2", results[1].Name);
            Assert.AreEqual("p3", results[2].Name);
        }
开发者ID:pixelsyndicate,项目名称:Pro_AspNet_MVC_5_book,代码行数:24,代码来源:AdminTests.cs


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