Пример #1
0
        public void Registration_fails_with_duplicate_emails()
        {
            var store = new UserRegistrationStore();
            var svc = new UserRegistrationService(store);

            svc.Register("*****@*****.**", "password");

            Assert.Throws<DbUpdateException>(() => svc.Register("*****@*****.**", "other"));
        }
Пример #2
0
        public void End_to_end_failed_login()
        {
            var store = new UserRegistrationStore();
            var svc = new UserRegistrationService(store);

            svc.Register("*****@*****.**", "password");

            Assert.Equal(Guid.Empty, svc.Login("*****@*****.**", "wrong"));
            Assert.Equal(Guid.Empty, svc.Login("*****@*****.**", "password"));
        }
Пример #3
0
        public void Password_is_saved()
        {
            var store = new UserRegistrationStore();
            var reg = new UserRegistration("*****@*****.**", "password");

            store.Save(reg);

            var stored = store.Users.FirstOrDefault(x => x.Id == reg.Id);

            Assert.NotNull(stored);
            Assert.True(stored.PasswordMatches("password"));
        }
Пример #4
0
        public void Password_is_hashed()
        {
            var store = new UserRegistrationStore();
            var reg = new UserRegistration("*****@*****.**", "password");

            store.Save(reg);

            var stored = store.Users.FirstOrDefault(x => x.Id == reg.Id);

            Assert.NotNull(stored);
            Assert.False(Encoding.UTF8.GetBytes("password").SequenceEqual(stored.Password));
        }
Пример #5
0
        public void End_to_end_success()
        {
            var store = new UserRegistrationStore();
            var svc = new UserRegistrationService(store);

            svc.Register("*****@*****.**", "password");

            var id = svc.Login("*****@*****.**", "password");
            Assert.NotEqual(Guid.Empty, id);

            var user = store.Users.FirstOrDefault(x => x.Id == id);
            Assert.Equal("*****@*****.**", user.Email);
        }
Пример #6
0
        public void UserRegistration_is_saved()
        {
            var store = new UserRegistrationStore();
            var reg = new UserRegistration("*****@*****.**", "password");

            store.Save(reg);

            var stored = store.Users.FirstOrDefault(x => x.Id == reg.Id);

            Assert.NotNull(stored);
            Assert.Equal("*****@*****.**", reg.Email);
        }
Пример #7
0
 public void Dispose()
 {
     // Clean up test data
     var store = new UserRegistrationStore().Database.ExecuteSqlCommand("delete from UserRegistrations");
 }