예제 #1
0
        public void Details()
        {
            // Arrange
            StoreController controller = new StoreController();

            // Act
            ViewResult result = controller.Details(3) as ViewResult;

            // Assert
            ViewDataDictionary viewData = result.ViewData;
            StoreDetailsViewModel storeDetailsViewModel = viewData.Model as StoreDetailsViewModel;

            Product product = storeDetailsViewModel.Product;

            Assert.AreEqual("Felt Brougham 2010", product.Name);
            Assert.AreEqual(299.99M, product.Price);
            Assert.AreEqual("http://s.wiggle.co.uk/images/felt-brougham-2010-ind.jpg", product.Url);
        }
예제 #2
0
        public void Index()
        {
            // Arrange
            StoreController controller = new StoreController();

            // Act
            ViewResult result = controller.Index() as ViewResult;

            // Assert
            ViewDataDictionary viewData = result.ViewData;
            StoreIndexViewModel storeIndexViewModel = viewData.Model as StoreIndexViewModel;

            IEnumerable<Category> categories = storeIndexViewModel.Categories;

            Assert.AreEqual("Accessories", categories.ElementAt<Category>(0).Name);
            Assert.AreEqual("Bikes", categories.ElementAt<Category>(1).Name);
            Assert.AreEqual("Clothing", categories.ElementAt<Category>(2).Name);
            Assert.AreEqual("Components", categories.ElementAt<Category>(3).Name);
            Assert.AreEqual("Nutrition", categories.ElementAt<Category>(4).Name);
            Assert.AreEqual("Shoes", categories.ElementAt<Category>(5).Name);
        }
예제 #3
0
        public void Browse()
        {
            // Arrange
            StoreController controller = new StoreController();

            // Act
            ViewResult result = controller.Browse("Accessories") as ViewResult;

            // Assert
            ViewDataDictionary viewData = result.ViewData;
            StoreBrowseViewModel storeBrowseViewModel = viewData.Model as StoreBrowseViewModel;

            Category category = storeBrowseViewModel.Category;

            Assert.AreEqual("Accessories", category.Name);

            IEnumerable<Product> products = storeBrowseViewModel.Products;

            Assert.AreEqual("Fibre Flare Shorty Rear Light", products.ElementAt<Product>(0).Name);
            Assert.AreEqual("Fox Flux Helmet", products.ElementAt<Product>(1).Name);
            Assert.AreEqual("Garmin Edge 500 with Heart Rate, Cadence and Team Jersey", products.ElementAt<Product>(2).Name);
            Assert.AreEqual("Giro Prolight Road Helmet", products.ElementAt<Product>(3).Name);
        }