Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 1836deff6a
Fetching contributors…

Cannot retrieve contributors at this time

58 lines (47 sloc) 1.803 kb
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using Microsoft.TestCommon;
using Xunit;
using Assert = Microsoft.TestCommon.AssertEx;
namespace System.Net.Http
{
public class HttpRequestMessageExtensionsTest
{
[Fact]
public void IsCorrectType()
{
Assert.Type.HasProperties(typeof(HttpRequestMessageExtensions), TypeAssert.TypeProperties.IsStatic | TypeAssert.TypeProperties.IsPublicVisibleClass);
}
[Fact]
public void CreateResponseThrowsOnNull()
{
Assert.ThrowsArgumentNull(() => HttpRequestMessageExtensions.CreateResponse(null), "request");
}
[Fact]
public void CreateResponseWithStatusThrowsOnNull()
{
Assert.ThrowsArgumentNull(() => HttpRequestMessageExtensions.CreateResponse(null, HttpStatusCode.OK), "request");
}
[Fact]
public void CreateResponse()
{
// Arrange
HttpRequestMessage request = new HttpRequestMessage();
// Act
HttpResponseMessage response = request.CreateResponse();
// Assert
Assert.Same(request, response.RequestMessage);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
[Fact]
public void CreateResponseWithStatus()
{
// Arrange
HttpRequestMessage request = new HttpRequestMessage();
// Act
HttpResponseMessage response = request.CreateResponse(HttpStatusCode.NotImplemented);
// Assert
Assert.Same(request, response.RequestMessage);
Assert.Equal(HttpStatusCode.NotImplemented, response.StatusCode);
}
}
}
Jump to Line
Something went wrong with that request. Please try again.