public void TestBagMultiProductCheckIfCorrectnumberOfItems(double price, int quantity, int products)
        {
            var options = new DbContextOptionsBuilder <DatabaseContext>()
                          .UseSqlite("DataSource=:memory:")
                          .Options;

            IWinkelwagenMapper mapper = new WinkelwagenMapper();

            // Run the test against one instance of the context
            using (var context = new DatabaseContext(options))
            {
                context.Database.OpenConnection();
                context.Database.EnsureCreated();

                context.Klanten.Add(new Klant()
                {
                    AzureId      = "TestUser",
                    Winkelwagens = new List <Winkelwagen>()
                });

                for (int f = 1; f <= products; f++)
                {
                    context.Cursussen.Add(new Cursus()
                    {
                        Titel = "C#" + f,
                        Prijs = price
                    });
                }
                context.SaveChanges();

                var facade = new WinkelwagenFacade(new CostCalculator(), new WinkelwagenRepository(context),
                                                   new KlantRepository(context), mapper);
                var winkelwagen = facade.GetBagForCustomer("TestUser");

                //Add each product 3 times
                for (int f = 1; f <= products; f++)
                {
                    winkelwagen = facade.AddProduct("TestUser", f, quantity, "Cursus");
                }
                for (int f = 1; f <= products; f++)
                {
                    winkelwagen = facade.AddProduct("TestUser", f, quantity, "Cursus");
                }
                for (int f = 1; f <= products; f++)
                {
                    winkelwagen = facade.AddProduct("TestUser", f, quantity, "Cursus");
                }

                //Check if there are still no more than number of items equal to the number of different products
                Assert.AreEqual(products, winkelwagen.Producten.Count);
            }
        }
        public void TestBagMultiProduct(double price, int quantity, int products, double expectedTotal)
        {
            var options = new DbContextOptionsBuilder <DatabaseContext>()
                          .UseSqlite("DataSource=:memory:")
                          .Options;

            IWinkelwagenMapper mapper = new WinkelwagenMapper();

            // Run the test against one instance of the context
            using (var context = new DatabaseContext(options))
            {
                context.Database.OpenConnection();
                context.Database.EnsureCreated();

                context.Klanten.Add(new Klant()
                {
                    AzureId      = "TestUser",
                    Winkelwagens = new List <Winkelwagen>()
                });

                for (int f = 1; f <= products; f++)
                {
                    context.Cursussen.Add(new Cursus()
                    {
                        ID    = f,
                        Titel = "dotNET" + f,
                        Prijs = price
                    });
                }
                context.SaveChanges();

                var facade = new WinkelwagenFacade(new CostCalculator(), new WinkelwagenRepository(context),
                                                   new KlantRepository(context), mapper);
                var winkelwagen = facade.GetBagForCustomer("TestUser");

                for (int f = 1; f <= products; f++)
                {
                    winkelwagen = facade.AddProduct("TestUser", f, quantity, "Cursus");
                }
                Assert.AreEqual(expectedTotal, winkelwagen.TotaalPrijs);
            }
        }
        public void TestBagOneProduct2TimesCheckIfSingleItem(double price, int quantity)
        {
            var options = new DbContextOptionsBuilder <DatabaseContext>()
                          .UseSqlite("DataSource=:memory:")
                          .Options;

            IWinkelwagenMapper mapper = new WinkelwagenMapper();

            // Run the test against one instance of the context
            using (var context = new DatabaseContext(options))
            {
                context.Database.OpenConnection();
                context.Database.EnsureCreated();

                context.Klanten.Add(new Klant()
                {
                    AzureId      = "TestUser",
                    Winkelwagens = new List <Winkelwagen>()
                });

                context.Cursussen.Add(new Cursus()
                {
                    ID    = 1,
                    Titel = "C#",
                    Prijs = price
                });

                context.SaveChanges();

                var facade = new WinkelwagenFacade(new CostCalculator(), new WinkelwagenRepository(context),
                                                   new KlantRepository(context), mapper);
                var winkelwagen = facade.GetBagForCustomer("TestUser");

                //Add the same product twice
                winkelwagen = facade.AddProduct("TestUser", 1, quantity, "Cursus");
                winkelwagen = facade.AddProduct("TestUser", 1, quantity, "Cursus");

                //Now we should still have only 1 item (= 1 product)
                Assert.AreEqual(1, winkelwagen.Producten.Count);
            }
        }