public BasketModificationTests()
 {
     basket             = new UnverifiedBasket();
     cheeseCache        = new CheeseInMemCacheClass();
     basketModification = new BasketModification(cheeseCache);
     basket.ID          = Guid.Parse("f3f6b014-df03-495e-a0c5-17ff198a1cff");
 }
 public BasketControllerTests()
 {
     basket           = new UnverifiedBasket();
     mockLogger       = new Mock <ILogger <BasketController> >();
     basketModifier   = new Mock <IBasketModification>();
     basket.ID        = Guid.Parse("f3f6b014-df03-495e-a0c5-17ff198a1cff");
     basketController = new BasketController(mockLogger.Object, this.basketModifier.Object);
 }
Esempio n. 3
0
        public BasketModel UpdateBasket(UnverifiedBasket basket)
        {
            var newBasket = new BasketModel();

            if (basket.ID == Guid.Empty)
            {
                newBasket.ID = Guid.NewGuid();
            }
            else
            {
                newBasket.ID = basket.ID;
            }

            var newLines = new List <VerifiedBasketLine>();

            if (basket.Lines?.Length > 0)
            {
                foreach (var basketLine in basket.Lines)
                {
                    var cheese = this._cheeseCache.Read(basketLine.ProductID);
                    if (cheese != null)
                    {
                        var line = new VerifiedBasketLine();
                        line.Grams     = basketLine.Grams;
                        line.Name      = cheese.Name;
                        line.RowNo     = basketLine.RowNo;
                        line.Price     = Math.Round((basketLine.Grams * cheese.PricePerKG) / 1000, 2, MidpointRounding.AwayFromZero);
                        line.ProductID = cheese.ID;

                        newLines.Add(line);
                    }
                }
            }

            newBasket.Lines = newLines.ToArray();

            return(newBasket);
        }
Esempio n. 4
0
 public BasketModel UpdateBasket(UnverifiedBasket basket)
 {
     return(this._basketModification.UpdateBasket(basket));
 }