Exemple #1
0
        public static void Load_ValidJson_Succeeds()
        {
            //Arrange + Act
            var stockItems = GroceryItemLoader.Load(ValidItemsJson)
                             .ToArray();

            //Assert
            Assert.That(stockItems.Length, Is.EqualTo(2));
        }
Exemple #2
0
        public static void Main()
        {
            // Load all data required to run the program
            var priceList = GroceryItemLoader.Load(File.ReadAllText(".\\GroceryItems.json"))
                            .ToDictionary(i => i.Id, i => i);

            var promotions = PromotionLoader.Load(File.ReadAllText(".\\Promotions.json"), priceList);

            var basket = BasketItemLoader.Load(File.ReadAllText(".\\Basket.json"));

            // Instantiate the controller
            var controller = new CheckoutController(priceList, promotions);

            // Checkout the items
            var view = controller.Checkout(basket);

            // Render the view
            view.Render();

            System.Console.WriteLine("Press a key to continue");
            System.Console.ReadKey();
        }
Exemple #3
0
 public static void Load_InvalidJson_Fails()
 {
     //Arrange + Act + Assert
     Assert.Throws <JsonSerializationException>(() => GroceryItemLoader.Load(InvalidItemsJson));
 }