public void ReportErrorParseBasketIfNoArgs()
        {
            var basketBuilder = new BasketBuilder();
            var basket        = new Basket();

            Assert.False(basketBuilder.Parse(null, out basket));;
            StringAssert.AreEqualIgnoringCase("No Items Given to Price Calculator", basketBuilder.ParseError);
        }
        public void NotParseBasket(object[] testArg, string expectedError)
        {
            var args = new List <string>();

            foreach (var test in testArg)
            {
                args.Add(test.ToString());
            }

            var basketBuilder = new BasketBuilder();

            Assert.False(basketBuilder.Parse(args.ToArray(), out var basket));
            StringAssert.StartsWith(expectedError, basketBuilder.ParseError);
        }
        public void ParseBasket(object[] testArg, int expectedCount)
        {
            var args = new List <string>();

            foreach (var test in testArg)
            {
                args.Add(test.ToString());
            }

            var basketBuilder = new BasketBuilder();

            Assert.True(basketBuilder.Parse(args.ToArray(), out var basket));
            Assert.That(basket.goods.Count(), Is.EqualTo(expectedCount));;;
        }
        public void CalculateWithBreadAndBeansOffers()
        {
            var printer       = Substitute.For <IPrinter>();
            var basketBuilder = new BasketBuilder();

            basketBuilder.Parse(new string[] { "Beans", "Beans", "Bread" }, out var basket);
            var specialOffers = new SpecialOffers();

            var priceCalculator = new PriceCalculator(printer, specialOffers);

            priceCalculator.Calculate(basket);

            printer.Received().PrintLine(Arg.Is <string>(x => x.StartsWith("Subtotal")));
            printer.Received().PrintLine(Arg.Is <string>(x => x.StartsWith("Buy 2 cans of ")));
            printer.Received().PrintLine(Arg.Is <string>(x => x.StartsWith("Total price:")));
        }
        public void CalculateWithLotsOfApplesOffers()
        {
            var printer       = Substitute.For <IPrinter>();
            var basketBuilder = new BasketBuilder();

            basketBuilder.Parse(new string[] { "Apples", "Apples", "Apples", "Apples" }, out var basket);
            var specialOffers = new SpecialOffers();

            var priceCalculator = new PriceCalculator(printer, specialOffers);

            priceCalculator.Calculate(basket);

            printer.Received().PrintLine(Arg.Is <string>(x => x.StartsWith("Subtotal: ")));
            printer.Received().PrintLine(Arg.Is <string>(x => x.StartsWith("Apples 10% off:: 40p")));
            printer.Received().PrintLine(Arg.Is <string>(x => x.StartsWith("Total price: ")));
        }