Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

58 lines
1.8 KiB
C#

// 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);
}
}
}