public async Task AddAsync(UsuarioViewModel usuario)
        {
            var command = new AddUsuarioCommand(usuario.Email, usuario.Senha, usuario.PessoaId, usuario.Role);

            if (!command.IsValid())
            {
                await RaiseCommandValidationErrors(command);

                return;
            }

            await _mediatorHandler.SendCommand(command);
        }
Beispiel #2
0
        public async Task <IActionResult> Post(
            AddUsuarioCommand addUsuarioCommand)
        {
            try
            {
                await _mediator.Send(addUsuarioCommand);

                return(Ok());
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Beispiel #3
0
        public async Task deve_retornar_true()
        {
            //Arrange
            var addUsuarioCommand = new AddUsuarioCommand("Teste Usuario", "1234", Guid.NewGuid(), "Motorista");

            _mocker.GetMock <IUsuarioRepository>()
            .Setup(e => e.UnitOfWork)
            .Returns(_mocker.GetMock <IUnitOfWork>().Object);

            //Act
            var result = await _commandHanler.Handle(addUsuarioCommand, CancellationToken.None);

            //Assert
            _mocker.GetMock <IUsuarioRepository>().Verify(e => e.Add(It.IsAny <Usuario>()), Times.Once);
        }