Example #1
0
        public void AddCookiesFromCupboard_Succeeds()
        {
            var command = new AddCookiesFromCupboardCommand(new[]
            {
                new CookieQuantity(10, Cookie.DosiSo),
                new CookieQuantity(15, Cookie.Samoas),
            }, DateTime.UtcNow, 1);

            _unitOfWork.Setup(f => f.Get <TroopCookieInventory>(It.Is <int>(id => id == 1))).Returns(_troopInventory);

            var handler = new AddCookiesFromCupboardCommandHandler(_unitOfWork.Object);
            var result  = handler.Handle(command);

            result.IsSuccess.Should().BeTrue();

            _troopInventory.Stacks.Count.Should().Be(8);
            _troopInventory.Stacks.Sum(s => s.CookieQuantity.TotalAmount).Should().Be(125);
        }
Example #2
0
        //TODO refactor to take view model and id
        public void AddCookiesFromCupboard(AddCookiesFromCupboardDto data)
        {
            using (var uow = UnitOfWork)
            {
                IEnumerable <CookieQuantity> cookies = new[]
                {
                    new CookieQuantity(data.DoSiSos, Cookie.DosiSo),
                    new CookieQuantity(data.Samoas, Cookie.Samoas),
                    new CookieQuantity(data.Savannah, Cookie.Savannah),
                    new CookieQuantity(data.Smors, Cookie.Smors),
                    new CookieQuantity(data.Tagalongs, Cookie.Tagalongs),
                    new CookieQuantity(data.ThinMints, Cookie.ThinMints),
                    new CookieQuantity(data.ToffeeTastic, Cookie.ToffeeTastic),
                    new CookieQuantity(data.Trefoils, Cookie.Trefoils),
                };
                DateTime dateReceived     = data.DateReceived;
                int      troopInventoryId = data.TroopInventoryId;


                var command = new AddCookiesFromCupboardCommand(cookies, dateReceived, troopInventoryId);
                var handler = new AddCookiesFromCupboardCommandHandler(uow);
                var result  = handler.Handle(command);
            }
        }