public async Task InsertBestellingIntoDatabaseAndUpdate()
        {
            var bestelling = new Bestelling
            {
                Id                = 1,
                KlantId           = "1",
                AdresRegel1       = "Laagstraat 11",
                Plaats            = "Laaghoven",
                Postcode          = "1234FG",
                BestellingStatus  = BestellingStatus.TerControleVoorSales,
                BesteldeArtikelen = new List <BestellingItem>
                {
                    new BestellingItem(1, 3)
                    {
                        Id = 1
                    },
                    new BestellingItem(2, 5)
                    {
                        Id = 2
                    }
                }
            };

            using (var context = new WebshopContext(_options))
            {
                var mapper = new BestellingDatamapper(context);
                await mapper.Insert(bestelling);
            }

            using (var context = new WebshopContext(_options))
            {
                var mapper = new BestellingDatamapper(context);
                var result = await mapper.Get(1);

                Assert.AreEqual("1", result.KlantId);
                Assert.AreEqual("Laagstraat 11", result.AdresRegel1);
                Assert.AreEqual("Laaghoven", result.Plaats);
                Assert.AreEqual("1234FG", result.Postcode);
                Assert.AreEqual(2, result.BesteldeArtikelen.Count);
                Assert.IsTrue(result.BesteldeArtikelen.Any(b => b.Artikel.Naam == "Fiets" && b.Aantal == 3));

                result.BestellingStatus = BestellingStatus.GereedVoorBehandeling;
                using (var context2 = new WebshopContext(_options))
                {
                    var mapper2 = new BestellingDatamapper(context2);
                    await mapper2.Update(result);
                }
            }

            using (var context = new WebshopContext(_options))
            {
                var mapper = new BestellingDatamapper(context);
                var result = await mapper.Get(1);

                Assert.AreEqual(BestellingStatus.GereedVoorBehandeling, result.BestellingStatus);
            }
        }
Exemple #2
0
        public async Task UpdateBestellingUpdatesIntoDatabase()
        {
            var bestelling = new Bestelling
            {
                KlantId           = "1",
                AdresRegel1       = "Laagstraat 11",
                Plaats            = "Laaghoven",
                Postcode          = "1234FG",
                BesteldeArtikelen = new List <BestellingItem>
                {
                    new BestellingItem(1, 3),
                    new BestellingItem(2, 5)
                }
            };

            using (var context = new BeheerContext(_options))
            {
                var mapper = new BestellingDatamapper(context);
                await mapper.Insert(bestelling);
            }

            bestelling.BestellingStatus = BestellingStatus.GereedVoorBehandeling;


            using (var context = new BeheerContext(_options))
            {
                var mapper = new BestellingDatamapper(context);
                await mapper.Update(bestelling);
            }


            using (var context = new BeheerContext(_options))
            {
                var mapper = new BestellingDatamapper(context);
                var result = await mapper.GetBestelling(1);

                Assert.AreEqual(BestellingStatus.GereedVoorBehandeling, result.BestellingStatus);
            }
        }