exam questions

Exam 70-486 All Questions

View all questions & answers for the 70-486 exam

Exam 70-486 topic 1 question 139 discussion

Actual exam question from Microsoft's 70-486
Question #: 139
Topic #: 1
[All 70-486 Questions]

DRAG DROP -
You are developing an ASP.NET Core MVC web application. The application is configured to use a Startup class.
The /status action must be tested on each check-in to source control.
You need to test the application.
How should you complete the code? To answer, drag the appropriate code segments to the correct locations. Each code segment may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.
NOTE: Each correct selection is worth one point.
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:
Example: Specify the Startup class with the WebHostBuilderExtensions UseStartup<TStartup> method: public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
References:
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/startup?view=aspnetcore-2.1

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
ptarasov
Highly Voted 5 years, 4 months ago
WebHost is an internal class from Microsoft.AspNetCore.Hosting.Internal. Correct answer is <new TestServer(new WebHostBuilder()...>
upvoted 27 times
aarset89
5 years ago
Where is declared TestServer? In the reference said that Webhost is the correct answer.
upvoted 1 times
Imen_chaaben
4 years, 4 months ago
https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.testhost.testserver?view=aspnetcore-2.0
upvoted 1 times
...
...
...
mr_
Highly Voted 4 years, 12 months ago
I agree. Correct answer is: TestServer WebHostBuilder Code: (...) // Configure the in-memory test server, and create an HttpClient for interacting with it var server = new TestServer(webHostBuilder); HttpClient client = server.CreateClient(); // Send requests just as if you were going over the network var response = await client.GetAsync("/"); response.EnsureSuccessStatusCode(); var responseString = await response.Content.ReadAsStringAsync(); Assert.Equal("Hello World!", responseString); Ref: https://andrewlock.net/converting-integration-tests-to-net-core-3/
upvoted 5 times
...
Imen_chaaben
Most Recent 4 years, 4 months ago
TestServer WebHostBuilder https://www.meziantou.net/testing-an-asp-net-core-application-using-testserver.htm
upvoted 1 times
...
Dhaval
5 years, 4 months ago
Agree with ptarasov
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...