Exemple #1
0
        public async Task ThenDeBestellingNaarSalesWordtDoorgestuurd(string toestand)
        {
            using (var context = new BeheerContext(options))
            {
                BestellingDatamapper bestellingDatamapper = new BestellingDatamapper(context);
                var bestaandeBestelling = await bestellingDatamapper.GetBestelling(id);

                if (toestand == "wel")
                {
                    Assert.IsTrue(bestaandeBestelling.BestellingStatus == BestellingStatus.TerControleVoorSales);
                }
                else
                {
                    Assert.IsTrue(bestaandeBestelling.BestellingStatus == BestellingStatus.GereedVoorBehandeling);
                }
            }
        }
Exemple #2
0
        public async Task KeurBestellingGoedChangesBestellingToGereedVoorBehandeling()
        {
            using (var context = new BeheerContext(options))
            {
                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
                        }
                    }
                };
                var datamapper = new BestellingDatamapper(context);
                await datamapper.Insert(bestelling);
            }

            var commandPublisher = new CommandPublisher(_context);
            await commandPublisher.Publish <int>(new BestellingGoedkeurenCommand { Id = 1 },
                                                 NameConstants.BestellingGoedKeurenCommandQueue);

            Thread.Sleep(1000);

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

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

                var klantmapper = new KlantDatamapper(context);
                var klant       = await klantmapper.GetKlant("1");
            }
        }
Exemple #3
0
        public async Task NieuweBestellingThatGoesAboveKredietLimitGoesToSale()
        {
            var bestelling = new NieuweBestellingCommand
            {
                KlantId           = "1",
                AdresRegel1       = "Laagstraat 11",
                Plaats            = "Laaghoven",
                Postcode          = "1234FG",
                BesteldeArtikelen = new List <BestellingItem>
                {
                    new BestellingItem(1, 3),
                    new BestellingItem(2, 3)
                }
            };


            var commandPublisher = new CommandPublisher(_context);
            await commandPublisher.Publish <bool>(bestelling, NameConstants.NieuweBestellingCommandQueue);

            Thread.Sleep(500);

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

                Assert.AreEqual("Hans", result.Klant.Voornaam);
                Assert.AreEqual("Van Huizen", result.Klant.Achternaam);
                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.AreEqual(BestellingStatus.TerControleVoorSales, result.BestellingStatus);
                Assert.IsTrue(result.BesteldeArtikelen.Any(b => b.Artikel.Naam == "Fiets" && b.Aantal == 3));

                var klantMapper = new KlantDatamapper(context);
                var klant       = await klantMapper.GetKlant("1");

                //Krediet should not be added yet
                Assert.AreEqual(508.2m, klant.KredietMetSales);
            }
        }
Exemple #4
0
        public async Task InsertNieuweBestellingUnder500EuroFromEventSetsStatusToGereed()
        {
            var bestelling = new NieuweBestellingCommand
            {
                KlantId           = "1",
                AdresRegel1       = "Laagstraat 11",
                Plaats            = "Laaghoven",
                Postcode          = "1234FG",
                BesteldeArtikelen = new List <BestellingItem>
                {
                    new BestellingItem(1, 1),
                    new BestellingItem(2, 1)
                }
            };


            var commandPublisher = new CommandPublisher(_context);
            await commandPublisher.Publish <bool>(bestelling, NameConstants.NieuweBestellingCommandQueue);

            Thread.Sleep(500);

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

                Assert.AreEqual("Hans", result.Klant.Voornaam);
                Assert.AreEqual("Van Huizen", result.Klant.Achternaam);
                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.AreEqual(BestellingStatus.GereedVoorBehandeling, result.BestellingStatus);
                Assert.IsTrue(result.BesteldeArtikelen.Any(b => b.Artikel.Naam == "Fiets" && b.Aantal == 1));

                var klantMapper = new KlantDatamapper(context);
                var klant       = await klantMapper.GetKlant("1");

                Assert.AreEqual(169.4m, klant.KredietMetSales);
            }
        }
Exemple #5
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);
            }
        }
Exemple #6
0
        public async Task InsertBestellingIntoDatabase()
        {
            var bestelling = new Bestelling
            {
                BestellingStatus  = BestellingStatus.GereedVoorBehandeling,
                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);
            }

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

                Assert.AreEqual("Hans", result.Klant.Voornaam);
                Assert.AreEqual("Van Huizen", result.Klant.Achternaam);
                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.AreEqual(BestellingStatus.GereedVoorBehandeling, result.BestellingStatus);
                Assert.IsTrue(result.BesteldeArtikelen.Any(b => b.Artikel.Naam == "Fiets" && b.Aantal == 3));
            }
        }
Exemple #7
0
        public async Task VolgendeBestellingInpakkenGivesVolgendeBestellingSetsStatusToInbehandeling()
        {
            using (var context = new BeheerContext(options))
            {
                var bestelling = new Bestelling
                {
                    BestellingStatus  = BestellingStatus.GereedVoorBehandeling,
                    KlantId           = "1",
                    AdresRegel1       = "Laagstraat 11",
                    Plaats            = "Laaghoven",
                    Postcode          = "1234FG",
                    BesteldeArtikelen = new List <BestellingItem>
                    {
                        new BestellingItem(1, 3),
                        new BestellingItem(2, 5)
                    }
                };
                var bestelling2 = new Bestelling
                {
                    BestellingStatus  = BestellingStatus.GereedVoorBehandeling,
                    KlantId           = "1",
                    AdresRegel1       = "Hoogstraat 77",
                    Plaats            = "Hooghoven",
                    Postcode          = "4321FE",
                    BesteldeArtikelen = new List <BestellingItem>
                    {
                        new BestellingItem(1, 3),
                        new BestellingItem(2, 5)
                    }
                };

                var datamapper = new BestellingDatamapper(context);
                await datamapper.Insert(bestelling);

                await datamapper.Insert(bestelling2);
            }

            var commandPublisher = new CommandPublisher(_context);
            var result           = await commandPublisher.Publish <int>(new VolgendeBestellingCommand(),
                                                                        NameConstants.VolgendeBestellingCommandQueue);

            Assert.AreEqual(1, result);

            var result2 = await commandPublisher.Publish <int>(new VolgendeBestellingCommand(),
                                                               NameConstants.VolgendeBestellingCommandQueue);

            Assert.AreEqual(2, result2);

            var resultShouldbeZero = await commandPublisher.Publish <int>(new VolgendeBestellingCommand(),
                                                                          NameConstants.VolgendeBestellingCommandQueue);

            Assert.AreEqual(0, resultShouldbeZero);


            using (var context = new BeheerContext(options))
            {
                var bestellingDatamapper = new BestellingDatamapper(context);
                var bestelling           = await bestellingDatamapper.GetBestelling(1);

                Assert.AreEqual(BestellingStatus.InBehandelingDoorMagazijn, bestelling.BestellingStatus);
            }
        }