public async Task GetNextBestelling_ShouldCallBestellingDataMapperWithExpression()
        {
            // Arrange
            BevestigdeBestellingBuilder builder = new BevestigdeBestellingBuilder();
            var bestellingen = new List <BevestigdeBestelling>
            {
                builder.SetDummy()
                .SetFactuurnummer(1)
                .SetBesteldatum(new DateTime(2018, 11, 10))
                .Create(),

                builder.SetDummy()
                .SetFactuurnummer(2)
                .SetBesteldatum(new DateTime(2018, 11, 11))
                .Create(),
            };

            _jwtHelperMock.Setup(j => j.GetEmail(It.IsAny <HttpContext>())).Returns("email");
            _magazijnSessionDataMapperMock.Setup(m => m.Find(It.IsAny <Expression <Func <MagazijnSessionEntity, bool> > >()))
            .Returns(new List <MagazijnSessionEntity>());

            _magazijnSessionDataMapperMock.Setup(m => m.Insert(It.Is <MagazijnSessionEntity>(e =>
                                                                                             e.MedewerkerEmail == "email" && e.Factuurnummer == 1
                                                                                             ))).Returns(new MagazijnSessionEntity());

            _bestellingDataMapperMock.Setup(d => d.Find(It.IsAny <Expression <Func <BevestigdeBestelling, bool> > >()))
            .Returns(bestellingen);

            _commandPublisherMock.Setup(publisher => publisher.Publish <long>(It.IsAny <UpdateBestelStatusCommand>()))
            .ReturnsAsync(1);

            // Act
            var result = await _target.GetNextBestelling();

            // Assert
            _jwtHelperMock.VerifyAll();
            _magazijnSessionDataMapperMock.VerifyAll();
            _bestellingDataMapperMock.VerifyAll();
            _commandPublisherMock.VerifyAll();

            Assert.IsNotNull(result);
            Assert.AreEqual(bestellingen.First(), result.Value);
        }
        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);
        }