Exemplo n.º 1
0
        public void Can_Create_Categories()
        {
            // Arrange
            var repositoryStub = new eStore.Domain.Abstract.Fakes.StubIProductRepository();
            repositoryStub.ProductsGet = () =>
            {
                return new List<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 target = new NavController(repositoryStub);

            // Act
            var 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");
        }
Exemplo n.º 2
0
        public void Indicates_Selected_Category()
        {
            // Arrange
            var repositoryStub = new eStore.Domain.Abstract.Fakes.StubIProductRepository();
            repositoryStub.ProductsGet = () =>
            {
                return new List<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 target = new NavController(repositoryStub);
            var categoryToSelect = "Apples";

            // Action
            String result = target.Menu(categoryToSelect).ViewBag.SelectedCategory;

            // Assert
            Assert.AreEqual(categoryToSelect, result);
        }