public void WhenSuccess_ThenSuccessMessage()
        {
            // Arrange
            const double debitAmount = 4.55;
            const double expected    = 7.44;

            _mockBankAccountObject.Create("Mr. Bryan Walton", BeginningBalance);

            // Act
            _mockBankAccountObject.Debit(debitAmount); // 11.99 - 4.55 = 7.44

            // Assert
            Assert.AreEqual(expected, _mockBankAccountObject.Balance, 0.001, "Account not debited correctly");
        }
Exemple #2
0
        // ----------------------------------------------------------------------------------- //
        // [button] REGISTER BANK ACCOUNT
        private void button2_Click(object sender, EventArgs e)
        {
            // GET DATA FROM INPUTS
            var ct = new BankAccountModel();

            ct.ID          = Convert.ToInt32(txt_ID.Text);
            ct.Owner       = txtOwner.Text;
            ct.Bank        = txtBanco.Text;
            ct.Balance     = Convert.ToDouble(txt_Opening_Balance.Text);
            ct.AccountType = cb_TypeAccount.SelectedItem.ToString();

            // SIMULATE DATABASE QUERY
            var bankAccountList = BankAccountList.Instance.Lista;
            var ID_exists       = bankAccountList.ToList().Where(x => x.ID == ct.ID).FirstOrDefault();

            // CHECK IF CLIENT EXISTS
            var clientList   = ClientList.Instance.Lista;
            var Owner_Exists = clientList.ToList().Where(x => x.Name == ct.Owner).FirstOrDefault();


            // IF NOT EXISTS, INSERT!
            if (ID_exists == null && Owner_Exists != null)
            {
                _bankAccountModel.Create(ct);
            }

            if (ID_exists != null)
            {
                MessageBox.Show("Numero da Conta já existe!");
            }

            if (Owner_Exists == null)
            {
                MessageBox.Show("Cliente não existe!");
            }

            // UPDATE VIEW
            dataGridContas.DataSource = null;
            dataGridContas.DataSource = bankAccountList;

            ct = null;
            GC.Collect();
        }