private static List <User> CreateUsers(int amountOfUsers, string firstName, TestType testType) { var users = new List <User>(); for (var i = 0; i < amountOfUsers; i++) { var number = i + 1; var lastName = EjudUserData.LAST_NAME(number); var displayName = EjudUserData.DISPLAY_NAME(firstName, lastName); var username = EjudUserData.USERNAME(firstName, lastName, DOMAIN); var contactEmail = EjudUserData.CONTACT_EMAIL(firstName, lastName, DOMAIN); users.Add(new User { Application = Application.Ejud, ContactEmail = contactEmail, CreatedDate = DateTime.UtcNow, DisplayName = displayName, FirstName = firstName, IsProdUser = false, LastName = lastName, Number = number, TestType = testType, Username = username, UserType = UserType.Judge }); } return(users); }
public void Should_throw_error_if_test_default_password_not_found() { var username = EjudUserData.USERNAME(EjudUserData.AUTOMATED_FIRST_NAME_PREFIX, EjudUserData.LAST_NAME(1), EjudUserData.FAKE_EJUD_DOMAIN); var request = new ResetUserPasswordRequest() { Username = username }; Configuration .Setup(x => x.GetSection("TestDefaultPassword").Value) .Returns(() => null); Assert.ThrowsAsync <ConfigurationErrorsException>(async() => await Controller.ResetUserPassword(request)); }
public async Task Should_return_test_password_for_ejud_users() { var username = EjudUserData.USERNAME(EjudUserData.AUTOMATED_FIRST_NAME_PREFIX, EjudUserData.LAST_NAME(1), EjudUserData.FAKE_EJUD_DOMAIN); var request = new ResetUserPasswordRequest() { Username = username }; var result = await Controller.ResetUserPassword(request); var objectResult = (OkObjectResult)result; objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK); var passwordResponse = (UpdateUserResponse)objectResult.Value; passwordResponse.NewPassword.Should().Be(EjudUserData.FAKE_PASSWORD); }
public UserDto BuildUserDto() { var firstName = SetFirstName(); var lastName = EjudUserData.LAST_NAME(_number); var displayName = EjudUserData.DISPLAY_NAME(firstName, lastName); var contactEmail = EjudUserData.CONTACT_EMAIL(firstName, lastName, _emailStem); var username = EjudUserData.USERNAME(firstName, lastName, _emailStem); return(new UserDto() { Application = Application.Ejud, ContactEmail = contactEmail, CreatedDate = DateTime.UtcNow, DisplayName = displayName, FirstName = firstName, IsProdUser = false, LastName = lastName, Number = _number, TestType = _testType, Username = username, UserType = _userType }); }