public void GetByUserId_LoginDoesNotExist() { var repository = new LoginAuthenticationRepository(_contextFactory); var loginAuthentication = repository.GetByUserId(long.MaxValue); Assert.IsNull(loginAuthentication); }
public void GetByUserId_LoginExists() { var userRepository = new UserRepository(_contextFactory); var authenticationRepository = new LoginAuthenticationRepository(_contextFactory); var user = new User { Name = "name", Email = "email" }; var userId = userRepository.Create(user); var initalLoginAuth = new LoginAuthentication { UserId = userId, LoginName = "login", PasswordHash = Enumerable.Range(0, 32).Select(i => (byte)i).ToArray(), Salt = Enumerable.Range(0, 16).Select(i => (byte)i).ToArray() }; authenticationRepository.Save(initalLoginAuth); var restoredLoginAuthentication = authenticationRepository.GetByUserId(initalLoginAuth.UserId); Assert.NotNull(restoredLoginAuthentication); Assert.AreEqual(initalLoginAuth.UserId, restoredLoginAuthentication.UserId); Assert.AreEqual(initalLoginAuth.LoginName, restoredLoginAuthentication.LoginName); CollectionAssert.AreEqual(initalLoginAuth.Salt, restoredLoginAuthentication.Salt); CollectionAssert.AreEqual(initalLoginAuth.PasswordHash, restoredLoginAuthentication.PasswordHash); }
public void GetByUserId_InvalidUserIdPassed(long userId) { var repository = new LoginAuthenticationRepository(_contextFactory); repository.GetByUserId(userId); }