PrepAway - Latest Free Exam Questions & Answers

Which methods should you choose?

You create Microsoft Windows-based applications. You are designing a unit test for a form in an application. You write the following code segment. (Line numbers are included for reference only.)

01 public partial class frmCalculation : Form {
02 public frmCalculation() {
03 InitializeComponent();
04 }
05 private void cmdFib_Click(object sender, EventArgs e) { 06 lblResult.Text = Fibonacci(int.Parse(txtNumber.Text)).ToString(); 07 }
08 private void cmdFac_Click(object sender, EventArgs e) { 09 lblResult.Text = Factorial(int.Parse(txtNumber.Text)).ToString(); 10 }
11 private int Fibonacci(int number) {
12 if (number < 3)
13 return 1;
14 else
15 return Fibonacci(number – 1) + Fibonacci(number – 2);
16 }
17 private int Factorial(int number) {
18 int total = 1;
19 for (int x = number; x > 1; x–)
20 total *= x;
21 return total;
22 }
23 }
You need to identify the methods that must be included for unit testing. Which methods should you choose?

PrepAway - Latest Free Exam Questions & Answers

A.
frmCalculation, cmdFib_Click, cmdFac_Click, Fibonacci, and Factorial

B.
frmCalculation, cmd_Fib_Click, and cmdFac_Click

C.
cmdFib_Click, cmdFac_Click, Fibonacci, and Factorial

D.
Fibonacci and Factorial


Leave a Reply