示例#1
0
        public async Task DeveExcluirSalarioPeloIdSalario()
        {
            var salario = new Salario(12345.42M, 54321.24M)
                          .AtualizarStatus(true);

            var command = new DeleteSalarioCommand
            {
                Id     = salario.Id,
                Status = false
            };

            await _fixture.CriarAsync(salario);

            var resultado = await _mediator.Send(command);

            resultado.Should().BeTrue();
            _notifications.HasNotifications().Should().BeFalse();
            _notifications.GetNotifications().Should().HaveCount(0);

            var resultadoBusca = await _fixture.BuscarAsync <Salario>(x => x.Id == salario.Id);

            resultadoBusca.Should().NotBeNull();
            resultadoBusca.Id.Should().Be(salario.Id);
            resultadoBusca.Pagamento.Should().Be(salario.Pagamento);
            resultadoBusca.Adiantamento.Should().Be(salario.Adiantamento);
            resultadoBusca.Status.Should().BeFalse();
        }
        public async Task DeleteNaoDeveExcluirSalarioBadRequest()
        {
            var model          = new DeleteSalarioCommandView();
            var salarioCommand = new DeleteSalarioCommand();

            _notificationMock.Setup(x => x.HasNotifications()).Returns(true);
            _mapperMock.Setup(x => x.Map <DeleteSalarioCommand>(model)).Returns(salarioCommand);
            _mediatorMock.Setup(x => x.Send(salarioCommand, default)).ReturnsAsync(false);

            var viewResult = (await _controller.DeleteAsync(model)) as ObjectResult;

            viewResult.StatusCode.Should().Be(400);
            viewResult.Should().BeOfType <ObjectResult>();
        }
示例#3
0
        public async Task DeveValidarSalarioAntesDeExcluir()
        {
            await _fixture.CriarAsync(new Salario(12345.42M, 54321.24M).AtualizarStatus(true));

            var command = new DeleteSalarioCommand {
                Status = true
            };
            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().Status.Should().BeTrue();
        }
示例#4
0
        public async Task DeveValidarSeBuscaRetornouDadosParaoIdSalario()
        {
            var command = new DeleteSalarioCommand
            {
                Id     = new Guid("10AFDB5E-D7D1-4773-B040-F7B6F610484F"),
                Status = false
            };

            var resultado = await _mediator.Send(command);

            resultado.Should().BeTrue();
            _notifications.HasNotifications().Should().BeFalse();
            _notifications.GetNotifications().Should().HaveCount(0);

            var resultadoBusca = await _salarioRepository.GetByIdAsync(command.Id);

            resultadoBusca.Should().BeNull();
        }
        public async Task DeleteDeveExcluirSalarioOkResult()
        {
            var model = new DeleteSalarioCommandView
            {
                Id     = new Guid("10AFDB5E-D7D1-4773-B040-F7B6F610484F"),
                Status = false
            };
            var salarioCommand = new DeleteSalarioCommand
            {
                Id     = new Guid("10AFDB5E-D7D1-4773-B040-F7B6F610484F"),
                Status = false
            };

            _notificationMock.Setup(x => x.HasNotifications()).Returns(false);
            _mapperMock.Setup(x => x.Map <DeleteSalarioCommand>(model)).Returns(salarioCommand);
            _mediatorMock.Setup(x => x.Send(salarioCommand, default)).ReturnsAsync(true);

            var viewResult = (await _controller.DeleteAsync(model)) as ObjectResult;

            viewResult.StatusCode.Should().Be(200);
            viewResult.Should().BeOfType <ObjectResult>();
        }