PrepAway - Latest Free Exam Questions & Answers

BackgroundYou are developing an online shopping web application.

Background

You are developing an online shopping web application.

Business Requirements

A user is not required to provide an email address. If a user enters an email address, it must be verified to be a valid email address.

Information about the first product on the product page must fade out over time to encourage the user to continue browsing the catalog.

Administrators must be able to edit information about existing customers.

Administrators also must be able to specify a default product on the product page.

Technical Requirements

General:

The web store application is in a load-balanced web farm. The load balancer is not configured to use server affinity.

The web store application is an ASP.NET MVC application written in Visual Studio.

Products:

The value of the productId property must always be greater than 0.

The Products page for mobile devices must display to mobile users. The Products page for desktop devices must display to desktop users.

Storage:

The data must be stored in a serialized XML data format.

Serialized objects must be schema-independent.

Exception handling:

Exceptions originating from IIS must display a page with support contact information.

Some page links expire, and users who access these links encounter 404 errors.

Exceptions must be logged by using the WriteLog method of the Utility class.

Browser and device support:

The application must support image format conversions from .bmp to .jpeg for mobile devices.

The application must support image format conversions from .bmp to .png for desktop devices.

Application Structure






You need to modify the application to meet the productId requirement.

What should you do?

A. Modify the RegisterGlobalFilters method of the Global.asax.cs file as follows. Contract.Assume(productId != 0);

B. Modify the GetDealPrice method of ProductController as follows. Contract.Requires(productId > 0);

C. Modify the RegisterGlobalFilters method of the Global.asax.cs file as follows. Contract.Requires(productId > 0);

D. Modify the GetDealPrice method of ProductController as follows. Contract.Assume(productId != 0);

Explanation:

Scenario: The value of the productId property must always be greater than 0.

The GetDealPrice method, in the ProductController, has ProductID as input parameter.

Note: The Contract.

Requires(Of TException) method specifies a precondition contract for the enclosing method or property, and throws an exception if the condition for the contract fails.

Syntax:

Declaration

Public Shared Sub Requires(Of TException As Exception) ( _ condition As Boolean _)

Type Parameters

TException

The exception to throw if the condition is false.

Parameters

condition

Type: System.Boolean

The conditional expression to test.

Incorrect Answers:

D: The Contract.Assume method instructs code analysis tools to assume that a condition is true, even if it cannot be statically proven to always be true.

Reference: Contract.Requires(Of TException) Method (Boolean)

https://msdn.microsoft.com/en-us/library/dd782896(v=vs.110).aspx


Leave a Reply