public void Fails_with_empty_inputs() { var store = new Mock<IUserRegistrationStore>(); var svc = new UserRegistrationService(store.Object); Assert.Throws<ArgumentNullException>(() => svc.Register(null, "password")); Assert.Throws<ArgumentNullException>(() => svc.Register("email", null)); }
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")); }
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")); }
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); }
public void Stores_new_UserRegistration() { var store = new Mock<IUserRegistrationStore>(); store.Setup(x => x.Save(It.IsAny<UserRegistration>())); var svc = new UserRegistrationService(store.Object); svc.Register("*****@*****.**", "password"); store.VerifyAll(); }
public void Stores_registration_with_email(string email, string password) { var store = new Mock<IUserRegistrationStore>(); store.Setup(x => x.Save(It.Is<UserRegistration>(r => r.Email == email))); var svc = new UserRegistrationService(store.Object); svc.Register(email, password); store.VerifyAll(); }