public async void ObterPorId_DeveRetornarBadRequest() { // Arrange var pagamentoAppService = new Mock <IPagamentoAppService>(); var notificador = new Mock <INotificador>(); var cache = new Mock <IDistributedCache>(); var pagamentoDtoEsperado = new PagamentoDTO() { DataCadastro = DateTimeOffset.Now, IdPagamento = Guid.NewGuid(), ValorPagamento = 1, ValorPagoCliente = 1, ValorTroco = 0, TrocoItems = new List <TrocoItemDTO>() }; pagamentoAppService.Setup(appService => appService.BuscarPorId(pagamentoDtoEsperado.IdPagamento)) .ReturnsAsync(pagamentoDtoEsperado); notificador.Setup(n => n.TemNotificacao()).Returns(true); notificador.Setup(n => n.ObterNotificacoes()).Returns(new List <Notificacao>() { new Notificacao("erro 1"), new Notificacao("erro 2") }); var controller = new PagamentoController(pagamentoAppService.Object, notificador.Object, cache.Object); // Act var retorno = await controller.BuscarPorId(pagamentoDtoEsperado.IdPagamento); // Assert Assert.IsType <ActionResult <PagamentoDTO> >(retorno); Assert.IsType <BadRequestObjectResult>(retorno.Result); }
public async void ObterPorId_DeveRetornarNotFound() { // Arrange var pagamentoAppService = new Mock <IPagamentoAppService>(); var notificador = new Mock <INotificador>(); var cache = new Mock <IDistributedCache>(); var controller = new PagamentoController(pagamentoAppService.Object, notificador.Object, cache.Object); // Act var retorno = await controller.BuscarPorId(Guid.NewGuid()); // Assert Assert.IsType <ActionResult <PagamentoDTO> >(retorno); Assert.IsType <NotFoundResult>(retorno.Result); }