This commit is contained in:
Stef Heyenrath
2026-02-21 17:21:18 +01:00
parent 43a26ec4bc
commit 43be85a88a
27 changed files with 306 additions and 281 deletions

View File

@@ -1,5 +1,6 @@
// Copyright © WireMock.Net
using System.Net.Http;
using System.Net.Http.Headers;
using AwesomeAssertions;
using WireMock.Http;
@@ -8,15 +9,17 @@ namespace WireMock.Net.Tests.Http;
public class StringContentHelperTests
{
private readonly CancellationToken _ct = TestContext.Current.CancellationToken;
[Fact]
public void StringContentHelper_Create_WithNullContentType()
public async Task StringContentHelper_Create_WithNullContentType()
{
// Act
var result = StringContentHelper.Create("test", null);
// Assert
result.Headers.ContentType.Should().BeNull();
result.ReadAsStringAsync().Result.Should().Be("test");
(await result.ReadAsStringAsync(_ct)).Should().Be("test");
}
[Theory]
@@ -24,7 +27,7 @@ public class StringContentHelperTests
[InlineData("application/soap+xml", "application/soap+xml")]
[InlineData("application/soap+xml;charset=UTF-8", "application/soap+xml; charset=UTF-8")]
[InlineData("application/soap+xml;charset=UTF-8;action=\"http://myCompany.Customer.Contract/ICustomerService/GetSomeConfiguration\"", "application/soap+xml; charset=UTF-8; action=\"http://myCompany.Customer.Contract/ICustomerService/GetSomeConfiguration\"")]
public void StringContentHelper_Create(string test, string expected)
public async Task StringContentHelper_Create(string test, string expected)
{
// Arrange
var contentType = MediaTypeHeaderValue.Parse(test);
@@ -33,7 +36,7 @@ public class StringContentHelperTests
var result = StringContentHelper.Create("test", contentType);
// Assert
result.Headers.ContentType.ToString().Should().Be(expected);
result.ReadAsStringAsync().Result.Should().Be("test");
result.Headers.ContentType?.ToString().Should().Be(expected);
(await result.ReadAsStringAsync(_ct)).Should().Be("test");
}
}