Which additional assertion should you test?

You create Microsoft Windows-based applications. You are designing a unit test class to test the functionality of a component named Calculator. The Calculator must function as a standard nonscientific calculator. A developer on your team writes the following lines of code for the test class. (Line numbers are included for reference only.)

01 [TestClass()]
02 public class CalculatorTest {
03 private TestContext testContextInstance;
04 public TestContext TestContext {
05 get{return testContextInstance;}
06 set{testContextInstance = value;}
07 }
08 [TestMethod()]
09 public void AddTest() {
10 Calculator target = new Calculator();
11 Assert.AreEqual(target.Add(1,1),2);
12 target.Dispose();
13 }
14 [TestMethod()]
15 public void SubtractTest() {
16 Calculator target = new Calculator();
17 Assert.AreEqual(target.Subtract(10,2),8);
18 target.Dispose();
19 }
20 }

You need to ensure that appropriate assertions are tested. Which additional assertion should you test?

You create Microsoft Windows-based applications. You are designing a unit test class to test the functionality of a component named Calculator. The Calculator must function as a standard nonscientific calculator. A developer on your team writes the following lines of code for the test class. (Line numbers are included for reference only.)

01 [TestClass()]
02 public class CalculatorTest {
03 private TestContext testContextInstance;
04 public TestContext TestContext {
05 get{return testContextInstance;}
06 set{testContextInstance = value;}
07 }
08 [TestMethod()]
09 public void AddTest() {
10 Calculator target = new Calculator();
11 Assert.AreEqual(target.Add(1,1),2);
12 target.Dispose();
13 }
14 [TestMethod()]
15 public void SubtractTest() {
16 Calculator target = new Calculator();
17 Assert.AreEqual(target.Subtract(10,2),8);
18 target.Dispose();
19 }
20 }

You need to ensure that appropriate assertions are tested. Which additional assertion should you test?

A.
AreSame

B.
IsInstanceOfType

C.
IsNotNull

D.
Inconclusive



Leave a Reply 0

Your email address will not be published. Required fields are marked *