Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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());
            }
        }
Beispiel #3
0
        [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>();
            }
        }
Beispiel #4
0
        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>();
            }
        }
Beispiel #5
0
        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>();
            }
        }
Beispiel #6
0
        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>();
            }
        }