public async void Task_GetDepenses_MatchResult() { //Arrange var list = new List <Depense>() { new Depense() { Id = 3, UserId = 1, Date = DateTime.Now, DeviseId = 1, Montant = 10, NatureDepense = NatureDepense.Hotel, Commentaire = "comment" }, new Depense() { Id = 2, UserId = 2, Date = DateTime.Now, DeviseId = 1, Montant = 10, NatureDepense = NatureDepense.Hotel, Commentaire = "comment" } }; mediator.Setup(m => m.Send(It.IsAny <GetAllDepensesQuery>(), CancellationToken.None)).ReturnsAsync(list); var controller = new DepensesController(mediator.Object); //Act var data = await controller.GetAll(); //Assert Assert.IsType <OkObjectResult>(data); var okResult = data as OkObjectResult; var Depenses = okResult.Value as List <Depense>; Assert.Equal(3, Depenses[0].Id); }
public async void Task_GetDepenses_Return_null() { //Arrange mediator.Setup(m => m.Send(It.IsAny <GetAllDepensesQuery>(), CancellationToken.None)).ReturnsAsync((List <Depense>)null); var controller = new DepensesController(mediator.Object); //Act var data = await controller.GetAll(); var items = data as OkObjectResult; //Assert Assert.Null(items.Value); }