Exemple #1
0
        public void ButtonClicked(UserViewModel userViewModel, bool isRegister)
        {

            var authRepo = new AuthorisationRepository();

            if (isRegister)
            {
                var user = authRepo.Register(userViewModel);

                if (user != null)
                {
                    ShowMainForm(user);
                }
                else
                {
                    MessageBox.Show("Email already in use. Try login instead");
                }
            }
            else
            {
                var user = authRepo.Login(userViewModel);

                if (user != null)
                {
                    ShowMainForm(user);
                }
                else
                {
                    MessageBox.Show("Login failed. Incorrect credentials");
                }
            }

        }
Exemple #2
0
        public void LoginTest()
        {
            // Setups container and session factory
            Program.SetSessionFactory(true);

            var authorizationRepo = new AuthorisationRepository();

            var userViewModel = Create();

            // Creates new user
            Assert.NotNull(authorizationRepo.Register(userViewModel));

            // Logs in the user
            var logedUser = authorizationRepo.Login(userViewModel);

            Assert.NotNull(logedUser);
        }
Exemple #3
0
        public void DoubleRegisterTest()
        {
            // Setups container and session factory
            Program.SetSessionFactory(true);

            var authorizationRepo = new AuthorisationRepository();

            var userViewModel = Create();
            // Creates new user
            Assert.NotNull(authorizationRepo.Register(userViewModel));

            // Tries to register same user twice
            Assert.Null(authorizationRepo.Register(userViewModel));
        }