Exemplo n.º 1
0
        public async Task <IActionResult> Register([FromBody] UserRxDto userReceivedDto)
        {
            // map dto to entity
            UserEntity user = _mapper.Map <UserEntity>(userReceivedDto);

            try
            {
                // save
                await _userProcessor.Create(user, userReceivedDto.Password);

                return(Ok());
            }
            catch (Exception ex)
            {
                // return error message if there was an exception
                return(BadRequest(new { message = ex.Message }));
            }
        }
Exemplo n.º 2
0
        public void RegisterNullEntityTest()
        {
            // Arrange
            UserRxDto user = new UserRxDto
            {
                Username = "******",
                Phone    = "0000",
                Email    = "*****@*****.**",
                Password = "******"
            };

            _mockMapper.Setup(m => m.Map <UserEntity>(It.IsAny <UserRxDto>())).Returns((UserEntity)null).Verifiable();
            _mockUserProcessor.Setup(m => m.Create(It.IsAny <UserEntity>(), It.IsAny <string>())).ReturnsAsync(It.IsAny <UserEntity>()).Verifiable();


            // Act
            IActionResult result = _usersController.Register(user).Result;

            // Assert
            Assert.IsNotNull(result);
            _mockMapper.Verify(m => m.Map <UserEntity>(user), Times.Once);
            _mockUserProcessor.Verify(m => m.Create(It.IsAny <UserEntity>(), user.Password), Times.Once);
        }
Exemplo n.º 3
0
 public async Task <IActionResult> Update([Required] string id, [FromBody] UserRxDto userReceivedDto)
 {
     return(Ok());
 }
Exemplo n.º 4
0
 public async Task <IActionResult> Authenticate([FromBody] UserRxDto userReceivedDto)
 {
     return(Ok());
 }