Exam4Training

You are developing an ASP.NET MVC 4 application that includes the following class

HOTSPOT

You are developing an ASP.NET MVC 4 application that includes the following class.

Line numbers are included for reference only.

For each of the following statements, select Yes if the statement is true. Otherwise, select No.

Answer:

Explanation:

Box 1: No

Line 7 executes fine as Name is the string Contoso.

Box 2: Yes

The assertion of Line 16 fails as the Boolean expression net|=0 evaluates to false (500-500 equals 0).

Note: An assertion verifies an assumption of truth for compared conditions. The assertion is central to the unit test. The Assert class provides many static methods for verifying suppositions of truth. If the condition being verified is not true, the assertion fails. The Assert class throws an AssertFailedException to signal a failure.

Box 3: No

The Boolean expression on line 22, balance >= 0.0f, evaluates to 0 >=0.0f (true), as balance is set to 0.0f at line 21, and because Contract.ensures is a postcondition.

Note: The Contract.Ensures method specifies a postcondition contract for the enclosing method or property.

References: https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.assert.aspx

http://stackoverflow.com/questions/7052640/how-does-contract-ensures-work

Latest 70-486 Dumps Valid Version with 255 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Exit mobile version