當前位置: 首頁>>代碼示例>>C#>>正文


C# NavController.Menu方法代碼示例

本文整理匯總了C#中SportsStore.WebUI.Controllers.NavController.Menu方法的典型用法代碼示例。如果您正苦於以下問題:C# NavController.Menu方法的具體用法?C# NavController.Menu怎麽用?C# NavController.Menu使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SportsStore.WebUI.Controllers.NavController的用法示例。


在下文中一共展示了NavController.Menu方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Can_Create_Categories

        public void Can_Create_Categories()
        {
            // 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", Category = "Apples"},
                                                new Product {ProductID = 2, Name = "P2", Category = "Apples"},
                                                new Product {ProductID = 3, Name = "P3", Category = "Plums"},
                                                new Product {ProductID = 4, Name = "P4", Category = "Oranges"},
                                                });

            // Arrange - create the controller
            NavController target = new NavController(mock.Object);

            // Act = get the set of categories
            string[] results = ((IEnumerable<string>)target.Menu().Model).ToArray();

            // Assert
            Assert.AreEqual(results.Length, 3);
            Assert.AreEqual(results[0], "Apples");
            Assert.AreEqual(results[1], "Oranges");
            Assert.AreEqual(results[2], "Plums");
        }
開發者ID:TarRob,項目名稱:Learning,代碼行數:25,代碼來源:UnitTest1.cs

示例2: Can_Create_Categories

        public void Can_Create_Categories()
        {
            // supply test data that does have duplicates and is not in order then pass it to the NavController and assert the data has been cleaned up.

            // arrange
            Mock<IProductRepository> mock = new Mock<IProductRepository>();

            mock.Setup(m => m.Products).Returns(new Product[]
            {
                new Product {ProductID = 1, Name = "P1", Category = "Apples"},
                new Product {ProductID = 2, Name = "P2", Category = "Apples"},
                new Product {ProductID = 3, Name = "P3", Category = "Plums"},
                new Product {ProductID = 4, Name = "P4", Category = "Oranges"},
                new Product {ProductID = 5, Name = "P5", Category = "Avacados"},
            });

            // arrange = create the controller
            NavController target = new NavController(mock.Object);

            // act = get the set of categoreis
            string[] results = ((IEnumerable<string>)target.Menu().Model).ToArray();

            // assert = did the controller put them in order and only get distinct?
            Assert.AreEqual(results.Length, 4);
            Assert.AreEqual(results[0], "Apples");
            Assert.AreEqual(results[1], "Avacados");
            Assert.AreEqual(results[2], "Oranges");
            Assert.AreEqual(results[3], "Plums");
        }
開發者ID:pixelsyndicate,項目名稱:Pro_AspNet_MVC_5_book,代碼行數:29,代碼來源:PagingUnitTests.cs

示例3: Can_Create_Categories

        public void Can_Create_Categories()
        {
            var mockProducts = PrepareProductsForTest();

            NavController controller = new NavController(mockProducts.Object);
            string[] results = ((IEnumerable<string>)controller.Menu().Model).ToArray();

            Assert.AreEqual(results.Length, 3);
            Assert.AreEqual(results[0], "Cart1");
            Assert.AreEqual(results[1], "Cart2");
            Assert.AreEqual(results[2], "Cart3");
        }
開發者ID:PawelHaracz,項目名稱:SportsStore,代碼行數:12,代碼來源:UnitTest1.cs

示例4: Can_Create_Categories

        public void Can_Create_Categories()
        {
            //arrange
            Mock<IProductsRepository> mock = InitializeMock();
            NavController target = new NavController(mock.Object);

            // act
            string[] results = ((IEnumerable<string>)target.Menu().Model).ToArray();

            Assert.AreEqual(results.Length, 3);
            Assert.AreEqual(results[0], "Apples");
            Assert.AreEqual(results[1], "Oranges");
            Assert.AreEqual(results[2], "Plums");
        }
開發者ID:jvvpabalan,項目名稱:SportsStore,代碼行數:14,代碼來源:UnitTest1.cs

示例5: IndicatesSelectedCategory

        public void IndicatesSelectedCategory()
        {
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(new Product[] {
                new Product { ProductID = 1, Name = "P1", Category = "Apples"},
                new Product { ProductID = 4, Name = "P2", Category = "Oranges"}
            });

            NavController controller = new NavController(mock.Object);
            string categoryToSelect = "Apples";

            string results = controller.Menu(categoryToSelect).ViewBag.SelectedCategory;

            Assert.AreEqual(categoryToSelect, results);
        }
開發者ID:brainiacOnly,項目名稱:SportsStore,代碼行數:15,代碼來源:NavControllerTests.cs

示例6: Indicates_Selected_Category

        public void Indicates_Selected_Category()
        {
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(new Product[]{
                new Product { ProductID = 1 , Name = "P1", Category = "Jabłka"},
                new Product { ProductID = 4 , Name = "P2", Category = "Pomarańcze" }
            }.AsQueryable());

            NavController target = new NavController(mock.Object);

            string categoryToSelect = "Jabłka";

            string result = target.Menu(categoryToSelect).ViewBag.SelectedCategory;

            Assert.AreEqual(categoryToSelect, result);
        }
開發者ID:akuczynski,項目名稱:SportsStore,代碼行數:16,代碼來源:NavControllerTest.cs

示例7: NavController_MenuAction_ReturningDistinctCategories_FromProductsCollection

        public void NavController_MenuAction_ReturningDistinctCategories_FromProductsCollection()
        {
            //Arrange
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(products.AsQueryable());
            NavController target = new NavController(mock.Object); // TODO: Initialize to an appropriate value

            //Action
            CategoryListViewModel result = (CategoryListViewModel)target.Menu(null).Model;
            string[] cats = result.Categories.ToArray();

            //Assert
            Assert.IsTrue(cats.Length == 4);
            Assert.AreEqual(cats[0], "Accounting");
            Assert.AreEqual(cats[1], "Computers");
            Assert.AreEqual(cats[2], "Fruit");
        }
開發者ID:najamsk,項目名稱:SportsStore,代碼行數:17,代碼來源:NavControllerTest.cs

示例8: Menu_GetCategories_Display

        public void Menu_GetCategories_Display()
        {
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(p => p.Products).Returns(
                new Product [] {
                   new Product {ProductID=1, ProductName="P1", Category=new Category{CategoryID=1, CategoryName="Cat1"}},
                new Product {ProductID=2, ProductName="P2", Category=new Category{CategoryID=2, CategoryName="Cat2"}},
                new Product {ProductID=2, ProductName="P3", Category=new Category{CategoryID=1, CategoryName="Cat1"}},
                new Product {ProductID=2, ProductName="P4", Category=new Category{CategoryID=1, CategoryName="Cat1"}},
                new Product {ProductID=2, ProductName="P5", Category=new Category{CategoryID=2, CategoryName="Cat2"}}
            }.AsQueryable());

            NavController controller = new NavController(mock.Object);
            string[] result = ((IEnumerable<string>)controller.Menu().Model).ToArray();
            Assert.AreEqual(1, result[0]);
            Assert.AreEqual(2, result[1]);
        }
開發者ID:vinhchung,項目名稱:SportsStore,代碼行數:17,代碼來源:UnitTest1.cs

示例9: Can_Create_Categories

        public void Can_Create_Categories()
        {
            // Arrange
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(GetFruitProductArray());

            NavController target = new NavController(mock.Object);

            // Act
            string[] results = ((IEnumerable<string>)target.Menu().Model).ToArray();

            // Assert
            Assert.AreEqual(results.Length, 3);
            Assert.AreEqual(results[0], "Apples");
            Assert.AreEqual(results[1], "Oranges");
            Assert.AreEqual(results[2], "Plums");
        }
開發者ID:nhebb,項目名稱:ProMVC5,代碼行數:17,代碼來源:UnitTest1.cs

示例10: Indicates_Selected_Category

 public void Indicates_Selected_Category()
 {
     // 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", Category = "Apples"},
         new Product {ProductID = 4, Name = "P2", Category = "Oranges"},
     }.AsQueryable());
     // Arrange - create the controller
     NavController target = new NavController(mock.Object);
     // Arrange - define the category to selected
     string categoryToSelect = "Apples";
     // Action
     string result = target.Menu(categoryToSelect).ViewBag.SelectedCategory;
     // Assert
     Assert.AreEqual(categoryToSelect, result);
 }
開發者ID:tofka,項目名稱:Lab-3,代碼行數:18,代碼來源:NavControllerTest.cs

示例11: NavController_Menu_IndicatesSelectedCategory

        public void NavController_Menu_IndicatesSelectedCategory()
        {
            // Arrange
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(new Product[] {
                new Product {ProductID = 1, Name = "P1", Category = "Apples" },
                new Product {ProductID = 3, Name = "P3", Category = "Plums" },

            }.AsQueryable());
            NavController controller = new NavController(mock.Object);
            string CategoryToSelect = "Apples";

            // Act
            var result = controller.Menu(CategoryToSelect).ViewBag.SelectedCategory;

            // Assert
            Assert.AreEqual<string>(CategoryToSelect, result);
        }
開發者ID:nitzerebbnitzerebb,項目名稱:Lab2,代碼行數:18,代碼來源:NavControllerTests.cs

示例12: Indicates_Selected_Category

        public void Indicates_Selected_Category()
        {
            Mock<IProductRepository> mock = new Mock<IProductRepository>();

            mock.Setup(m => m.Products).Returns(new Product[] {
               new Product{ ProductID = 1, Name = "P1", Category = "c2"},
               new Product{ ProductID = 2, Name = "P2", Category = "c2"},
               new Product{ ProductID = 3, Name = "P3", Category = "c3"},
               new Product{ ProductID = 4, Name = "P4", Category = "c4"},
               new Product{ ProductID = 5, Name = "P5", Category = "c5"}}.AsQueryable());

            NavController controller = new NavController(mock.Object);

            string categorySelected = "c2";

            string result = controller.Menu(categorySelected).ViewBag.SelectedCategory;

            Assert.AreEqual(categorySelected, result);
        }
開發者ID:CacoDurban,項目名稱:SportsStore,代碼行數:19,代碼來源:NavControllerTest.cs

示例13: Can_Create_Categories

        public void Can_Create_Categories()
        {
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(new Product[]
            {
                new Product { ProductId = 1, Name = "P1", Category = "Apples"},
                new Product { ProductId = 2, Name = "P2", Category = "Apples"},
                new Product { ProductId = 3, Name = "P3", Category = "Plums"},
                new Product { ProductId = 4, Name = "P4", Category = "Oranges"},
            });

            NavController controller = new NavController(mock.Object);
            string[] results = ((IEnumerable<string>) controller.Menu().Model).ToArray();

            Assert.AreEqual(3, results.Length);
            Assert.AreEqual("Apples",results[0]);
            Assert.AreEqual("Oranges", results[1]);
            Assert.AreEqual("Plums", results[2]);
        }
開發者ID:erangeljr,項目名稱:SportsStore,代碼行數:19,代碼來源:UnitTest1.cs

示例14: Can_Create_Categories

        public void Can_Create_Categories()
        {
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(new Product[]{
                new Product { ProductID = 1 , Name = "P1", Category = "Jabłka"},
                new Product { ProductID = 2 , Name = "P2", Category = "Jabłka" },
                new Product { ProductID = 3, Name = "P3", Category = "Śliwki" },
                new Product { ProductID = 4, Name = "P4", Category = "Pomarańcze" }
            }.AsQueryable());

            NavController target = new NavController(mock.Object);

            string[] results = ((IEnumerable<string>)target.Menu().Model).ToArray();

            Assert.AreEqual(results.Length, 3);
            Assert.AreEqual(results[0], "Jabłka");
            Assert.AreEqual(results[1], "Pomarańcze");
            Assert.AreEqual(results[2], "Śliwki");
        }
開發者ID:akuczynski,項目名稱:SportsStore,代碼行數:19,代碼來源:NavControllerTest.cs

示例15: CanCreateCategories

        public void CanCreateCategories()
        {
            Mock<IProductRepository> mock = new Mock<IProductRepository>();
            mock.Setup(m => m.Products).Returns(new Product[]
            {
                new Product() {Id = 1, Name = "P1", Category = "Jabłka"},
                new Product() {Id = 2, Name = "P2", Category = "Jabłka"},
                new Product() {Id = 3, Name = "P3", Category = "Śliwki"},
                new Product() {Id = 4, Name = "P4", Category = "Pomarańcze"}
            });
            NavController controller = new NavController(mock.Object);

            var viewResult = (PartialViewResult) controller.Menu();
            string[] result = ((IEnumerable<string>) viewResult.Model).ToArray();

            Assert.AreEqual(result.Length, 3);
            Assert.AreEqual(result[0], "Jabłka");
            Assert.AreEqual(result[1], "Pomarańcze");
            Assert.AreEqual(result[2], "Śliwki");
        }
開發者ID:MichalZawadzki,項目名稱:SportsStore,代碼行數:20,代碼來源:ProductTests.cs


注:本文中的SportsStore.WebUI.Controllers.NavController.Menu方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。