public async Task Register(StudentRegisterContract contract) { var user = _mapper.Map(contract); var result = await _userManager.CreateAsync(user, contract.Password); if (result.Succeeded) { await _signInManager.SignInAsync(user, false); } }
public async Task RegisteringStudent_Then_MapperCalled() { // Arrange var contract = new StudentRegisterContract { Email = "*****@*****.**", Password = "******", FirstName = "name", LastName = "surname", GitLink = "gitLink", GroupId = 1 }; var student = new Student { Email = "*****@*****.**", UserName = "******", FirstName = "name", LastName = "surname", GroupId = 1, GitLink = "gitLink" }; _mapper.Map(contract).Returns(student); _userManager.CreateAsync(student, contract.Password).Returns(IdentityResult.Success); // Act await _usersApi.Register(contract); // Assert _mapper.Received().Map(contract); }