public async Task GetUserAsync_ShouldReturnInitiative_WhenUserExists() { //Arrange var userId = Guid.NewGuid(); var mockUser = new ApplicationUser { Id = userId.ToString(), FirstName = "Xian", LastName = "User", Designation = "Software Engineer" }; var mockDto = new UserForProfileDto { Id = userId.ToString(), FirstName = "Xian", LastName = "User", Designation = "Software Engineer" }; _mockMapper.Setup(x => x.Map <UserForProfileDto>(It.IsAny <ApplicationUser>())).Returns(mockDto); _mockUnitOfWork.Setup(x => x.User.GetUser(userId.ToString())).ReturnsAsync(mockUser); //Act var result = await _service.GetUserAsync(userId.ToString()); //Assert Assert.Equal(userId.ToString(), result.Id.ToString()); }
public async Task <IActionResult> Get(UserForProfileDto userForProfileDto) { using (SqlConnection connection = new SqlConnection(configuration.GetConnectionString("DefaultConnection"))) { var values = await connection.QueryFirstAsync <UserProfile>(String.Format("SELECT * FROM TableUserProfiles WHERE Username like '{0}'", userForProfileDto.Username)); return(Ok(values)); } }
public async Task <IActionResult> Get(UserForProfileDto userForProfileDto) { var values = await _context.TableUserProfiles.FirstOrDefaultAsync(x => x.Username == userForProfileDto.Username); return(Ok(values)); }
public void WhenCalled_ReturnCurrentUserInfo() { var currentUserInfo = new UserForProfileDto(); _service.Setup(x => x.GetCurrentUserInfo(default))