public async void Task_Add_InvalidData_Return_BadRequest() { //Arrange mediator.Setup(m => m.Send(It.IsAny <CreateDepenseCommand>(), CancellationToken.None)).Returns(Task.FromResult(0)); var controller = new DepensesController(mediator.Object); var command = new CreateDepenseCommand() { UserId = 1, Date = DateTime.Now, DeviseId = 1, Montant = 10, Commentaire = "comment" }; //Act var data = await controller.Create(command); //Assert Assert.IsType <BadRequestResult>(data); }
public async void Task_Add_ValidData_MatchResult() { //Arrange mediator.Setup(m => m.Send(It.IsAny <CreateDepenseCommand>(), CancellationToken.None)).Returns(Task.FromResult(1)); var controller = new DepensesController(mediator.Object); var command = new CreateDepenseCommand() { UserId = 1, Date = DateTime.Now, DeviseId = 1, Montant = 10, Commentaire = "comment" }; //Act var data = await controller.Create(command); //Assert Assert.IsType <OkObjectResult>(data); var okResult = data as OkObjectResult; Assert.Equal(1, okResult.Value); }