public BankDeposit calculateDeposite(double P) { BankDeposit obj = new BankDeposit(); obj.deposit = 1000; P /= 100; while (obj.deposit <= 5000) { obj.deposit += obj.deposit * P; obj.year += 1; } Console.WriteLine(obj.ToString()); return(obj); }
public static bool TestCalculateDeposite() { //arrange ControlFlowStatements1 obj = new ControlFlowStatements1(); BankDeposit expected = new BankDeposit(); BankDeposit actual = new BankDeposit(); expected.deposit = 5062.5; expected.year = 4; //act actual = obj.calculateDeposite(50); //assert if (expected.year != actual.year) { return(false); } if (expected.deposit != actual.deposit) { return(false); } return(true); }