/// <summary>
        /// Function for login fase used by Enterkey event and Login butten event
        /// </summary>
        private void login()
        {
            if (string.IsNullOrEmpty(tb_mail.Text) || string.IsNullOrEmpty(pb_password.Password) || string.IsNullOrEmpty(tb_mail.Text) && string.IsNullOrEmpty(pb_password.Password))
            {
                MessageBox.Show("Please fill out username and password");
            }
            else
            {
                if (tb_password.Visibility == Visibility.Visible)
                {
                    pb_password.Password = tb_password.Text;
                }

                string JSONapikey = HttpApiRequest.ClimateLogin(tb_mail.Text, pb_password.Password);
                if (string.IsNullOrEmpty(JSONapikey))
                {
                    MessageBox.Show("Wrong username or password");
                }
                else
                {
                    UserInformation.ApiKey   = JsonDataConverter.deserializedApikey(JSONapikey);
                    UserInformation.Mail     = tb_mail.Text;
                    UserInformation.Password = pb_password.Password;

                    Climate c = new Climate();
                    c.Show();
                    Close();
                }
            }
        }
Exemple #2
0
        public void HttpApiRequest_ClimateLogin()
        {
            string mail     = "test";
            string password = "******";
            string expectedoutput_Noaccess = null;
            string expectedoutput_Access   = "userapi";

            string JSONapikey = HttpApiRequest.ClimateLogin(mail, password);

            if (mail == "test")
            {
                Assert.AreEqual(expectedoutput_Noaccess, JSONapikey);
            }
            else
            {
                Assert.IsTrue(JSONapikey.Contains(expectedoutput_Access));
            }
        }