Esempio n. 1
0
        public void ShouldChangeGameQuantityAtBasket()
        {
            var model = new ChangeGameQuantityViewModel
            {
                Id       = 1,
                Quantity = 3
            };
            var sessionItems = new SessionStateItemCollection
            {
                [Basket] = new List <Purchase>
                {
                    new Purchase(model.Id, It.IsAny <string>(), It.IsAny <decimal>(), quantity: 1)
                }
            };

            _basketController.ControllerContext = new FakeControllerContext(_basketController, sessionItems);

            _orderService
            .Setup(m => m.GetCurrentOrderForCustomer(It.IsAny <string>()))
            .Returns(new OrderDto {
                Id = 1
            });

            _orderService
            .Setup(m => m.Update(It.IsAny <int>(), It.IsAny <Dictionary <int, short> >(), It.IsAny <string>()));

            _basketController.ChangeGameQuantity(model);

            var purchases = _basketController.Session[Basket] as List <Purchase>;

            Assert.IsNotNull(purchases);
            Assert.AreEqual(model.Quantity, purchases.First().Quantity);
        }