Files
WireMock.Net/test/WireMock.Net.Tests/Http/ByteArrayContentHelperTests.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

45 lines
1.4 KiB
C#

// Copyright © WireMock.Net
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using FluentAssertions;
using WireMock.Http;
using Xunit;
namespace WireMock.Net.Tests.Http;
public class ByteArrayContentHelperTests
{
[Fact]
public async Task ByteArrayContentHelperTests_Create_WithNullContentType()
{
// Arrange
var content = Encoding.UTF8.GetBytes("test");
// Act
var result = ByteArrayContentHelper.Create(content, null);
// Assert
result.Headers.ContentType.Should().BeNull();
(await result.ReadAsByteArrayAsync().ConfigureAwait(false)).Should().BeEquivalentTo(content);
}
[Theory]
[InlineData("application/octet-stream", "application/octet-stream")]
[InlineData("application/soap+xml", "application/soap+xml")]
[InlineData("multipart/form-data; boundary=------------------------x", "multipart/form-data; boundary=------------------------x")]
public async Task ByteArrayContentHelperTests_Create(string test, string expected)
{
// Arrange
var content = Encoding.UTF8.GetBytes("test");
var contentType = MediaTypeHeaderValue.Parse(test);
// Act
var result = ByteArrayContentHelper.Create(content, contentType);
// Assert
result.Headers.ContentType.ToString().Should().Be(expected);
(await result.ReadAsByteArrayAsync().ConfigureAwait(false)).Should().BeEquivalentTo(content);
}
}