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