mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-21 08:39:00 +01:00
@@ -175,9 +175,11 @@ namespace WireMock.Net.Tests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("GET")]
|
||||
[InlineData("TRACE")]
|
||||
[InlineData("DELETE")]
|
||||
#if !NET452
|
||||
[InlineData("TRACE")]
|
||||
[InlineData("GET")]
|
||||
#endif
|
||||
public async Task FluentMockServer_Should_exclude_body_for_methods_where_body_is_definitely_disallowed(string method)
|
||||
{
|
||||
// Assign
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
using FluentAssertions;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using WireMock.RequestBuilders;
|
||||
using WireMock.ResponseBuilders;
|
||||
using WireMock.Server;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.ResponseBuilders
|
||||
{
|
||||
public class ResponseWithBodyFromFileTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task Response_ProvideResponse_WithBodyFromFile()
|
||||
{
|
||||
// Arrange
|
||||
var server = FluentMockServer.Start();
|
||||
|
||||
string path = Path.Combine(Directory.GetCurrentDirectory(), "__admin", "mappings", "MyXmlResponse.xml");
|
||||
|
||||
server
|
||||
.Given(
|
||||
Request
|
||||
.Create()
|
||||
.UsingGet()
|
||||
.WithPath("/v1/content")
|
||||
)
|
||||
.RespondWith(
|
||||
Response
|
||||
.Create()
|
||||
.WithStatusCode(HttpStatusCode.OK)
|
||||
.WithHeader("Content-Type", "application/xml")
|
||||
.WithBodyFromFile(path)
|
||||
);
|
||||
|
||||
// Act
|
||||
var response = await new HttpClient().GetStringAsync("http://localhost:" + server.Ports[0] + "/v1/content");
|
||||
|
||||
// Assert
|
||||
response.Should().Contain("<hello>world</hello>");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user