public void GetUser() { //-- arrange var user = new User { FirstName = "fname", LastName = "lname", EmailAddress = "email@users", Password = "******" }; _repository.AddUser(user); _repository.Save(); //-- act var actual = _repository.GetUser(1); //-- assert Assert.AreEqual("fname", actual.FirstName); //-- cleanup _repository.DeleteUser(user); _repository.Save(); }
public IActionResult GetUser(int userId, [FromHeader(Name = nameof(HeaderNames.Accept))] string mediaType) { var userEntity = _weblogDataRepository.GetUser(userId); if (userEntity is null) { return(NotFound()); } var userToReturn = _mapper.Map <UserDto>(userEntity); var includeLinks = MediaTypes.IncludeLinks(mediaType); if (!includeLinks) { return(Ok(userToReturn)); } var userWithLinks = new UserDtoWithLinks (userToReturn, CreateLinksForUser(userId)); return(Ok(userWithLinks)); }