Exemple #1
0
        public async void Task_GetDepenseById_Return_NotFoundResult()
        {
            //Arrange

            mediator.Setup(m => m.Send(It.IsAny <GetDepenseByIdQuery>(), CancellationToken.None)).ReturnsAsync((Depense)null);
            var controller = new DepensesController(mediator.Object);
            var DepenseId  = 3;

            //Act
            var data = await controller.GetById(DepenseId);

            //Assert
            Assert.IsType <NotFoundResult>(data);
        }
Exemple #2
0
        public async void Task_GetDepenseById_Return_OkResult()
        {
            //Arrange

            var item = new Depense()
            {
                Id = 3, UserId = 1, Date = DateTime.Now, DeviseId = 1, Montant = 10, NatureDepense = NatureDepense.Hotel, Commentaire = "comment"
            };

            mediator.Setup(m => m.Send(It.IsAny <GetDepenseByIdQuery>(), CancellationToken.None)).ReturnsAsync(item);
            var controller = new DepensesController(mediator.Object);

            //Act
            var data = await controller.GetById(3);

            //Assert
            Assert.IsType <OkObjectResult>(data);
        }