private void login_Click(object sender, RoutedEventArgs e)
        {
            string login    = txtLogin.Text;
            string password = txtPassword.Password;

            if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
            {
                MessageBox.Show("Favor Preencha todos os campos.");
            }
            else
            {
                string jsonDados = "{ \"login\": \"" + login + "\"," +
                                   "\"password\": \"" + password + "\"";

                WebserviceRequisitionController requisition = new WebserviceRequisitionController();

                dynamic item    = requisition.makeRequisition("http://localhost:60010/api/User/loginUser", "POST", jsonDados);
                string  message = item["Message"];
                string  sucess  = item["Sucess"];

                if ("true".Equals(sucess))
                {
                    Application.Current.Resources["userLogged"] = login;

                    UserHomeWindow window = new UserHomeWindow();
                    App.Current.MainWindow = window;
                    this.Close();
                    window.Show();
                }
                else
                {
                    MessageBox.Show(message);
                }
            }
        }
예제 #2
0
        private void loadTransactions()
        {
            WebserviceRequisitionController requisition = new WebserviceRequisitionController();

            dynamic item   = requisition.makeRequisition("http://localhost:60010/api/Transactions/getUserTransactions?userLogin="******"userLogged"], "GET", null);
            string  sucess = item["Sucess"];

            if ("true".Equals(sucess))
            {
                dynamic data = item["Data"];

                for (int i = 0; i < Enumerable.Count(data); i++)
                {
                    lvTransactionsData.Items.Add(new lvTransactionItem {
                        amount      = data[i]["amount"],
                        type        = data[i]["type"],
                        number      = data[i]["number"],
                        cardName    = data[i]["card"]["cardholderName"],
                        cardNumber  = data[i]["card"]["number"],
                        cardExpDate = data[i]["card"]["expirationDate"],
                        cardBrand   = data[i]["card"]["cardBrand"]
                    });
                }
            }
        }
        public void getUserTransactionsInvalidConsultTest()
        {
            WebserviceRequisitionController requisition = new WebserviceRequisitionController();

            dynamic item    = requisition.makeRequisition("http://localhost:60010/api/Transactions/getUserTransactions?userLogin=vini", "GET", null);
            string  message = item["Message"];
            string  sucess  = item["Sucess"];

            Assert.AreEqual("false", sucess);
            Assert.AreEqual("Não foi possível consultar as transações", message);
        }
        public void getUserTransactionsValidConsultTest()
        {
            WebserviceRequisitionController requisition = new WebserviceRequisitionController();

            dynamic item    = requisition.makeRequisition("http://localhost:60010/api/Transactions/getUserTransactions?userLogin=leo", "GET", null);
            string  message = item["Message"];
            string  sucess  = item["Sucess"];

            Assert.AreEqual("true", sucess);
            Assert.AreEqual("Transações retornadas", message);
        }
예제 #5
0
        public void registerUserLoginRequired()
        {
            string jsonDados = "{ \"login\": \"\"," +
                               "\"name\": \"Leonardo\"," +
                               "\"password\": \"Leo123\"";

            WebserviceRequisitionController requisition = new WebserviceRequisitionController();

            dynamic item    = requisition.makeRequisition("http://localhost:60010/api/User/registerUser", "POST", jsonDados);
            string  message = item["Message"];
            string  sucess  = item["Sucess"];

            Assert.AreEqual("false", sucess);
            Assert.AreEqual("Informe o login do usuário", message);
        }
예제 #6
0
        public void loginUserValidLoginTest()
        {
            //Login Válido
            string jsonDados = "{ \"login\": \"leo\"," +
                               "\"password\": \"Leo123\"";

            WebserviceRequisitionController requisition = new WebserviceRequisitionController();

            dynamic item    = requisition.makeRequisition("http://localhost:60010/api/User/loginUser", "POST", jsonDados);
            string  message = item["Message"];
            string  sucess  = item["Sucess"];

            Assert.AreEqual("true", sucess);
            Assert.AreEqual("Usuário Logado com sucesso", message);
        }
예제 #7
0
        public void loginUserInvalidLoginTest()
        {
            //Login Válido
            string jsonDados = "{ \"login\": \"le\"," +
                               "\"password\": \"le\"";

            WebserviceRequisitionController requisition = new WebserviceRequisitionController();

            dynamic item    = requisition.makeRequisition("http://localhost:60010/api/User/loginUser", "POST", jsonDados);
            string  message = item["Message"];
            string  sucess  = item["Sucess"];

            Assert.AreEqual("false", sucess);
            Assert.AreEqual("Não foi possível efetuar o login", message);
        }
예제 #8
0
        public void loginUserPasswordRequiredTest()
        {
            //Login Válido
            string jsonDados = "{ \"login\": \"leo\"," +
                               "\"password\": \"\"";

            WebserviceRequisitionController requisition = new WebserviceRequisitionController();

            dynamic item    = requisition.makeRequisition("http://localhost:60010/api/User/loginUser", "POST", jsonDados);
            string  message = item["Message"];
            string  sucess  = item["Sucess"];

            Assert.AreEqual("false", sucess);
            Assert.AreEqual("Informe a senha do usuário", message);
        }
예제 #9
0
        public void registerUserPasswordFormat()
        {
            string jsonDados = "{ \"login\": \"leo21\"," +
                               "\"name\": \"Leonardo\"," +
                               "\"password\": \"leo123\"";

            WebserviceRequisitionController requisition = new WebserviceRequisitionController();

            dynamic item    = requisition.makeRequisition("http://localhost:60010/api/User/registerUser", "POST", jsonDados);
            string  message = item["Message"];
            string  sucess  = item["Sucess"];

            Assert.AreEqual("false", sucess);
            Assert.AreEqual("Senha inválida: A senha deve conter ao menos um caracter maiúsculo", message);
        }
예제 #10
0
        public void registerUserPasswordLengthBigger()
        {
            string jsonDados = "{ \"login\": \"leo21\"," +
                               "\"name\": \"Leonardo\"," +
                               "\"password\": \"Leo123456\"";

            WebserviceRequisitionController requisition = new WebserviceRequisitionController();

            dynamic item    = requisition.makeRequisition("http://localhost:60010/api/User/registerUser", "POST", jsonDados);
            string  message = item["Message"];
            string  sucess  = item["Sucess"];

            Assert.AreEqual("false", sucess);
            Assert.AreEqual("Erro no tamanho da senha: A senha deve ter entre 6 e 8 dítigos", message);
        }
예제 #11
0
        private void btnRegister_Click(object sender, RoutedEventArgs e)
        {
            string cardName     = txtName.Text;
            string cardBrand    = cbBrand.SelectedItem != null ? ((ComboBoxItem)cbBrand.SelectedItem).Content.ToString() : "";
            string cardNumber   = txtNumber.Text;
            string cardPassword = txtPassword.Password;
            string cardExpDate  = txtExpDate.Text;
            string cardType     = cbType.SelectedItem != null ? ((ComboBoxItem)cbType.SelectedItem).Content.ToString() : "";
            string cardBalance  = txtBalance.Text;

            if (string.IsNullOrEmpty(cardName) || string.IsNullOrEmpty(cardBrand) || string.IsNullOrEmpty(cardNumber) ||
                string.IsNullOrEmpty(cardPassword) || string.IsNullOrEmpty(cardExpDate) || string.IsNullOrEmpty(cardType) ||
                string.IsNullOrEmpty(cardBalance))
            {
                MessageBox.Show("Favor Preencha todos os campos.");
            }
            else
            {
                string jsonDados = "{ \"userLogin\": \"" + Application.Current.Resources["userLogged"] + "\"," +
                                   "\"cardholderName\": \"" + cardName + "\"," +
                                   "\"number\": \"" + cardNumber + "\"," +
                                   "\"expirationDate\": \"" + cardExpDate + "\"," +
                                   "\"cardBrand\": \"" + cardBrand + "\"," +
                                   "\"password\": \"" + cardPassword + "\"," +
                                   "\"type\": \"" + cardType + "\"," +
                                   "\"balance\": \"" + cardBalance + "\"" +
                                   " } ";

                WebserviceRequisitionController requisition = new WebserviceRequisitionController();

                dynamic item    = requisition.makeRequisition("http://localhost:60010/api/Card/registerCard", "POST", jsonDados);
                string  message = item["Message"];
                string  sucess  = item["Sucess"];

                if ("true".Equals(sucess))
                {
                    MessageBox.Show(message);
                }
                else
                {
                    MessageBox.Show(message);
                }
            }
        }
        public void makeTransactionValidTransactionTest()
        {
            string jsonDados = "{ \"amount\": \"100\"," +
                               "\"type\": \"Crédito\"," +
                               "\"number\": \"1\"," +
                               "\"card\": { " +
                               "\"number\": \"1\"," +
                               "\"password\": \"1234\"," +
                               " }, " +
                               "\"userLogin\": \"leo\" }";

            WebserviceRequisitionController requisition = new WebserviceRequisitionController();

            dynamic item    = requisition.makeRequisition("http://localhost:60010/api/Transactions/makeTransaction", "POST", jsonDados);
            string  message = item["Message"];
            string  sucess  = item["Sucess"];

            Assert.AreEqual("true", sucess);
            Assert.AreEqual("Transação Aprovada", message);
        }
        public void makeTransactionInvalidAmountTest()
        {
            string jsonDados = "{ \"amount\": \"0\"," +
                               "\"type\": \"Crédito\"," +
                               "\"number\": \"1\"," +
                               "\"card\": { " +
                               "\"number\": \"1\"," +
                               "\"password\": \"123\"," +
                               " }, " +
                               "\"userLogin\": \"leo\" }";

            WebserviceRequisitionController requisition = new WebserviceRequisitionController();

            dynamic item    = requisition.makeRequisition("http://localhost:60010/api/Transactions/makeTransaction", "POST", jsonDados);
            string  message = item["Message"];
            string  sucess  = item["Sucess"];

            Assert.AreEqual("false", sucess);
            Assert.AreEqual("Valor inválido: mínimo de 10 centavos.", message);
        }
        public void registerCardValidRegisterTest()
        {
            string jsonDados = "{ \"userLogin\": \"leo\"," +
                               "\"cardholderName\": \"Leonardo\"," +
                               "\"number\": \"123\"," +
                               "\"expirationDate\": \"20/10/2020\"," +
                               "\"cardBrand\": \"Visa\"," +
                               "\"password\": \"123\"," +
                               "\"type\": \"CHIP\"," +
                               "\"balance\": \"500\"" +
                               " } ";

            WebserviceRequisitionController requisition = new WebserviceRequisitionController();

            dynamic item    = requisition.makeRequisition("http://localhost:60010/api/Card/registerCard", "POST", jsonDados);
            string  message = item["Message"];
            string  sucess  = item["Sucess"];

            Assert.AreEqual("true", sucess);
            Assert.AreEqual("Cartão Registrado com sucesso.", message);
        }
        private void btnMakeTransaction_Click(object sender, RoutedEventArgs e)
        {
            string amount       = txtAmount.Text;
            string type         = cbType.SelectedItem != null ? ((ComboBoxItem)cbType.SelectedItem).Content.ToString() : "";
            string number       = txtNumber.Text;
            string cardNumber   = txtCardNumber.Text;
            string cardPassword = txtCardPassword.Password;

            if (string.IsNullOrEmpty(amount) || string.IsNullOrEmpty(type) || string.IsNullOrEmpty(number) ||
                string.IsNullOrEmpty(cardNumber) || string.IsNullOrEmpty(cardPassword))
            {
                MessageBox.Show("Favor Preencha todos os campos.");
            }
            else
            {
                string jsonDados = "{ \"amount\": \"" + amount + "\"," +
                                   "\"type\": \"" + type + "\"," +
                                   "\"number\": \"" + number + "\"," +
                                   "\"card\": { " +
                                   "\"number\": \"" + cardNumber + "\"," +
                                   "\"password\": \"" + cardPassword + "\"," +
                                   " }, " +
                                   "\"userLogin\": \"" + Application.Current.Resources["userLogged"] + "\" }";

                WebserviceRequisitionController requisition = new WebserviceRequisitionController();

                dynamic item    = requisition.makeRequisition("http://localhost:60010/api/Transactions/makeTransaction", "POST", jsonDados);
                string  message = item["Message"];
                string  sucess  = item["Sucess"];

                if ("true".Equals(sucess))
                {
                    MessageBox.Show(message);
                }
                else
                {
                    MessageBox.Show(message);
                }
            }
        }
        private void register_Click(object sender, RoutedEventArgs e)
        {
            string name     = txtName.Text;
            string login    = txtLogin.Text;
            string password = txtPassword.Password;

            if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
            {
                MessageBox.Show("Favor Preencha todos os campos.");
            }
            else
            {
                string jsonDados = "{ \"login\": \"" + login + "\"," +
                                   "\"name\": \"" + name + "\"," +
                                   "\"password\": \"" + password + "\"";

                WebserviceRequisitionController requisition = new WebserviceRequisitionController();

                dynamic item    = requisition.makeRequisition("http://localhost:60010/api/User/registerUser", "POST", jsonDados);
                string  message = item["Message"];

                MessageBox.Show(message);
            }
        }