public void RemoveFromCartTest()
        {
            using (TransactionScope ts = new TransactionScope())
            {
                Album album1 = this.GetAlbum(669);
                Album album2 = this.GetAlbum(668);

                ICartIdProvider provider = new TestCartIdProvider();
                ShoppingCart cart = ShoppingCart.GetCart(provider);

                cart.AddToCart(album1);
                cart.AddToCart(album2);
                cart.AddToCart(album2);

                ShoppingCartController target = new ShoppingCartController(provider);
                int id = cart.GetCartItems().First().RecordId;
                ActionResult actual;
                actual = target.RemoveFromCart(id);

                Assert.IsNotNull(actual);
                Assert.IsInstanceOfType(actual, typeof(JsonResult));

                JsonResult jsonResult = (JsonResult)actual;

                Assert.IsInstanceOfType(jsonResult.Data, typeof(ShoppingCartRemoveViewModel));

                ShoppingCartRemoveViewModel model = (ShoppingCartRemoveViewModel)jsonResult.Data;

                Assert.AreEqual(2, model.CartCount);
                Assert.AreEqual(id, model.DeleteId);
            }
        }
        public void IndexTest()
        {
            using (TransactionScope ts = new TransactionScope())
            {
                Album album1 = this.GetAlbum(669);
                Album album2 = this.GetAlbum(668);

                ICartIdProvider provider = new TestCartIdProvider();
                ShoppingCart cart = ShoppingCart.GetCart(provider);

                cart.AddToCart(album1);
                cart.AddToCart(album2);
                cart.AddToCart(album2);

                ShoppingCartController target = new ShoppingCartController(provider);
                ActionResult actual;
                actual = target.Index();

                Assert.IsNotNull(actual);
                Assert.IsInstanceOfType(actual, typeof(ViewResult));

                ViewResult viewResult = (ViewResult)actual;

                Assert.IsInstanceOfType(viewResult.ViewData.Model, typeof(ShoppingCartViewModel));

                ShoppingCartViewModel model = (ShoppingCartViewModel)viewResult.ViewData.Model;

                Assert.AreEqual(2, model.CartItems.Count);
                Assert.AreEqual(3, model.CartItems.Sum(it => it.Count));
            }
        }
        public void AddToCartTest()
        {
            using (TransactionScope ts = new TransactionScope())
            {
                ICartIdProvider provider = new TestCartIdProvider();
                ShoppingCartController target = new ShoppingCartController(provider);
                int id = 669;
                ActionResult actual;
                actual = target.AddToCart(id);

                Assert.IsNotNull(actual);

                ShoppingCart cart = ShoppingCart.GetCart(provider);

                List<Cart> items = cart.GetCartItems();

                Assert.IsNotNull(items);
                Assert.AreEqual(1, items.Count);
                Assert.AreEqual(id, items[0].AlbumId);
                Assert.AreEqual(1, items[0].Count);
            }
        }