public async Task GetInformationFroMyProfileAsyncSuccessReturnDtoWithoutScientificWork() { var userId = 1u; var user = new User() { Id = userId, Name = _faker.Person.FirstName, Surname = _faker.Person.LastName, Email = _faker.Person.Email, Degree = _faker.Name.JobTitle(), University = _faker.Company.CompanyName(), Specialization = _faker.Commerce.Categories(1)[0], UserName = UserHelper.GetUserName(UserTypeEnum.Participant, _faker.Person.Email) }; var expectedDto = _mapper.Map <MyProfileUserDto>(user); MyProfileUserDto returnedDto = null; _userManagerMock.Setup(x => x.FindByIdAsync(userId.ToString())).ReturnsAsync(user); _scientificWorkRepositoryMock.Setup(x => x.GetByAuthorIdAsync(userId)).ReturnsAsync((ScientificWork)null); var err = await Record.ExceptionAsync(async() => returnedDto = await _userService.GetInformationForMyProfileAsync(userId.ToString())); err.Should().BeNull(); returnedDto.Should().NotBeNull(); returnedDto.Should().BeEquivalentTo(expectedDto); _userManagerMock.Verify(x => x.FindByIdAsync(userId.ToString()), Times.Once); _scientificWorkRepositoryMock.Verify(x => x.GetByAuthorIdAsync(userId), Times.Once); }
public void MapUserToMyProfileUserDto() { var expected = new MyProfileUserDto() { Name = user.Name, Surname = user.Surname, AcademicTitle = user.Degree, Email = user.Email, Specialization = user.Specialization, Role = UserHelper.GetRole(user), University = user.University }; var returned = _mapper.Map <MyProfileUserDto>(user); returned.Should().BeEquivalentTo(expected); }