Ejemplo n.º 1
0
        public async Task VolgendeBestellingReturnsNotFoundWhenNoBestellingLeft()
        {
            var publisherMock = new Mock <ICommandPublisher>(MockBehavior.Strict);

            publisherMock.Setup(m => m.Publish <int>(It.IsAny <VolgendeBestellingCommand>(),
                                                     NameConstants.VolgendeBestellingCommandQueue, ""))
            .ReturnsAsync(0).Verifiable();

            var datamapperMock = new Mock <IBestellingDatamapper>(MockBehavior.Strict);


            var controller = new BestellingenController(publisherMock.Object, datamapperMock.Object);

            var result = await controller.VolgendeBestelling();

            Assert.IsInstanceOfType(result, typeof(NotFoundResult));
        }
Ejemplo n.º 2
0
        public async Task VolgendeBestellingReturnsVolgendeBestellingObject()
        {
            var publisherMock = new Mock <ICommandPublisher>(MockBehavior.Strict);

            publisherMock.Setup(m => m.Publish <int>(It.IsAny <VolgendeBestellingCommand>(),
                                                     NameConstants.VolgendeBestellingCommandQueue, ""))
            .ReturnsAsync(1).Verifiable();

            var datamapperMock = new Mock <IBestellingDatamapper>(MockBehavior.Strict);

            datamapperMock.Setup(d => d.Get(1)).ReturnsAsync(new Bestelling
            {
                Id                = 1,
                KlantId           = "1",
                AdresRegel1       = "Laagstraat 11",
                Plaats            = "Laaghoven",
                Postcode          = "1234FG",
                BesteldeArtikelen = new List <BestellingItem>
                {
                    new BestellingItem(1, 3),
                    new BestellingItem(2, 5)
                }
            }).Verifiable();

            var controller = new BestellingenController(publisherMock.Object, datamapperMock.Object);

            var result = await controller.VolgendeBestelling();

            var okResult = result as OkObjectResult;

            Assert.IsNotNull(okResult);

            var bestelling = (Bestelling)okResult.Value;

            Assert.AreEqual(1, bestelling.Id);
            Assert.AreEqual("1", bestelling.KlantId);
        }