public void Dever_Encontrar_Usuario_Pelo_Id()
        {
            var user = fakeData.FirstOrDefault();

            Assert.NotNull(user);

            var changed = appService.GetById(user.Id);

            Assert.NotNull(changed);
        }
Exemple #2
0
 public ActionResult <UserModel> Get(int id)
 {
     try
     {
         return(Ok(_userAppService.GetById(id)));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, ex));
     }
 }
Exemple #3
0
 public IActionResult GetById(int userId)
 {
     try
     {
         var user = _userAppService.GetById(userId);
         return(Ok(user));
     }
     catch (NotFoundException)
     {
         return(NotFound());
     }
 }
        public void Should_Get_By_Id()
        {
            var service    = new UserService(_repository);
            var appService = new UserAppService(service, _mapper);
            var actual     = appService.Find(a => a.Id == fakeData[0].Id).FirstOrDefault();

            Assert.NotNull(actual);

            var changed = appService.GetById(actual.Id);

            Assert.NotNull(changed);
        }
Exemple #5
0
 public User Get(int id)
 {
     try
     {
         _logger.Trace("User/Get - {0}", id);
         return(_userAppService.GetById(id));
     }
     catch (Exception ex)
     {
         _logger.Error(ex, String.Format("ERROR: User/Get id: {0}", id));
         throw;
     }
 }
Exemple #6
0
        public void ApplService_user_deveria_retornar_usuario()
        {
            //Arrange
            User user = ObjectMother.userDefault;

            user.GeneratePassword("123");
            _repository.Setup(x => x.GetById(It.IsAny <long>())).Returns(user);

            //Action
            User userResult = _appService.GetById(user.Id);

            //Assert
            _repository.Verify(p => p.GetById(It.IsAny <long>()), Times.Once());
            userResult.Should().NotBeNull();
            userResult.Id.Should().Be(user.Id);
            _repository.VerifyNoOtherCalls();
        }