FixNullRef (#295) (#297)

This commit is contained in:
Stef Heyenrath
2019-07-15 17:00:52 +02:00
committed by GitHub
parent 4bcc27ff01
commit 1db2bc7c89
7 changed files with 97 additions and 52 deletions

View File

@@ -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

View File

@@ -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>");
}
}
}