예제 #1
0
        /// <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();
                }
            }
        }
예제 #2
0
        public void JsonDataConverter_deserializedApikey()
        {
            string Testapikey     = "[{\"userapi\":\"testapikey\"}]";
            string expectedoutput = "testapikey";

            string key = JsonDataConverter.deserializedApikey(Testapikey);

            Assert.AreEqual(expectedoutput, key);
        }