mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-19 07:43:48 +01:00
Fixed Proxy when using MultipartForm with byte[] (#473)
* wip * ByteArrayContentHelper * ByteArrayContentHelperTests
This commit is contained in:
44
test/WireMock.Net.Tests/Http/ByteArrayContentHelperTests.cs
Normal file
44
test/WireMock.Net.Tests/Http/ByteArrayContentHelperTests.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
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()).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()).Should().BeEquivalentTo(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user