Esempio n. 1
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            if (Validate())
            {
                return;
            }
            if (gum._isConsumer)
            {
                usermodel.user.name      = customerName.Text;
                usermodel.user.phone     = customerPhone.Text;
                usermodel.user.email     = customerEmail.Text;
                usermodel.user.user_type = "customer";
                usermodel.user.password  = customepass.Text;
            }
            else
            {
                usermodel.user.organization_name = executorName.Text;
                usermodel.user.phone             = executorPhone.Text;
                usermodel.user.email             = executorEmail.Text;
                usermodel.user.user_type         = "executor";
                usermodel.user.password          = executorpass.Text;
            }

            await PopupNavigation.PushAsync(loading);

            creator.CreateUser(Succksess, Error);
        }
        public void Button_Clicked_SignUp(object sender, EventArgs e)
        {
            CreateUserController createUser = new CreateUserController();
            LoginPage            loginPage  = new LoginPage();
            Boolean signUpBool = false;

            signUpBool = createUser.CreateUser(entryFirstName.Text, entryLastName.Text, entryEmail.Text, entryPassword.Text, entryPasswordRepeat.Text);

            if (signUpBool)
            {
                Navigation.PushModalAsync(new LoginPage());
            }
        }
        public async Task CreateUser_ShouldReturnError()
        {
            string username = "******";
            string password = "******";
            string name     = "Test";

            // when the user doesn't exist
            _userRepo.Setup(repo => repo.GetUserBasedOnUsername("Test")).
            Returns(Task.FromResult(GetUser()));

            var controller = new CreateUserController(_userRepo.Object);
            var response   = await controller.CreateUser(username, password, name);

            // TODO - check for bad request on return
            _userRepo.Verify(mock => mock.AddUser(It.IsAny <User>()), Times.Never());
            _userRepo.Verify(mock => mock.SaveChangesAsync(), Times.Never());
        }
        public async Task CreateUser_ShouldCreateUser()
        {
            string username = "******";
            string password = "******";
            string name     = "Test";

            // when the user already exists
            _userRepo.Setup(repo => repo.GetUserBasedOnUsername("Test"))
            .Returns(Task.FromResult((User)null));

            var controller     = new CreateUserController(_userRepo.Object);
            var actionResponse = await controller.CreateUser(username, password, name);

            var response = actionResponse.Value;

            // TODO - check for insatnce of user on return
            _userRepo.Verify(mock => mock.AddUser(It.IsAny <User>()), Times.Once());
            _userRepo.Verify(mock => mock.SaveChangesAsync(), Times.Once());
        }