Files
WireMock.Net/test/WireMock.Net.Tests/Http/StringContentHelperTests.cs
Stef Heyenrath 54edf0bebc Add link to TIOBE Index on main page + fix issues (#1137)
* Add TIOBE + include SonarAnalyzer.CSharp

* .

* cp

* Copyright © WireMock.Net

* more fixes

* fix

* xpath

* if (Matchers == null || !Matchers.Any())

* if (Matchers != null)

* ?

* .

* .
2024-07-18 18:06:04 +02:00

40 lines
1.4 KiB
C#

// Copyright © WireMock.Net
using System.Net.Http.Headers;
using FluentAssertions;
using WireMock.Http;
using Xunit;
namespace WireMock.Net.Tests.Http;
public class StringContentHelperTests
{
[Fact]
public void StringContentHelper_Create_WithNullContentType()
{
// Act
var result = StringContentHelper.Create("test", null);
// Assert
result.Headers.ContentType.Should().BeNull();
result.ReadAsStringAsync().Result.Should().Be("test");
}
[Theory]
[InlineData("application/json", "application/json")]
[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)
{
// Arrange
var contentType = MediaTypeHeaderValue.Parse(test);
// Act
var result = StringContentHelper.Create("test", contentType);
// Assert
result.Headers.ContentType.ToString().Should().Be(expected);
result.ReadAsStringAsync().Result.Should().Be("test");
}
}