public async Task GivenUniqueEmailAndValidPasswordUserShouldBeRegistered() { using (var context = new CinemaDbContextFactory().CreateContext()) { SetUp(context); var newValidEmail = "*****@*****.**"; var newValidPassword = "******"; await UserService.RegisterAsync(newValidEmail, User.FirstName, User.LastName, newValidPassword, User.Role, User.PhoneNumber); } }
public async Task GivenValidCredentialsUserShouldBeLogged() { using (var context = new CinemaDbContextFactory().CreateContext()) { SetUp(context); var email = User.Email; var password = User.Password; await UserService.LoginAsync(email, password); TokenProviderMock.Verify(m => m.CreateToken(It.IsAny <int>(), User.Role), Times.Once()); } }
[InlineData("ABCKdada")] //no number public void GivenInvalidPasswordExceptionShouldBeThrown(string password) { using (var context = new CinemaDbContextFactory().CreateContext()) { SetUp(context); Func <Task> fun = async() => { await UserService.RegisterAsync(User.Email, User.FirstName, User.LastName, password, User.Role, User.PhoneNumber); }; fun.ShouldThrow <CinemaException>(); } }
public void GivenInvalidPasswordExceptionShouldBeThrown() { using (var context = new CinemaDbContextFactory().CreateContext()) { SetUp(context); var email = User.Email; var invalidPassword = "******"; Func <Task> fun = async() => { await UserService.LoginAsync(email, invalidPassword); }; fun.ShouldThrow <CinemaException>(); } }
public void GivenInvalidEmailExceptionShouldBeThrown() { using (var context = new CinemaDbContextFactory().CreateContext()) { SetUp(context); var invalidEmail = "*****@*****.**"; var password = User.Password; Func <Task> fun = async() => { await UserService.LoginAsync(invalidEmail, password); }; fun.ShouldThrow <CinemaException>(); } }
public void GivenOccupiedEmailExceptionShouldBeThrown() { using (var context = new CinemaDbContextFactory().CreateContext()) { SetUp(context); context.Users.Add(User); context.SaveChanges(); var occupiedEmail = User.Email; Func <Task> fun = async() => { await UserService.RegisterAsync(occupiedEmail, User.FirstName, User.LastName, User.Password, User.Role, User.PhoneNumber); }; fun.ShouldThrow <CinemaException>(); } }