HOTSPOT

HOTSPOT
You are building an ASP.NET application. You develop the following unit test code. Line numbers are included for reference only.
01[TestClass]
02public class UnitTest1
03{
04protected string _name;
05protected float _expenses;
06protected float _income;
07protected float _payment;
08protected float _balance;
09public void AddCustomer(string name, float income, float payment, float balance)
10{
11_name = name;
12_expenses = expenses;
13_income = income;
14_payment = payment;
15_balance = balance;
16CheckName();
17DebRatio();
18CheckBalance();
19}
20[TestMethod]
21public void CheckName()
22{
23Assert.IsNotNull(_name, "CheckName failed unit test");
24}
25[TestMethod]
26public void DebRatio()
27{
28Assert.AreSame(_income, _payment, "DebRatio failed unit test");
29}
30[TestMethod]
31public void CheckBalance()
32{
33Assert.IsTrue(_balance >= 0.0f, Check balance failed unit test.");
34} 35}
You run the following line of code:
AddCustomer("Contoso", 0, 100, 100, -1);
You need to evaluate the unit test results. For each of the following statements, select Yes if the statement is true. Otherwise, select No.
Hot Area:

microsoft-exams

2 thoughts on “HOTSPOT

  1. the question is invalid.
    – AddCustomer(“Contoso”, 0, 100, 100, -1);

    there is no AddCustomer method with 5 input parameters.
    Thus the answers make no sense.

    to make the answers correct, it should be:
    line 9 should be:
    public void AddCustomer(string name, float expenses, float income, float payment, float balance)

    AreSame compares object references, to compare simple types as float use Assert.AreEqual

  2. Method AddCustomer is missing parameter ‘float expenses’. Under assumption that _expenses would be 0, _income = 100 and payment = 100 the assertion at Line 28 would fail nonetheless.
    AreSame compares object references, to compare simple types as float use Assert.AreEqual

Leave a Reply

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


The reCAPTCHA verification period has expired. Please reload the page.