Пример #1
0
        public async void testAuthenticateSucess()
        {
            //Arrange
            string username     = "******";
            string password     = "******";
            string expectUserID = "bc9ce5ff-1731-457f-bee3-336a99165c22";

            //Act
            AuthenticateJsonResult result = await MyMartService.AuthenWithUsername(username, password);

            //Assert
            Assert.IsTrue(result.UserID == expectUserID);
        }
Пример #2
0
        public async void testAuthenticateFail()
        {
            //Arrange
            string username            = "******";
            string password            = "******";
            bool   expectAuthenticated = false;

            //Act
            AuthenticateJsonResult result = await MyMartService.AuthenWithUsername(username, password);

            //Assert
            Assert.IsTrue(result.Authenticated == expectAuthenticated);
        }
Пример #3
0
        public async void testAuthenticateNullValue()
        {
            //Arrange
            string username            = "";
            string password            = "";
            bool   expectAuthenticated = false;

            //Act
            AuthenticateJsonResult result = await MyMartService.AuthenWithUsername(username, password);

            //Assert
            Assert.IsTrue(result.Authenticated == expectAuthenticated);
        }
Пример #4
0
        private async void loginButton_Click(object sender, RoutedEventArgs e)
        {
            AuthenticateJsonResult result = await MyMartService.AuthenWithUsername(userNameTextBox.Text, passwordBox.Password);

            if (result.Authenticated)
            {
                LocalSetting.UserID = result.UserID;
                LoggedIn(sender, e);
            }
            else
            {
                MessageDialog messageDialog = new MessageDialog(result.ExceptionMessage, "Authentication Fail");
                await messageDialog.ShowAsync();
            }
        }
        private async void buttonNum_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (button.Content.ToString().CompareTo("<") == 0)
            {
                if (pin.Length >= 1)
                {
                    pin = pin.Substring(0, pin.Length - 1);

                    SetPasswordBox(pin);
                }
            }
            else if (button.Content.ToString().CompareTo("Forgot My Pin") == 0)
            {
            }
            else
            {
                pin += button.Content.ToString();

                SetPasswordBox(pin);

                if (pin.Length >= 4)
                {
                    if (!LocalSetting.IsRegisterDevice)
                    {
                        if (isConfirmPin)
                        {
                            isConfirmPin = false;
                            firstpin     = pin;
                            descriptionTextBlock.Text = "Please confirm your Quick-Pin";
                            pin = "";

                            SetPasswordBox(pin);
                        }
                        else
                        {
                            if (pin == firstpin)
                            {
                                RegisterDeviceQuickPinJsonResult result = await MyMartService.RegisterDeviceQuickPin(pin, true);

                                if (result.RegisterSuccess)
                                {
                                    LocalSetting.IsRegisterDevice = true;
                                    LoggedIn(sender, e);
                                }
                                else
                                {
                                    MessageDialog messageDialog = new MessageDialog(result.ExceptionMessage);
                                    await messageDialog.ShowAsync();
                                }
                            }
                        }
                    }
                    else
                    {
                        AuthenticateJsonResult result = await MyMartService.AuthenWithQuickPin(pin);

                        if (result.Authenticated)
                        {
                            LocalSetting.UserID = result.UserID;
                            LoggedIn(sender, e);
                        }
                        else
                        {
                            MessageDialog messageDialog = new MessageDialog(result.ExceptionMessage);
                            await messageDialog.ShowAsync();
                        }
                    }
                }
            }
        }