Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (maskedTextBox_transactAmount.Text != "")
            {
                decimal balance = Transactions.calculateTransact(1, Convert.ToDecimal(label1.Text), Convert.ToDecimal(maskedTextBox_transactAmount.Text), out errorMsg);
                label1.Text = balance.ToString("0.00");
                accountsDS.Tables["Table1"].Rows[comboBox1.SelectedIndex].SetField <string>("Balance", label1.Text);
                writeAccounts();

                if (errorMsg != "")
                {
                    MessageBox.Show(errorMsg);
                    errorMsg = "";
                }

                maskedTextBox_transactAmount.Text = "";
            }
        }
Example #2
0
 public void calculateTransactTest_DepositPositiveAmount()
 {
     Console.WriteLine("TestID 4");
     Transactions target = new Transactions(); // REM
     int transactType = 2; // REM
     Decimal accountBalance = new Decimal(10000); // REM
     Decimal transactAmount = new Decimal(1000); // REM
     string errorMsg = string.Empty; // REM
     string errorMsgExpected = string.Empty; // REM
     Decimal expected = new Decimal(11000); // REM
     Decimal actual;
     actual = target.calculateTransact(transactType, accountBalance, transactAmount, out errorMsg);
     Assert.AreEqual(errorMsgExpected, errorMsg);
     Assert.AreEqual(expected, actual);
 }
Example #3
0
 public void calculateTransactTest_interesAddingAfterAYear()
 {
     Console.WriteLine("TestID 6");
     Transactions target = new Transactions(); // TODO: Initialize to an appropriate value
     int transactType = 3; // TODO: Initialize to an appropriate value
     Decimal accountBalance = new Decimal(10000); // TODO: Initialize to an appropriate value
     Decimal transactAmount = new Decimal(0.1); // TODO: Initialize to an appropriate value
     string errorMsg = string.Empty; // TODO: Initialize to an appropriate value
     string errorMsgExpected = string.Empty; // TODO: Initialize to an appropriate value
     string lastInterestDate = Convert.ToString(DateTime.Today.AddDays(-365).Date); // TODO: Initialize to an appropriate value
     Decimal expected = new Decimal(11000); // TODO: Initialize to an appropriate value
     Decimal actual;
     actual = target.calculateTransact(transactType, accountBalance, transactAmount, out errorMsg, lastInterestDate);
     Assert.AreEqual(errorMsgExpected, errorMsg);
     Assert.AreEqual(expected, actual);
     //Assert.Inconclusive("Verify the correctness of this test method.");
 }
Example #4
0
 public void calculateTransactTest_WithdrawIllegalBoundaryAmount()
 {
     Console.WriteLine("TestID 5:boundary");
     Transactions target = new Transactions(); // REM
     int transactType = 1; // REM
     Decimal accountBalance = new Decimal(); // REM
     Decimal transactAmount = new Decimal(); // REM
     accountBalance = 0;
     transactAmount = 0.01m;
     string errorMsg = string.Empty; // REM
     string errorMsgExpected = "The current balance is " + accountBalance + "\r\n\n" +
                           "Your withdrawal of " + transactAmount +
                           " is not possible at this time !! \r\n\n Please withdraw a lower amount.";
     Decimal expected = new Decimal(0); // REM
     Decimal actual;
     actual = target.calculateTransact(transactType, accountBalance, transactAmount, out errorMsg);
     Assert.AreEqual(errorMsgExpected, errorMsg);
     Assert.AreEqual(expected, actual);
 }
Example #5
0
 public void calculateTransactTest_WithdrawIllegalAmount()
 {
     Console.WriteLine("TestID 2");
     Transactions target = new Transactions(); // REM
     int transactType = 1; // WithDraw
     Decimal accountBalance = new Decimal(10000); // REM
     Decimal transactAmount = new Decimal(11000); /**
                                                 * Withdraw more than the current balance
                                                 * This should not be possible, and must raise an error message.
                                                 */
     string errorMsg = string.Empty; // REM
     string errorMsgExpected = "The current balance is " + accountBalance + "\r\n\n" +
                           "Your withdrawal of " + transactAmount +
                           " is not possible at this time !! \r\n\n Please withdraw a lower amount.";
     Console.WriteLine(errorMsg);
     Decimal expected = new Decimal(10000); // REM
     Decimal actual;
     actual = target.calculateTransact(transactType, accountBalance, transactAmount, out errorMsg);
     Assert.AreEqual(errorMsgExpected, errorMsg);
     Assert.AreEqual(expected, actual);
     //Assert.Inconclusive("Verify the correctness of this test method.");
 }
Example #6
0
 public void calculateTransactTest_WithdrawBoundaryAmount()
 {
     Console.WriteLine("TestID 4:boundary");
     Transactions target = new Transactions(); // REM
     int transactType = 1; // REM
     Decimal accountBalance = new Decimal(); // REM
     Decimal transactAmount = new Decimal(); // REM
     accountBalance = 0.01m;
     transactAmount = 0.01m;
     string errorMsg = string.Empty; // REM
     string errorMsgExpected = string.Empty; // REM
     Decimal expected = new Decimal(0); // REM
     Decimal actual;
     actual = target.calculateTransact(transactType, accountBalance, transactAmount, out errorMsg);
     Assert.AreEqual(errorMsgExpected, errorMsg);
     Assert.AreEqual(expected, actual);
 }
Example #7
0
 public void calculateTransactTest_WithdrawAllowedAmount()
 {
     Console.WriteLine("TestID 1");
     Transactions target = new Transactions();
     int transactType = 1; // WithDraw
     Decimal accountBalance = new Decimal(10000); // REM
     Decimal transactAmount = new Decimal(9000); // REM
     string errorMsg = string.Empty; // REM
     string errorMsgExpected = string.Empty; // REM
     Decimal expected = new Decimal(1000); // REM
     Decimal actual;
     actual = target.calculateTransact(transactType, accountBalance, transactAmount, out errorMsg);
     Assert.AreEqual(errorMsgExpected, errorMsg);
     Assert.AreEqual(expected, actual);
     //Assert.Inconclusive("Verify the correctness of this test method.");
 }
Example #8
0
 public void calculateTransactTest_interesAddingWithNoDate()
 {
     Console.WriteLine("TestID 8");
     Transactions target = new Transactions();
     int transactType = 3;
     Decimal accountBalance = new Decimal(10000);
     Decimal transactAmount = new Decimal(0.1);
     string errorMsg = string.Empty;
     string errorMsgExpected = "The last date of interest adding is missing !!";
     string lastInterestDate = string.Empty;
     Decimal expected = new Decimal(10000);
     Decimal actual;
     /// We expect the accountBalance to remain unchanged, as we cannot see the last date of interest update
     /// The method must throw the interestAddingException
     actual = target.calculateTransact(transactType, accountBalance, transactAmount, out errorMsg, lastInterestDate);
     Assert.AreEqual(errorMsgExpected, errorMsg);
     Assert.AreEqual(expected, actual);
     Console.WriteLine(errorMsg);
 }
Example #9
0
 public void calculateTransactTest_interesAddingUnderAYear()
 {
     Console.WriteLine("TestID 7");
     Transactions target = new Transactions();
     int transactType = 3;
     Decimal accountBalance = new Decimal(10000);
     Decimal transactAmount = new Decimal(0.1);
     string errorMsg = string.Empty;
     string errorMsgExpected = "It has not been a year since last interest adding !!";
     string lastInterestDate = Convert.ToString(DateTime.Today.AddDays(-364).Date);
     Decimal expected = new Decimal(10000);
     Decimal actual;
     actual = target.calculateTransact(transactType, accountBalance, transactAmount, out errorMsg, lastInterestDate);
     Assert.AreEqual(errorMsgExpected, errorMsg);
     Assert.AreEqual(expected, actual);
     Console.WriteLine(errorMsg);
 }