public async Task GetNextBestelling_ShouldReturnOldestBestellingenWithStatusGoedgekeurd() { long expectedFactuurnummer = 2; var receiver = _nijnContext.CreateCommandReceiver(NameConstants.BestelServiceUpdateBestelStatusCommandQueue); receiver.DeclareCommandQueue(); receiver.StartReceivingCommands(request => new ResponseCommandMessage($"{expectedFactuurnummer}", "Long", request.CorrelationId)); _jwtHelperMock.Setup(j => j.GetEmail(It.IsAny <HttpContext>())).Returns("Email"); var result = await _target.GetNextBestelling(); var queue = _nijnContext.CommandBus.Queues[NameConstants.BestelServiceUpdateBestelStatusCommandQueue]; _jwtHelperMock.VerifyAll(); Assert.IsNotNull(result); Assert.AreEqual(1, queue.CalledTimes); Assert.AreEqual(expectedFactuurnummer, result.Value.Factuurnummer); }
public void ShouldHandlePlaatsBestellingCommand() { var queueName = "PlaatsOrderQueue"; _nijnHost.EventBus.DeclareQueue(queueName, new List <string> { NameConstants.BestelServiceBestellingGeplaatstEvent }); var bestellingCM = new BestellingCM { Klantnummer = 1234, ContactInfo = new ContactInfoCM { Naam = "Pieter Pas", Email = "*****@*****.**", Telefoonnummer = "1234567890" }, Afleveradres = new AfleveradresCM { Adres = "Straat 1", Plaats = "Plaats", Postcode = "1234 AB", Land = "Nederland" }, BestelRegels = new List <BestelRegelCM> { new BestelRegelCM { Artikelnummer = 1, Aantal = 42, } } }; var receiver = _nijnHost.CreateCommandReceiver(NameConstants.MagazijnServiceCommandQueue); receiver.DeclareCommandQueue(); receiver.StartReceivingCommands(request => new ResponseCommandMessage(JsonConvert.SerializeObject(true), "boolean", request.CorrelationId)); var requestCommand = new PlaatsBestellingCommand(bestellingCM, NameConstants.BestelServicePlaatsBestellingCommandQueue); _target.HandlePlaatsBestelling(requestCommand); var result = _context.Bestellingen.Include(b => b.BestelRegels).SingleOrDefault(b => b.Id == 1); Assert.IsNotNull(result, "result != null"); Assert.AreEqual(1234, result.Klantnummer); Assert.AreEqual(DateTime.Now.Date, result.Besteldatum.Date); Assert.AreEqual(1, result.Factuurnummer); Assert.AreEqual(BestelStatus.Geplaatst, result.BestelStatus); Assert.AreEqual(bestellingCM.ContactInfo.Naam, result.ContactInfo.Naam); Assert.AreEqual(bestellingCM.ContactInfo.Email, result.ContactInfo.Email); Assert.AreEqual(bestellingCM.ContactInfo.Telefoonnummer, result.ContactInfo.Telefoonnummer); Assert.AreEqual(bestellingCM.Afleveradres.Adres, result.Afleveradres.Adres); Assert.AreEqual(bestellingCM.Afleveradres.Postcode, result.Afleveradres.Postcode); Assert.AreEqual(bestellingCM.Afleveradres.Plaats, result.Afleveradres.Plaats); Assert.AreEqual(bestellingCM.Afleveradres.Land, result.Afleveradres.Land); Assert.AreEqual(1, result.BestelRegels.Count); Assert.IsTrue(result.BestelRegels.Any(b => b.Id == 1 && b.Artikelnummer == 1 && b.Naam == "Fietsband" && b.PrijsExclBtw == 12.95m), "Should contain BestelRegel"); Assert.AreEqual(1, _nijnHost.EventBus.Queues[queueName].MessageQueueLength); }