mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-14 14:23:34 +01:00
45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|