PrepAway - Latest Free Exam Questions & Answers

Which line of code should you use to replace the code on line 06?

You create Microsoft Windows-based applications. You review code for an application that is developed for a bank. You need to test a method named Deposit in one of the application components. The following code segment represents the Deposit method. (Line numbers are included for reference only.)
01 public void Deposit(decimal amount) {
03 if (!(amount > 0)) {
04 throw new Exception(“Invalid deposit amount!”);
05 } else {
06 this.balance += amount;
07 }
08 }

You use the Microsoft Visual Studio 2005 test feature to automatically generate the following unit test.
(Line numbers are included for reference only.)

01 [TestMethod()]
02 public void DepositTest() {
03 BankAccount target = new BankAccount(); //balance will be ZERO
04 decimal amount = 100;
05 target.Deposit(amount);
06 Assert.Inconclusive
(“A method that does not return a value cannot be verified.”); 07 }

You need to change the test method to return a conclusive result. Which line of code should you use to replace the code on line 06?

PrepAway - Latest Free Exam Questions & Answers

A.
Assert.AreEqual(100M,target.Balance);

B.
Assert.IsTrue(target.Balance!=100M);

C.
Debug.Assert(target.Balance==100M,passed);

D.
Debug.Assert(target.Balance==100M,failed);


Leave a Reply