Inheritance: IUserService
Example #1
0
 private static void PerformInitialSetup(IDocumentSession session)
 {
     IUserService userService = new UserService(session);
     if (!userService.DoesUserExistWithUsername("robashton"))
     {
         User newUser = new User("robashton", "password");
         IUserRepository userRepository = new UserRepository(session);
         userRepository.Add(newUser);
     }
     session.SaveChanges();
 }
        public void WhenUserExists_DoesUserExistWithUsernameAndPassword_ReturnsTrue()
        {
            using (var session = Store.OpenSession())
            {
                session.Store(new UserDocument()
                {
                    PasswordHash = HashUtil.HashPassword("password"),
                    Username = "******"
                });
                session.SaveChanges();
                WaitForIndexing();

                UserService service = new UserService(session);
                bool result = service.DoesUserExistWithUsernameAndPassword("testUser", "password");
                Assert.True(result);
            }
        }
        public void WhenUserDoesNotExist_DoesUserExistWithUsername_ReturnsFalse()
        {
            using (var session = Store.OpenSession())
            {
                session.Store(new UserDocument()
                {
                    PasswordHash = "pass",
                    Username = "******"
                });
                session.SaveChanges();
                WaitForIndexing();

                UserService service = new UserService(session);
                bool result = service.DoesUserExistWithUsername("testOtherUser");
                Assert.False(result);
            }
        }