Skip to main content

Definition

Assembly: MSTest.TestFramework.Extensions.dll Namespace: Microsoft.VisualStudio.TestTools.UnitTesting

Syntax

Microsoft.VisualStudio.TestTools.UnitTesting.TestContext

Summary

This type is defined in MSTest.TestFramework.Extensions.

Methods

LogAndReturnMessageContentAsync Extension

Extension method from Microsoft.VisualStudio.TestTools.UnitTesting.Breakdance_MsTest2_TestContextExtensions
Attempts to unwrap the Content and log it to the testContext if possible.

Syntax

public static System.Threading.Tasks.Task<string> LogAndReturnMessageContentAsync(Microsoft.VisualStudio.TestTools.UnitTesting.TestContext testContext, System.Net.Http.HttpResponseMessage message, bool nullIsExpected = false)

Parameters

NameTypeDescription
testContextMicrosoft.VisualStudio.TestTools.UnitTesting.TestContext-
messageSystem.Net.Http.HttpResponseMessage-
nullIsExpectedboolSpecifies whether the Content in message is expected to be null.

Returns

Type: System.Threading.Tasks.Task<string>

Remarks

This exists in order to safely allow the tests to continue in the absence of correct content. This is because the tests should log the response content BEFORE failing the test for an incorrect StatusCode.