예제 #1
0
 public void should_create_unique_admin_user()
 {
     var userRepository = new MemoryRepository<User>();
     var userCreationService = new UserCreateService(userRepository);
     var user = userCreationService.Create(Username, Password, Email, true, "");
     user.Administrator.ShouldBeTrue();
 }
예제 #2
0
 public void should_create_user_password_hash()
 {
     var userRepository = new MemoryRepository<User>();
     var userCreationService = new UserCreateService(userRepository);
     var user = userCreationService.Create(Username, Password, Email, false, "");
     user.PasswordHash.ShouldNotBeNull();
     user.PasswordHash.ShouldNotBeEmpty();
     user.PasswordHash.ShouldNotEqual(Password);
 }
예제 #3
0
 public void should_create_unique_non_admin_user()
 {
     var userRepository = new MemoryRepository<User>();
     var userCreationService = new UserCreateService(userRepository);
     var user = userCreationService.Create(Username, Password, Email, false, "");
     userRepository.Count().ShouldEqual(1);
     userRepository.First().ShouldEqual(user);
     user.Username.ShouldEqual(Username.ToLower());
     user.Administrator.ShouldBeFalse();
     user.Email.ShouldEqual(Email);
 }
예제 #4
0
 public void generate_users()
 {
     var users = new UserCreateService(new MongoRepository<User>(new MongoConnection(Constants.VoltaAcceptanceConnectionString)));
     Enumerable.Range(1, 50).ToList().ForEach(x => users.Create(string.Format("testuser{0}", x), "t3$t", string.Format("test{0}@test.com", x), x % 5 == 0, "test"));
 }
예제 #5
0
 public void should_not_create_user_with_empty_username()
 {
     var userCreationService = new UserCreateService(new MemoryRepository<User>());
     Assert.Throws<EmptyUsernameException>(() => userCreationService.Create(string.Empty, Password, Email, false, ""));
 }
예제 #6
0
 public void should_not_create_user_with_duplicate_differently_cased_usernames()
 {
     var userRepository = new MemoryRepository<User>(new User { Username = Username.ToUpper() });
     var userCreationService = new UserCreateService(userRepository);
     Assert.Throws<DuplicateUsernameException>(() => userCreationService.Create(Username.ToLower(), Password, Email, false, ""));
 }