public async Task TryCreateLogin_ShouldCheckPasswordMinLength_Always(int minLength, string password, bool expected) { // Arrange var configBuilder = new AuthConfigBuilder(); configBuilder.Password.MinLength = minLength; var loginRepo = LoginRepoMock.Mock(false, false); var service = new AuthenticationService(loginRepo.Object, configBuilder.Get()); // Act var result = await service.TryCreateLogin("", password); // Assert Assert.Equal(expected, result.Password.MeetsMinLength); }
public async Task TryCreateLogin_ShouldCheckPasswordHasUppercase_WhenConfiguredToCheckForUppercase(string password, bool expected) { // Arrange var configBuilder = new AuthConfigBuilder(); configBuilder.Password.RequireUppercase = true; var loginRepo = LoginRepoMock.Mock(false, false); var service = new AuthenticationService(loginRepo.Object, configBuilder.Get()); // Act var result = await service.TryCreateLogin("", password); // Assert Assert.Equal(expected, result.Password.HasUppercase); }
public async Task TryCreateLogin_ShouldCheckUsernameMinLengthRequirements_Always(int minLength, string username, bool expected) { // Arrange var configBuilder = new AuthConfigBuilder(); configBuilder.Username.MinLength = minLength; var loginRepo = LoginRepoMock.Mock(false, false); var service = new AuthenticationService(loginRepo.Object, configBuilder.Get()); // Act var result = await service.TryCreateLogin(username, ""); // Assert Assert.Equal(expected, result.Username.MeetsMinLength); }
public async Task TryCreateLogin_ShouldReturnNullForPasswordHasSymbol_WhenConfiguredToNotCheckForSymbol(string password) { // Arrange var configBuilder = new AuthConfigBuilder(); configBuilder.Password.RequireSymbol = false; var loginRepo = LoginRepoMock.Mock(false, false); var service = new AuthenticationService(loginRepo.Object, configBuilder.Get()); // Act var result = await service.TryCreateLogin("", password); // Assert Assert.Null(result.Password.HasSymbol); }