1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
// 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);
}
}
}
|