Esempio n. 1
0
        public void ShouldCheckout1A()
        {
            var a = new Sku {
                ItemName = "A", Price = 5
            };
            var b = new Sku {
                ItemName = "B", Price = 3
            };
            var offers = new List <Pricing> {
                new Pricing {
                    Condition = new List <SkuUnits> {
                        new SkuUnits {
                            Sku = a, Units = 2
                        }, new SkuUnits {
                            Sku = b, Units = 1
                        }
                    }
                }
            };
            var skus = new Skus();

            skus.AddOrUpdate(a);
            skus.AddOrUpdate(b);
            var basket = new List <(Sku sku, int items)>();

            basket.AddRange(new[]
Esempio n. 2
0
        public void ShouldCheckoutNothing()
        {
            var a = new Sku {
                ItemName = "A", Price = 5
            };
            var b = new Sku {
                ItemName = "B", Price = 3
            };
            var offers = new List <Pricing> {
                new Pricing {
                    Condition = new List <SkuUnits> {
                        new SkuUnits {
                            Sku = a, Units = 2
                        }, new SkuUnits {
                            Sku = b, Units = 1
                        }
                    }
                }
            };
            var skus = new Skus();

            skus.AddOrUpdate(a);
            skus.AddOrUpdate(b);
            var emptyBasket = new List <(Sku sku, int items)>();
            var kart        = new Kart();
            var sut         = new Checkout(skus, offers);

            foreach (var i in emptyBasket)
            {
                kart = sut.Scan(kart, i.sku, i.items);
            }

            kart.Total.ShouldBe(0m);
        }