public async Task PostNaoDeveAdicionarSalarioBadRequest() { var model = new AddSalarioCommandView(); var addSalarioCommand = new AddSalarioCommand(); _notificationMock.Setup(x => x.HasNotifications()).Returns(true); _mapperMock.Setup(x => x.Map <AddSalarioCommand>(model)).Returns(addSalarioCommand); _mediatorMock.Setup(x => x.Send(addSalarioCommand, default)).ReturnsAsync(false); var viewResult = (await _controller.PostAsync(model)) as ObjectResult; viewResult.StatusCode.Should().Be(400); viewResult.Should().BeOfType <ObjectResult>(); }
public async Task DeveValidarSalarioAntesDeIncluir() { var command = new AddSalarioCommand { }; var resultado = await _mediator.Send(command); resultado.Should().BeFalse(); _notifications.HasNotifications().Should().BeTrue(); _notifications.GetNotifications().Should().HaveCount(2); var resultadoBusca = await _salarioRepository.GetAllAsync(); resultadoBusca.FirstOrDefault().Should().BeNull(); }
public async Task PostDeveAdicionarSalarioOkResult() { var model = new AddSalarioCommandView { Adiantamento = decimal.One, Pagamento = decimal.One }; var addSalarioCommand = new AddSalarioCommand { Adiantamento = decimal.One, Pagamento = decimal.One }; _notificationMock.Setup(x => x.HasNotifications()).Returns(false); _mapperMock.Setup(x => x.Map <AddSalarioCommand>(model)).Returns(addSalarioCommand); _mediatorMock.Setup(x => x.Send(addSalarioCommand, default)).ReturnsAsync(true); var viewResult = (await _controller.PostAsync(model)) as ObjectResult; viewResult.StatusCode.Should().Be(200); viewResult.Should().BeOfType <ObjectResult>(); }
public async Task DeveIncluirUmSalario() { var command = new AddSalarioCommand { Pagamento = 1200.24M, Adiantamento = 800.60M }; var resultado = await _mediator.Send(command); resultado.Should().BeTrue(); _notifications.HasNotifications().Should().BeFalse(); _notifications.GetNotifications().Should().HaveCount(0); var resultadoBusca = (await _salarioRepository.GetAllAsync()).FirstOrDefault(x => x.Pagamento == command.Pagamento); resultadoBusca.Should().NotBeNull(); resultadoBusca.Pagamento.Should().Be(command.Pagamento); resultadoBusca.Adiantamento.Should().Be(command.Adiantamento); resultadoBusca.Status.Should().BeTrue(); }