mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-24 10:01:00 +01:00
Update BodyParser logic (#212)
* Update BodyParser logic * update logic for byte[] * small update * MyGetKey * myget * dotnet nuget push * dotnet build * Release * . * StringContent * 1.0.4.18-preview-02 * Debug * 1.0.4.18-preview-02 * disable some proxy tests * myget * packagesToPack * fix * <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> * Release * <VersionPrefix>1.0.4.18</VersionPrefix> * fix * BodyParserTests * ResponseBodyData (#216) * ResponseBodyData * refactor tests * LogEntryMapperTests
This commit is contained in:
@@ -319,7 +319,7 @@ namespace WireMock.Net.Tests
|
||||
Check.That(server.LogEntries).HasSize(1);
|
||||
var requestLogged = server.LogEntries.First();
|
||||
Check.That(requestLogged.RequestMessage.Method).IsEqualTo("GET");
|
||||
Check.That(requestLogged.RequestMessage.BodyAsBytes).IsNull();
|
||||
Check.That(requestLogged.RequestMessage.BodyData).IsNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WireMock.RequestBuilders;
|
||||
using WireMock.ResponseBuilders;
|
||||
@@ -67,7 +68,7 @@ namespace WireMock.Net.Tests
|
||||
{
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri($"{server.Urls[0]}{path}"),
|
||||
Content = new StringContent("stringContent")
|
||||
Content = new StringContent("stringContent", Encoding.ASCII)
|
||||
};
|
||||
requestMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("text/plain");
|
||||
requestMessage.Content.Headers.Add("bbb", "test");
|
||||
@@ -75,7 +76,7 @@ namespace WireMock.Net.Tests
|
||||
|
||||
// then
|
||||
var receivedRequest = serverForProxyForwarding.LogEntries.First().RequestMessage;
|
||||
Check.That(receivedRequest.Body).IsEqualTo("stringContent");
|
||||
Check.That(receivedRequest.BodyData.BodyAsString).IsEqualTo("stringContent");
|
||||
Check.That(receivedRequest.Headers).ContainsKey("Content-Type");
|
||||
Check.That(receivedRequest.Headers["Content-Type"].First()).Contains("text/plain");
|
||||
Check.That(receivedRequest.Headers).ContainsKey("bbb");
|
||||
@@ -158,7 +159,7 @@ namespace WireMock.Net.Tests
|
||||
|
||||
// Assert
|
||||
var receivedRequest = serverForProxyForwarding.LogEntries.First().RequestMessage;
|
||||
Check.That(receivedRequest.Body).IsEqualTo("");
|
||||
Check.That(receivedRequest.BodyData.BodyAsString).IsEqualTo("");
|
||||
Check.That(receivedRequest.Headers).ContainsKey("Content-Type");
|
||||
Check.That(receivedRequest.Headers["Content-Type"].First()).Contains("text/plain");
|
||||
}
|
||||
|
||||
@@ -1,115 +1,46 @@
|
||||
using NFluent;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using WireMock.RequestBuilders;
|
||||
using WireMock.ResponseBuilders;
|
||||
using WireMock.Server;
|
||||
using WireMock.Settings;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace WireMock.Net.Tests
|
||||
{
|
||||
public class FluentMockServerProxy2Tests : IDisposable
|
||||
public class FluentMockServerProxy2Tests
|
||||
{
|
||||
private readonly ITestOutputHelper _output;
|
||||
private readonly CancellationTokenSource _cts;
|
||||
private Guid _guid;
|
||||
private string _url;
|
||||
|
||||
public FluentMockServerProxy2Tests(ITestOutputHelper output)
|
||||
{
|
||||
_output = output;
|
||||
|
||||
_cts = new CancellationTokenSource();
|
||||
}
|
||||
|
||||
//private Task Run()
|
||||
//{
|
||||
|
||||
// return Task.Run(() =>
|
||||
// {
|
||||
// _guid = Guid.NewGuid();
|
||||
|
||||
// var targetServer = FluentMockServer.Start();
|
||||
// targetServer.Given(Request.Create().UsingPost().WithPath($"/{_guid}"))
|
||||
// .RespondWith(Response.Create().WithStatusCode(201).WithBodyAsJson(new { p = 42 }).WithHeader("Content-Type", "application/json"));
|
||||
|
||||
// _url = targetServer.Urls[0];
|
||||
|
||||
// //while (!_cts.IsCancellationRequested)
|
||||
// //{
|
||||
// // Thread.Sleep(100);
|
||||
// //}
|
||||
// }, _cts.Token);
|
||||
//}
|
||||
|
||||
private void X()
|
||||
{
|
||||
_guid = Guid.NewGuid();
|
||||
|
||||
var targetServer = FluentMockServer.Start();
|
||||
targetServer.Given(Request.Create().UsingPost().WithPath($"/{_guid}"))
|
||||
.RespondWith(Response.Create().WithStatusCode(201).WithBodyAsJson(new { p = 42 }).WithHeader("Content-Type", "application/json"));
|
||||
|
||||
_url = targetServer.Urls[0];
|
||||
|
||||
// Thread.Sleep(TimeSpan.FromSeconds(3));
|
||||
|
||||
_output.WriteLine(targetServer.Urls[0]);
|
||||
|
||||
//while (!_cts.IsCancellationRequested)
|
||||
//{
|
||||
// Thread.Sleep(100);
|
||||
//}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FluentMockServer_ProxyAndRecordSettings_ShouldProxyContentTypeHeader()
|
||||
public async Task FluentMockServer_ProxyAndRecordSettings_ShouldProxy()
|
||||
{
|
||||
// Assign
|
||||
_output.WriteLine("This is output fr");
|
||||
//var t = new Thread(X);
|
||||
//t.Start();
|
||||
X();
|
||||
_output.WriteLine("started");
|
||||
var server = FluentMockServer.Start();
|
||||
|
||||
Thread.Sleep(TimeSpan.FromSeconds(4));
|
||||
server.Given(Request.Create().UsingPost().WithHeader("prx", "1"))
|
||||
.RespondWith(Response.Create().WithProxy(server.Urls[0]));
|
||||
|
||||
_output.WriteLine("sleep 4 done");
|
||||
|
||||
var server = FluentMockServer.Start(
|
||||
new FluentMockServerSettings
|
||||
{
|
||||
ProxyAndRecordSettings = new ProxyAndRecordSettings
|
||||
{
|
||||
Url = _url
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
_output.WriteLine("started 2");
|
||||
_output.WriteLine(server.Urls[0]);
|
||||
server.Given(Request.Create().UsingPost())
|
||||
.RespondWith(Response.Create().WithStatusCode(201).WithBodyAsJson(new { p = 42 }).WithHeader("Content-Type", "application/json"));
|
||||
|
||||
// Act
|
||||
var response = new HttpClient().PostAsync(new Uri($"{server.Urls[0]}/{_guid}"), new StringContent("{ \"x\": 1 }", Encoding.UTF8, "application/json")).Result;
|
||||
//string content = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
||||
var request = new HttpRequestMessage
|
||||
{
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri($"{server.Urls[0]}/TST"),
|
||||
Content = new StringContent("test")
|
||||
};
|
||||
request.Headers.Add("prx", "1");
|
||||
|
||||
//// Assert
|
||||
//Check.That(content).IsEqualTo("{\"p\":42}");
|
||||
//Check.That(response.StatusCode).IsEqualTo(HttpStatusCode.Created);
|
||||
//Check.That(response.Content.Headers.GetValues("Content-Type").First()).IsEqualTo("application/json");
|
||||
}
|
||||
// Assert
|
||||
var response = await new HttpClient().SendAsync(request);
|
||||
string content = await response.Content.ReadAsStringAsync();
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_cts.Cancel();
|
||||
Check.That(content).IsEqualTo("{\"p\":42}");
|
||||
Check.That(response.StatusCode).IsEqualTo(HttpStatusCode.Created);
|
||||
Check.That(response.Content.Headers.GetValues("Content-Type").First()).IsEqualTo("application/json");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,11 +17,7 @@ namespace WireMock.Net.Tests.Http
|
||||
{
|
||||
// Assign
|
||||
var headers = new Dictionary<string, string[]> { { "x", new[] { "value-1" } } };
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "<xml>hello</xml>"
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body, headers);
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, null, headers);
|
||||
|
||||
// Act
|
||||
var message = HttpRequestMessageHelper.Create(request, "http://url");
|
||||
@@ -36,7 +32,8 @@ namespace WireMock.Net.Tests.Http
|
||||
// Assign
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsBytes = Encoding.UTF8.GetBytes("hi")
|
||||
BodyAsBytes = Encoding.UTF8.GetBytes("hi"),
|
||||
DetectedBodyType = BodyType.Bytes
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "GET", ClientIp, body);
|
||||
|
||||
@@ -53,7 +50,8 @@ namespace WireMock.Net.Tests.Http
|
||||
// Assign
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsJson = new { x = 42 }
|
||||
BodyAsJson = new { x = 42 },
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "GET", ClientIp, body);
|
||||
|
||||
@@ -71,7 +69,28 @@ namespace WireMock.Net.Tests.Http
|
||||
var headers = new Dictionary<string, string[]> { { "Content-Type", new[] { "application/json" } } };
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsJson = new { x = 42 }
|
||||
BodyAsJson = new { x = 42 },
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "GET", ClientIp, body, headers);
|
||||
|
||||
// Act
|
||||
var message = HttpRequestMessageHelper.Create(request, "http://url");
|
||||
|
||||
// Assert
|
||||
Check.That(await message.Content.ReadAsStringAsync()).Equals("{\"x\":42}");
|
||||
Check.That(message.Content.Headers.GetValues("Content-Type")).ContainsExactly("application/json");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void HttpRequestMessageHelper_Create_Json_With_ContentType_ApplicationJson_UTF8()
|
||||
{
|
||||
// Assign
|
||||
var headers = new Dictionary<string, string[]> { { "Content-Type", new[] { "application/json; charset=utf-8" } } };
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsJson = new { x = 42 },
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "GET", ClientIp, body, headers);
|
||||
|
||||
@@ -90,7 +109,8 @@ namespace WireMock.Net.Tests.Http
|
||||
var headers = new Dictionary<string, string[]> { { "Content-Type", new[] { "application/xml" } } };
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "<xml>hello</xml>"
|
||||
BodyAsString = "<xml>hello</xml>",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body, headers);
|
||||
|
||||
@@ -98,7 +118,7 @@ namespace WireMock.Net.Tests.Http
|
||||
var message = HttpRequestMessageHelper.Create(request, "http://url");
|
||||
|
||||
// Assert
|
||||
Check.That(message.Content.Headers.GetValues("Content-Type")).ContainsExactly("application/xml; charset=utf-8");
|
||||
Check.That(message.Content.Headers.GetValues("Content-Type")).ContainsExactly("application/xml");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -108,7 +128,8 @@ namespace WireMock.Net.Tests.Http
|
||||
var headers = new Dictionary<string, string[]> { { "Content-Type", new[] { "application/xml; charset=UTF-8" } } };
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "<xml>hello</xml>"
|
||||
BodyAsString = "<xml>hello</xml>",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body, headers);
|
||||
|
||||
@@ -126,7 +147,8 @@ namespace WireMock.Net.Tests.Http
|
||||
var headers = new Dictionary<string, string[]> { { "Content-Type", new[] { "application/xml; charset=Ascii" } } };
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "<xml>hello</xml>"
|
||||
BodyAsString = "<xml>hello</xml>",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body, headers);
|
||||
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
using System;
|
||||
using NFluent;
|
||||
using WireMock.Admin.Mappings;
|
||||
using WireMock.Matchers;
|
||||
using WireMock.Serialization;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests
|
||||
{
|
||||
public class MatcherMapperTests
|
||||
{
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_MatcherModel_Null()
|
||||
{
|
||||
// Act
|
||||
var result = MatcherMapper.Map((MatcherModel)null);
|
||||
|
||||
// Assert
|
||||
Check.That(result).IsNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_MatcherModel_Exception()
|
||||
{
|
||||
// Assign
|
||||
var model = new MatcherModel { Name = "test" };
|
||||
|
||||
// Act and Assert
|
||||
Check.ThatCode(() => MatcherMapper.Map(model)).Throws<NotSupportedException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_MatcherModel_LinqMatcher_Pattern()
|
||||
{
|
||||
// Assign
|
||||
var model = new MatcherModel
|
||||
{
|
||||
Name = "LinqMatcher",
|
||||
Pattern = "p"
|
||||
};
|
||||
|
||||
// Act
|
||||
var matcher = MatcherMapper.Map(model) as LinqMatcher;
|
||||
|
||||
// Assert
|
||||
Check.That(matcher).IsNotNull();
|
||||
Check.That(matcher.MatchBehaviour).IsEqualTo(MatchBehaviour.AcceptOnMatch);
|
||||
Check.That(matcher.GetPatterns()).ContainsExactly("p");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_MatcherModel_LinqMatcher_Patterns()
|
||||
{
|
||||
// Assign
|
||||
var model = new MatcherModel
|
||||
{
|
||||
Name = "LinqMatcher",
|
||||
Patterns = new[] { "p1", "p2" }
|
||||
};
|
||||
|
||||
// Act
|
||||
var matcher = MatcherMapper.Map(model) as LinqMatcher;
|
||||
|
||||
// Assert
|
||||
Check.That(matcher).IsNotNull();
|
||||
Check.That(matcher.MatchBehaviour).IsEqualTo(MatchBehaviour.AcceptOnMatch);
|
||||
Check.That(matcher.GetPatterns()).Contains(new[] { "p1", "p2" });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_IMatcher_Null()
|
||||
{
|
||||
// Act
|
||||
var result = MatcherMapper.Map((IMatcher)null);
|
||||
|
||||
// Assert
|
||||
Check.That(result).IsNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_IMatcher_LinqMatcher_Pattern()
|
||||
{
|
||||
// Assign
|
||||
var matcher = new LinqMatcher(MatchBehaviour.AcceptOnMatch, "p");
|
||||
|
||||
// Act
|
||||
var result = MatcherMapper.Map(matcher);
|
||||
|
||||
// Assert
|
||||
Check.That(result).IsNotNull();
|
||||
Check.That(result.Name).IsEqualTo("LinqMatcher");
|
||||
Check.That(result.IgnoreCase).IsNull();
|
||||
Check.That(result.Pattern).IsEqualTo("p");
|
||||
Check.That(result.Patterns).IsNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ namespace WireMock.Net.Tests.Owin.Mappers
|
||||
var responseMessage = new ResponseMessage
|
||||
{
|
||||
Headers = new Dictionary<string, WireMockList<string>>(),
|
||||
Body = body
|
||||
BodyData = new BodyData { DetectedBodyType = BodyType.String, BodyAsString = body }
|
||||
};
|
||||
|
||||
// Act
|
||||
@@ -114,7 +114,7 @@ namespace WireMock.Net.Tests.Owin.Mappers
|
||||
var responseMessage = new ResponseMessage
|
||||
{
|
||||
Headers = new Dictionary<string, WireMockList<string>>(),
|
||||
BodyAsBytes = bytes
|
||||
BodyData = new BodyData { DetectedBodyType = BodyType.Bytes, BodyAsBytes = bytes }
|
||||
};
|
||||
|
||||
// Act
|
||||
@@ -128,11 +128,11 @@ namespace WireMock.Net.Tests.Owin.Mappers
|
||||
public async void OwinResponseMapper_MapAsync_BodyAsJson()
|
||||
{
|
||||
// Assign
|
||||
var json = new { t = "x", i = (string)null };
|
||||
var responseMessage = new ResponseMessage
|
||||
{
|
||||
Headers = new Dictionary<string, WireMockList<string>>(),
|
||||
BodyAsJson = new { t = "x", i = (string)null },
|
||||
BodyAsJsonIndented = false
|
||||
BodyData = new BodyData { DetectedBodyType = BodyType.Json, BodyAsJson = json, BodyAsJsonIndented = false }
|
||||
};
|
||||
|
||||
// Act
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace WireMock.Net.Tests.Owin
|
||||
_optionsMock = new Mock<IWireMockMiddlewareOptions>();
|
||||
_optionsMock.SetupAllProperties();
|
||||
_optionsMock.Setup(o => o.Mappings).Returns(new ConcurrentDictionary<Guid, IMapping>());
|
||||
_optionsMock.Setup(o => o.LogEntries).Returns(new ConcurentObservableCollection<LogEntry>());
|
||||
_optionsMock.Setup(o => o.LogEntries).Returns(new ConcurrentObservableCollection<LogEntry>());
|
||||
_optionsMock.Setup(o => o.Scenarios).Returns(new ConcurrentDictionary<string, ScenarioState>());
|
||||
|
||||
_sut = new MappingMatcher(_optionsMock.Object);
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace WireMock.Net.Tests.Owin
|
||||
_optionsMock = new Mock<IWireMockMiddlewareOptions>();
|
||||
_optionsMock.SetupAllProperties();
|
||||
_optionsMock.Setup(o => o.Mappings).Returns(new ConcurrentDictionary<Guid, IMapping>());
|
||||
_optionsMock.Setup(o => o.LogEntries).Returns(new ConcurentObservableCollection<LogEntry>());
|
||||
_optionsMock.Setup(o => o.LogEntries).Returns(new ConcurrentObservableCollection<LogEntry>());
|
||||
_optionsMock.Setup(o => o.Scenarios).Returns(new ConcurrentDictionary<string, ScenarioState>());
|
||||
_optionsMock.Setup(o => o.Logger.Warn(It.IsAny<string>(), It.IsAny<object[]>()));
|
||||
_optionsMock.Setup(o => o.Logger.Error(It.IsAny<string>(), It.IsAny<object[]>()));
|
||||
@@ -79,7 +79,7 @@ namespace WireMock.Net.Tests.Owin
|
||||
// Assert and Verify
|
||||
_optionsMock.Verify(o => o.Logger.Warn(It.IsAny<string>(), It.IsAny<object[]>()), Times.Once);
|
||||
|
||||
Expression<Func<ResponseMessage, bool>> match = r => r.StatusCode == 404 && ((StatusModel)r.BodyAsJson).Status == "No matching mapping found";
|
||||
Expression<Func<ResponseMessage, bool>> match = r => r.StatusCode == 404 && ((StatusModel)r.BodyData.BodyAsJson).Status == "No matching mapping found";
|
||||
_responseMapperMock.Verify(m => m.MapAsync(It.Is(match), It.IsAny<IResponse>()), Times.Once);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace WireMock.Net.Tests.RequestBuilders
|
||||
public void RequestBuilder_WithHeader_FuncIDictionary()
|
||||
{
|
||||
// Act
|
||||
var requestBuilder = (Request)Request.Create().WithHeader((IDictionary<string, string[]> x) => true);
|
||||
var requestBuilder = (Request)Request.Create().WithHeader(x => true);
|
||||
|
||||
// Assert
|
||||
var matchers = requestBuilder.GetPrivateFieldValue<IList<IRequestMatcher>>("_requestMatchers");
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
using System.Collections.Generic;
|
||||
using NFluent;
|
||||
using WireMock.Matchers;
|
||||
using WireMock.Matchers.Request;
|
||||
using WireMock.RequestBuilders;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.RequestBuilders
|
||||
{
|
||||
public class RequestBuilderWithUrlTests
|
||||
{
|
||||
[Fact]
|
||||
public void RequestBuilder_WithUrl_Strings()
|
||||
{
|
||||
// Act
|
||||
var requestBuilder = (Request)Request.Create().WithUrl("http://a", "http://b");
|
||||
|
||||
// Assert
|
||||
var matchers = requestBuilder.GetPrivateFieldValue<IList<IRequestMatcher>>("_requestMatchers");
|
||||
Check.That(matchers.Count()).IsEqualTo(1);
|
||||
Check.That(matchers[0]).IsInstanceOfType(typeof(RequestMessageUrlMatcher));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestBuilder_WithUrl_MatchBehaviour_Strings()
|
||||
{
|
||||
// Act
|
||||
var requestBuilder = (Request)Request.Create().WithUrl(MatchBehaviour.AcceptOnMatch, "http://a", "http://b");
|
||||
|
||||
// Assert
|
||||
var matchers = requestBuilder.GetPrivateFieldValue<IList<IRequestMatcher>>("_requestMatchers");
|
||||
Check.That(matchers.Count()).IsEqualTo(1);
|
||||
Check.That(matchers[0]).IsInstanceOfType(typeof(RequestMessageUrlMatcher));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestBuilder_WithUrl_Funcs()
|
||||
{
|
||||
// Act
|
||||
var requestBuilder = (Request) Request.Create().WithUrl(url => true, url => false);
|
||||
|
||||
// Assert
|
||||
var matchers = requestBuilder.GetPrivateFieldValue<IList<IRequestMatcher>>("_requestMatchers");
|
||||
Check.That(matchers.Count()).IsEqualTo(1);
|
||||
Check.That(matchers[0]).IsInstanceOfType(typeof(RequestMessageUrlMatcher));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestBuilder_WithUrl_IStringMatchers()
|
||||
{
|
||||
// Act
|
||||
var requestBuilder = (Request) Request.Create().WithUrl(new ExactMatcher("http://a"), new ExactMatcher("http://b"));
|
||||
|
||||
// Assert
|
||||
var matchers = requestBuilder.GetPrivateFieldValue<IList<IRequestMatcher>>("_requestMatchers");
|
||||
Check.That(matchers.Count()).IsEqualTo(1);
|
||||
Check.That(matchers[0]).IsInstanceOfType(typeof(RequestMessageUrlMatcher));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using NFluent;
|
||||
using WireMock.Matchers.Request;
|
||||
using WireMock.Models;
|
||||
using WireMock.RequestBuilders;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests
|
||||
{
|
||||
public class RequestCookieTests
|
||||
{
|
||||
private const string ClientIp = "::1";
|
||||
|
||||
[Fact]
|
||||
public void Request_WithCookie_OK()
|
||||
{
|
||||
// given
|
||||
var spec = Request.Create().UsingAnyMethod().WithCookie("session", "a*");
|
||||
|
||||
// when
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, null, null, new Dictionary<string, string> { { "session", "abc" } });
|
||||
|
||||
// then
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
Check.That(spec.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,8 @@ namespace WireMock.Net.Tests.RequestMatchers
|
||||
// Assign
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "b"
|
||||
BodyAsString = "b",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var stringMatcherMock = new Mock<IStringMatcher>();
|
||||
stringMatcherMock.Setup(m => m.IsMatch(It.IsAny<string>())).Returns(0.5d);
|
||||
@@ -43,7 +44,8 @@ namespace WireMock.Net.Tests.RequestMatchers
|
||||
// Assign
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsBytes = new byte[] { 1 }
|
||||
BodyAsBytes = new byte[] { 1 },
|
||||
DetectedBodyType = BodyType.Bytes
|
||||
};
|
||||
var stringMatcherMock = new Mock<IStringMatcher>();
|
||||
stringMatcherMock.Setup(m => m.IsMatch(It.IsAny<string>())).Returns(0.5d);
|
||||
@@ -70,7 +72,8 @@ namespace WireMock.Net.Tests.RequestMatchers
|
||||
// Assign
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsJson = new { value = 42 }
|
||||
BodyAsJson = new { value = 42 },
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
var stringMatcherMock = new Mock<IStringMatcher>();
|
||||
stringMatcherMock.Setup(m => m.IsMatch(It.IsAny<string>())).Returns(0.5d);
|
||||
@@ -84,10 +87,10 @@ namespace WireMock.Net.Tests.RequestMatchers
|
||||
double score = matcher.GetMatchingScore(requestMessage, result);
|
||||
|
||||
// Assert
|
||||
Check.That(score).IsEqualTo(0.0d);
|
||||
Check.That(score).IsEqualTo(0.5d);
|
||||
|
||||
// Verify
|
||||
stringMatcherMock.Verify(m => m.IsMatch(It.IsAny<string>()), Times.Never);
|
||||
stringMatcherMock.Verify(m => m.IsMatch(It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -97,7 +100,8 @@ namespace WireMock.Net.Tests.RequestMatchers
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsJson = new { value = 42 },
|
||||
BodyAsString = "orig"
|
||||
BodyAsString = "orig",
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
var stringMatcherMock = new Mock<IStringMatcher>();
|
||||
stringMatcherMock.Setup(m => m.IsMatch(It.IsAny<string>())).Returns(0.5d);
|
||||
@@ -123,7 +127,8 @@ namespace WireMock.Net.Tests.RequestMatchers
|
||||
// Assign
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsJson = 42
|
||||
BodyAsJson = 42,
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
var objectMatcherMock = new Mock<IObjectMatcher>();
|
||||
objectMatcherMock.Setup(m => m.IsMatch(It.IsAny<object>())).Returns(0.5d);
|
||||
@@ -149,7 +154,8 @@ namespace WireMock.Net.Tests.RequestMatchers
|
||||
// Assign
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsBytes = new byte[] { 1 }
|
||||
BodyAsBytes = new byte[] { 1 },
|
||||
DetectedBodyType = BodyType.Bytes
|
||||
};
|
||||
var objectMatcherMock = new Mock<IObjectMatcher>();
|
||||
objectMatcherMock.Setup(m => m.IsMatch(It.IsAny<object>())).Returns(0.5d);
|
||||
|
||||
@@ -35,7 +35,8 @@ namespace WireMock.Net.Tests
|
||||
// when
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "whatever"
|
||||
BodyAsString = "whatever",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body, new Dictionary<string, string[]> { { "X-toto", new[] { "tata" } } });
|
||||
|
||||
@@ -53,7 +54,8 @@ namespace WireMock.Net.Tests
|
||||
// when
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "whatever"
|
||||
BodyAsString = "whatever",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body, new Dictionary<string, string[]> { { "X-toto", new[] { "ABC" } } });
|
||||
|
||||
@@ -71,7 +73,8 @@ namespace WireMock.Net.Tests
|
||||
// when
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "whatever"
|
||||
BodyAsString = "whatever",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body, new Dictionary<string, string[]> { { "X-toto", new[] { "TaTa" } } });
|
||||
|
||||
@@ -89,7 +92,8 @@ namespace WireMock.Net.Tests
|
||||
// when
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "Hello world!"
|
||||
BodyAsString = "Hello world!",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body);
|
||||
|
||||
@@ -107,7 +111,8 @@ namespace WireMock.Net.Tests
|
||||
// when
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "xxx"
|
||||
BodyAsString = "xxx",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body, new Dictionary<string, string[]> { { "X-toto", new[] { "tata" } } });
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@ namespace WireMock.Net.Tests
|
||||
// Act
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "b"
|
||||
BodyAsString = "b",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POST", ClientIp, body);
|
||||
|
||||
@@ -42,7 +43,8 @@ namespace WireMock.Net.Tests
|
||||
// Act
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsJson = 123
|
||||
BodyAsJson = 123,
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POST", ClientIp, body);
|
||||
|
||||
@@ -60,7 +62,8 @@ namespace WireMock.Net.Tests
|
||||
// Act
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsBytes = new byte[0]
|
||||
BodyAsBytes = new byte[0],
|
||||
DetectedBodyType = BodyType.Bytes
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POST", ClientIp, body);
|
||||
|
||||
@@ -78,7 +81,8 @@ namespace WireMock.Net.Tests
|
||||
// when
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "cat"
|
||||
BodyAsString = "cat",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POST", ClientIp, body);
|
||||
|
||||
@@ -96,7 +100,8 @@ namespace WireMock.Net.Tests
|
||||
// when
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "Hello world!"
|
||||
BodyAsString = "Hello world!",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body);
|
||||
|
||||
@@ -119,7 +124,8 @@ namespace WireMock.Net.Tests
|
||||
<todo-item id='a1'>abc</todo-item>
|
||||
<todo-item id='a2'>def</todo-item>
|
||||
<todo-item id='a3'>xyz</todo-item>
|
||||
</todo-list>"
|
||||
</todo-list>",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body);
|
||||
|
||||
@@ -142,7 +148,8 @@ namespace WireMock.Net.Tests
|
||||
<todo-item id='a1'>abc</todo-item>
|
||||
<todo-item id='a2'>def</todo-item>
|
||||
<todo-item id='a3'>xyz</todo-item>
|
||||
</todo-list>"
|
||||
</todo-list>",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body);
|
||||
|
||||
@@ -160,7 +167,8 @@ namespace WireMock.Net.Tests
|
||||
// when
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "{ \"things\": [ { \"name\": \"RequiredThing\" }, { \"name\": \"Wiremock\" } ] }"
|
||||
BodyAsString = "{ \"things\": [ { \"name\": \"RequiredThing\" }, { \"name\": \"Wiremock\" } ] }",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body);
|
||||
|
||||
@@ -178,7 +186,8 @@ namespace WireMock.Net.Tests
|
||||
// when
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "{ \"things\": { \"name\": \"Wiremock\" } }"
|
||||
BodyAsString = "{ \"things\": { \"name\": \"Wiremock\" } }",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, body);
|
||||
|
||||
@@ -199,7 +208,8 @@ namespace WireMock.Net.Tests
|
||||
{
|
||||
BodyAsJson = JsonConvert.DeserializeObject(jsonString),
|
||||
BodyAsString = jsonString,
|
||||
Encoding = Encoding.UTF8
|
||||
Encoding = Encoding.UTF8,
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, bodyData);
|
||||
@@ -221,7 +231,8 @@ namespace WireMock.Net.Tests
|
||||
{
|
||||
BodyAsJson = JsonConvert.DeserializeObject(jsonString),
|
||||
BodyAsString = jsonString,
|
||||
Encoding = Encoding.UTF8
|
||||
Encoding = Encoding.UTF8,
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, bodyData);
|
||||
@@ -243,7 +254,8 @@ namespace WireMock.Net.Tests
|
||||
{
|
||||
BodyAsJson = JsonConvert.DeserializeObject(jsonString),
|
||||
BodyAsString = jsonString,
|
||||
Encoding = Encoding.UTF8
|
||||
Encoding = Encoding.UTF8,
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp, bodyData);
|
||||
@@ -263,7 +275,8 @@ namespace WireMock.Net.Tests
|
||||
|
||||
var bodyData = new BodyData
|
||||
{
|
||||
BodyAsJson = DateTime.MinValue
|
||||
BodyAsJson = DateTime.MinValue,
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
|
||||
// Act
|
||||
@@ -283,7 +296,8 @@ namespace WireMock.Net.Tests
|
||||
|
||||
var bodyData = new BodyData
|
||||
{
|
||||
BodyAsBytes = new byte[] { 123 }
|
||||
BodyAsBytes = new byte[] { 123 },
|
||||
DetectedBodyType = BodyType.Bytes
|
||||
};
|
||||
|
||||
// Act
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
using NFluent;
|
||||
using WireMock.Matchers;
|
||||
using WireMock.Matchers.Request;
|
||||
using WireMock.Models;
|
||||
using WireMock.RequestBuilders;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests
|
||||
{
|
||||
public class RequestWithUrlTests
|
||||
{
|
||||
private const string ClientIp = "::1";
|
||||
|
||||
[Fact]
|
||||
public void Request_WithUrl()
|
||||
{
|
||||
// given
|
||||
var spec = Request.Create().WithUrl("*/foo");
|
||||
|
||||
// when
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "blabla", ClientIp);
|
||||
|
||||
// then
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
Check.That(spec.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Request_WithUrl_WildcardMatcher()
|
||||
{
|
||||
// given
|
||||
var spec = Request.Create().WithUrl(new WildcardMatcher("*/foo"));
|
||||
|
||||
// when
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "blabla", ClientIp);
|
||||
|
||||
// then
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
Check.That(spec.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Request_WithUrl_Func()
|
||||
{
|
||||
// given
|
||||
var spec = Request.Create().WithUrl(url => url.Contains("foo"));
|
||||
|
||||
// when
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "blabla", ClientIp);
|
||||
|
||||
// then
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
Check.That(spec.GetMatchingScore(request, requestMatchResult)).IsEqualTo(1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
// given
|
||||
var body = new BodyData
|
||||
{
|
||||
DetectedBodyType = BodyType.String,
|
||||
BodyAsString = "abc"
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POST", ClientIp, body);
|
||||
@@ -28,9 +29,9 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// then
|
||||
Check.That(responseMessage.Body).Equals("01");
|
||||
Check.That(responseMessage.BodyAsBytes).IsNull();
|
||||
Check.That(responseMessage.BodyEncoding).Equals(Encoding.ASCII);
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("01");
|
||||
Check.That(responseMessage.BodyData.BodyAsBytes).IsNull();
|
||||
Check.That(responseMessage.BodyData.Encoding).Equals(Encoding.ASCII);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -39,6 +40,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
// given
|
||||
var body = new BodyData
|
||||
{
|
||||
DetectedBodyType = BodyType.String,
|
||||
BodyAsString = "abc"
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POST", ClientIp, body);
|
||||
@@ -49,9 +51,9 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// then
|
||||
Check.That(responseMessage.BodyAsBytes).ContainsExactly(new byte[] { 48, 49 });
|
||||
Check.That(responseMessage.Body).IsNull();
|
||||
Check.That(responseMessage.BodyEncoding).IsNull();
|
||||
Check.That(responseMessage.BodyData.BodyAsBytes).ContainsExactly(new byte[] { 48, 49 });
|
||||
Check.That(responseMessage.BodyData.BodyAsString).IsNull();
|
||||
Check.That(responseMessage.BodyData.Encoding).IsNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -60,6 +62,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
// given
|
||||
var body = new BodyData
|
||||
{
|
||||
DetectedBodyType = BodyType.String,
|
||||
BodyAsString = "abc"
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POST", ClientIp, body);
|
||||
@@ -70,8 +73,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// then
|
||||
Check.That(responseMessage.Body).Equals("test");
|
||||
Check.That(responseMessage.BodyEncoding).Equals(Encoding.ASCII);
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("test");
|
||||
Check.That(responseMessage.BodyData.Encoding).Equals(Encoding.ASCII);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -80,6 +83,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
// given
|
||||
var body = new BodyData
|
||||
{
|
||||
DetectedBodyType = BodyType.String,
|
||||
BodyAsString = "abc"
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POST", ClientIp, body);
|
||||
@@ -91,9 +95,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// then
|
||||
Check.That(responseMessage.BodyAsJson).IsNotNull();
|
||||
Check.That(responseMessage.BodyAsJson).Equals(x);
|
||||
Check.That(responseMessage.BodyEncoding).Equals(Encoding.ASCII);
|
||||
Check.That(responseMessage.BodyData.BodyAsJson).Equals(x);
|
||||
Check.That(responseMessage.BodyData.Encoding).Equals(Encoding.ASCII);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -102,6 +105,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
// given
|
||||
var body = new BodyData
|
||||
{
|
||||
DetectedBodyType = BodyType.String,
|
||||
BodyAsString = "abc"
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POST", ClientIp, body);
|
||||
@@ -113,9 +117,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// then
|
||||
Check.That(responseMessage.BodyAsJson).IsNotNull();
|
||||
Check.That(responseMessage.BodyAsJson).Equals(x);
|
||||
Check.That(responseMessage.BodyAsJsonIndented).IsEqualTo(true);
|
||||
Check.That(responseMessage.BodyData.BodyAsJson).Equals(x);
|
||||
Check.That(responseMessage.BodyData.BodyAsJsonIndented).IsEqualTo(true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -130,10 +133,10 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(responseMessage.BodyAsBytes).IsNull();
|
||||
Check.That(responseMessage.BodyAsJson).IsNull();
|
||||
Check.That(responseMessage.Body).Equals("r");
|
||||
Check.That(responseMessage.BodyEncoding).Equals(Encoding.ASCII);
|
||||
Check.That(responseMessage.BodyData.BodyAsBytes).IsNull();
|
||||
Check.That(responseMessage.BodyData.BodyAsJson).IsNull();
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("r");
|
||||
Check.That(responseMessage.BodyData.Encoding).Equals(Encoding.ASCII);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -148,10 +151,10 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(responseMessage.Body).IsNull();
|
||||
Check.That(responseMessage.BodyAsJson).IsNull();
|
||||
Check.That(responseMessage.BodyAsBytes).IsNotNull();
|
||||
Check.That(responseMessage.BodyEncoding).Equals(Encoding.ASCII);
|
||||
Check.That(responseMessage.BodyData.BodyAsString).IsNull();
|
||||
Check.That(responseMessage.BodyData.BodyAsJson).IsNull();
|
||||
Check.That(responseMessage.BodyData.BodyAsBytes).IsNotNull();
|
||||
Check.That(responseMessage.BodyData.Encoding).Equals(Encoding.ASCII);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -166,10 +169,10 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(responseMessage.Body).IsNull();
|
||||
Check.That(responseMessage.BodyAsBytes).IsNull();
|
||||
Check.That(((dynamic)responseMessage.BodyAsJson).value).Equals(42);
|
||||
Check.That(responseMessage.BodyEncoding).Equals(Encoding.ASCII);
|
||||
Check.That(responseMessage.BodyData.BodyAsString).IsNull();
|
||||
Check.That(responseMessage.BodyData.BodyAsBytes).IsNull();
|
||||
Check.That(((dynamic)responseMessage.BodyData.BodyAsJson).value).Equals(42);
|
||||
Check.That(responseMessage.BodyData.Encoding).Equals(Encoding.ASCII);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -188,10 +191,10 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(responseMessage.Body).IsEqualTo("path: /test");
|
||||
Check.That(responseMessage.BodyAsBytes).IsNull();
|
||||
Check.That(responseMessage.BodyAsJson).IsNull();
|
||||
Check.That(responseMessage.BodyEncoding.CodePage).Equals(Encoding.UTF8.CodePage);
|
||||
Check.That(responseMessage.BodyData.BodyAsString).IsEqualTo("path: /test");
|
||||
Check.That(responseMessage.BodyData.BodyAsBytes).IsNull();
|
||||
Check.That(responseMessage.BodyData.BodyAsJson).IsNull();
|
||||
Check.That(responseMessage.BodyData.Encoding.CodePage).Equals(Encoding.UTF8.CodePage);
|
||||
Check.That(responseMessage.StatusCode).IsEqualTo(500);
|
||||
Check.That(responseMessage.Headers["H1"].ToString()).IsEqualTo("X1");
|
||||
Check.That(responseMessage.Headers["H2"].ToString()).IsEqualTo("X2");
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using NFluent;
|
||||
using WireMock.Models;
|
||||
using WireMock.ResponseBuilders;
|
||||
using WireMock.Util;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.ResponseBuilders
|
||||
@@ -13,13 +14,13 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
{
|
||||
// Assign
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "GET", "::1");
|
||||
var response = Response.Create().WithCallback(req => new ResponseMessage { Body = req.Path + "Bar", StatusCode = 302 });
|
||||
var response = Response.Create().WithCallback(req => new ResponseMessage { BodyData = new BodyData { DetectedBodyType = BodyType.String, BodyAsString = req.Path + "Bar" }, StatusCode = 302 });
|
||||
|
||||
// Act
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(responseMessage.Body).IsEqualTo("/fooBar");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).IsEqualTo("/fooBar");
|
||||
Check.That(responseMessage.StatusCode).IsEqualTo(302);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
]
|
||||
}
|
||||
]
|
||||
}"
|
||||
}",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||
@@ -62,7 +63,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
JObject j = JObject.FromObject(responseMessage.BodyAsJson);
|
||||
JObject j = JObject.FromObject(responseMessage.BodyData.BodyAsJson);
|
||||
Check.That(j["x"]).IsNotNull();
|
||||
Check.That(j["x"]["Name"].ToString()).Equals("Acme Co");
|
||||
}
|
||||
@@ -71,7 +72,11 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
public async Task Response_ProvideResponse_Handlebars_JsonPath_SelectToken_Number_ResponseBodyAsJson()
|
||||
{
|
||||
// Assign
|
||||
var body = new BodyData { BodyAsString = "{ \"Price\": 99 }" };
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "{ \"Price\": 99 }",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||
|
||||
@@ -84,7 +89,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
JObject j = JObject.FromObject(responseMessage.BodyAsJson);
|
||||
JObject j = JObject.FromObject(responseMessage.BodyData.BodyAsJson);
|
||||
Check.That(j["x"].Value<long>()).Equals(99);
|
||||
}
|
||||
|
||||
@@ -123,7 +128,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
]
|
||||
}
|
||||
]
|
||||
}"
|
||||
}",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||
@@ -137,7 +143,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(responseMessage.Body).Equals($"{{{Environment.NewLine} \"Name\": \"Acme Co\",{Environment.NewLine} \"Products\": [{Environment.NewLine} {{{Environment.NewLine} \"Name\": \"Anvil\",{Environment.NewLine} \"Price\": 50{Environment.NewLine} }}{Environment.NewLine} ]{Environment.NewLine}}}");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals($"{{{Environment.NewLine} \"Name\": \"Acme Co\",{Environment.NewLine} \"Products\": [{Environment.NewLine} {{{Environment.NewLine} \"Name\": \"Anvil\",{Environment.NewLine} \"Price\": 50{Environment.NewLine} }}{Environment.NewLine} ]{Environment.NewLine}}}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -175,7 +181,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
]
|
||||
}
|
||||
]
|
||||
}")
|
||||
}"),
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||
@@ -189,7 +196,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(responseMessage.Body).Equals($"{{{Environment.NewLine} \"Name\": \"Acme Co\",{Environment.NewLine} \"Products\": [{Environment.NewLine} {{{Environment.NewLine} \"Name\": \"Anvil\",{Environment.NewLine} \"Price\": 50{Environment.NewLine} }}{Environment.NewLine} ]{Environment.NewLine}}}");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals($"{{{Environment.NewLine} \"Name\": \"Acme Co\",{Environment.NewLine} \"Products\": [{Environment.NewLine} {{{Environment.NewLine} \"Name\": \"Anvil\",{Environment.NewLine} \"Price\": 50{Environment.NewLine} }}{Environment.NewLine} ]{Environment.NewLine}}}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -227,7 +234,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
]
|
||||
}
|
||||
]
|
||||
}"
|
||||
}",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||
@@ -241,7 +249,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(responseMessage.Body).Equals("%0:Anvil%%1:Elbow Grease%");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("%0:Anvil%%1:Elbow Grease%");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -279,7 +287,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
]
|
||||
}
|
||||
]
|
||||
}")
|
||||
}"),
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||
@@ -293,7 +302,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(responseMessage.Body).Equals("%0:Anvil%%1:Elbow Grease%");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("%0:Anvil%%1:Elbow Grease%");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -307,7 +316,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
'Lambton Quay',
|
||||
'Willis Street'
|
||||
]
|
||||
}")
|
||||
}"),
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
JObject j = JObject.FromObject(responseMessage.BodyAsJson);
|
||||
JObject j = JObject.FromObject(responseMessage.BodyData.BodyAsJson);
|
||||
Check.That(j["x"]).IsNotNull();
|
||||
Check.That(j["x"].ToString()).Equals("/pathtest");
|
||||
}
|
||||
@@ -43,7 +43,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
{
|
||||
{ "Id", new JValue(9) },
|
||||
{ "Name", new JValue("Test") }
|
||||
}
|
||||
},
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", "::1", body);
|
||||
@@ -57,7 +58,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
JObject j = JObject.FromObject(responseMessage.BodyAsJson);
|
||||
JObject j = JObject.FromObject(responseMessage.BodyData.BodyAsJson);
|
||||
Check.That(j["x"]).IsNotNull();
|
||||
Check.That(j["x"].ToString()).Equals("Test_123");
|
||||
}
|
||||
@@ -72,7 +73,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
{
|
||||
{ "Id", new JValue(9) },
|
||||
{ "Name", new JValue("Test") }
|
||||
}
|
||||
},
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", "::1", body);
|
||||
@@ -86,7 +88,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
JObject j = JObject.FromObject(responseMessage.BodyAsJson);
|
||||
JObject j = JObject.FromObject(responseMessage.BodyData.BodyAsJson);
|
||||
Check.That(j["x"]).IsNotNull();
|
||||
Check.That(j["x"].ToString()).Equals("{ N = Test_123, I = 9 }");
|
||||
}
|
||||
@@ -101,7 +103,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
{
|
||||
{ "Id", new JValue(9) },
|
||||
{ "Name", new JValue("Test") }
|
||||
}
|
||||
},
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", "::1", body);
|
||||
@@ -115,7 +118,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
JObject j = JObject.FromObject(responseMessage.BodyAsJson);
|
||||
JObject j = JObject.FromObject(responseMessage.BodyData.BodyAsJson);
|
||||
Check.That(j["x"]).IsNotNull();
|
||||
Check.That(j["x"].ToString()).Equals("{ N = Test_123, I = 9 }");
|
||||
}
|
||||
@@ -124,7 +127,11 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
public void Response_ProvideResponse_Handlebars_Linq_Throws_NotSupportedException()
|
||||
{
|
||||
// Assign
|
||||
var body = new BodyData { BodyAsJson = new { x = "x" }};
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsJson = new { x = "x" },
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", "::1", body);
|
||||
|
||||
@@ -178,7 +185,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
{
|
||||
{ "Id", new JValue(9) },
|
||||
{ "Name", new JValue("Test") }
|
||||
}
|
||||
},
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", "::1", body);
|
||||
@@ -191,7 +199,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
JObject j = JObject.FromObject(responseMessage.BodyAsJson);
|
||||
JObject j = JObject.FromObject(responseMessage.BodyData.BodyAsJson);
|
||||
Check.That(j["x"].ToString()).IsEmpty();
|
||||
}
|
||||
|
||||
@@ -205,7 +213,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
{
|
||||
{ "Id", new JValue(9) },
|
||||
{ "Name", new JValue("Test") }
|
||||
}
|
||||
},
|
||||
DetectedBodyType = BodyType.Json
|
||||
};
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", "::1", body);
|
||||
@@ -218,7 +227,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
JObject j = JObject.FromObject(responseMessage.BodyAsJson);
|
||||
JObject j = JObject.FromObject(responseMessage.BodyData.BodyAsJson);
|
||||
Check.That(j["x"].ToString()).IsEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
public async void Response_ProvideResponse_Handlebars_RegexMatch()
|
||||
{
|
||||
// Assign
|
||||
var body = new BodyData { BodyAsString = "abc" };
|
||||
var body = new BodyData { BodyAsString = "abc", DetectedBodyType = BodyType.String };
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||
|
||||
@@ -27,14 +27,14 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// assert
|
||||
Check.That(responseMessage.Body).Equals("abc");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("abc");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void Response_ProvideResponse_Handlebars_RegexMatch_NoMatch()
|
||||
{
|
||||
// Assign
|
||||
var body = new BodyData { BodyAsString = "abc" };
|
||||
var body = new BodyData { BodyAsString = "abc", DetectedBodyType = BodyType.String };
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||
|
||||
@@ -46,14 +46,14 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// assert
|
||||
Check.That(responseMessage.Body).Equals("");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void Response_ProvideResponse_Handlebars_RegexMatch_NoMatch_WithDefaultValue()
|
||||
{
|
||||
// Assign
|
||||
var body = new BodyData { BodyAsString = "abc" };
|
||||
var body = new BodyData { BodyAsString = "abc", DetectedBodyType = BodyType.String };
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||
|
||||
@@ -65,14 +65,14 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// assert
|
||||
Check.That(responseMessage.Body).Equals("d");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("d");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void Response_ProvideResponse_Handlebars_RegexMatch2()
|
||||
{
|
||||
// Assign
|
||||
var body = new BodyData { BodyAsString = "https://localhost:5000/" };
|
||||
var body = new BodyData { BodyAsString = "https://localhost:5000/", DetectedBodyType = BodyType.String };
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||
|
||||
@@ -84,14 +84,14 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// assert
|
||||
Check.That(responseMessage.Body).Equals("5000-https");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("5000-https");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void Response_ProvideResponse_Handlebars_RegexMatch2_NoMatch()
|
||||
{
|
||||
// Assign
|
||||
var body = new BodyData { BodyAsString = "{{\\test" };
|
||||
var body = new BodyData { BodyAsString = "{{\\test", DetectedBodyType = BodyType.String };
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||
|
||||
@@ -103,14 +103,14 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// assert
|
||||
Check.That(responseMessage.Body).Equals("");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async void Response_ProvideResponse_Handlebars_RegexMatch2_NoMatch_WithDefaultValue()
|
||||
{
|
||||
// Assign
|
||||
var body = new BodyData { BodyAsString = "{{\\test" };
|
||||
var body = new BodyData { BodyAsString = "{{\\test", DetectedBodyType = BodyType.String };
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||
|
||||
@@ -122,14 +122,14 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// assert
|
||||
Check.That(responseMessage.Body).Equals("x");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("x");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Response_ProvideResponse_Handlebars_RegexMatch2_Throws()
|
||||
{
|
||||
// Assign
|
||||
var body = new BodyData { BodyAsString = "{{\\test" };
|
||||
var body = new BodyData { BodyAsString = "{{\\test", DetectedBodyType = BodyType.String };
|
||||
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var bodyData = new BodyData
|
||||
{
|
||||
BodyAsJson = JsonConvert.DeserializeObject(jsonString),
|
||||
DetectedBodyType = BodyType.Json,
|
||||
Encoding = Encoding.UTF8
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo_object"), "POST", ClientIp, bodyData);
|
||||
@@ -40,7 +41,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(JsonConvert.SerializeObject(responseMessage.BodyAsJson)).Equals("{\"x\":\"test /foo_object\"}");
|
||||
Check.That(JsonConvert.SerializeObject(responseMessage.BodyData.BodyAsJson)).Equals("{\"x\":\"test /foo_object\"}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -49,7 +50,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
// Assign
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "whatever"
|
||||
BodyAsString = "whatever",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POSt", ClientIp, body);
|
||||
|
||||
@@ -61,7 +63,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(responseMessage.Body).Equals("test http://localhost/foo /foo POSt");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("test http://localhost/foo /foo POSt");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -79,7 +81,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(responseMessage.Body).Equals("http://localhost/a/b http://localhost/wiremock/a/b /a/b /wiremock/a/b");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("http://localhost/a/b http://localhost/wiremock/a/b /a/b /wiremock/a/b");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -97,7 +99,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(responseMessage.Body).Equals("a wiremock");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("a wiremock");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -106,7 +108,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
// Assign
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "abc"
|
||||
BodyAsString = "abc",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo?a=1&a=2&b=5"), "POST", ClientIp, body);
|
||||
|
||||
@@ -118,7 +121,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(responseMessage.Body).Equals("test keya=1 idx=1 idx=2 keyb=5");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("test keya=1 idx=1 idx=2 keyb=5");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -127,7 +130,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
// Assign
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "abc"
|
||||
BodyAsString = "abc",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POST", ClientIp, body, new Dictionary<string, string[]> { { "Content-Type", new[] { "text/plain" } } });
|
||||
|
||||
@@ -137,7 +141,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(responseMessage.Body).Equals("test");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("test");
|
||||
Check.That(responseMessage.Headers).ContainsKey("x");
|
||||
Check.That(responseMessage.Headers["x"]).ContainsExactly("text/plain");
|
||||
}
|
||||
@@ -148,7 +152,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
// Assign
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "abc"
|
||||
BodyAsString = "abc",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo"), "POST", ClientIp, body, new Dictionary<string, string[]> { { "Content-Type", new[] { "text/plain" } } });
|
||||
|
||||
@@ -158,7 +163,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(responseMessage.Body).Equals("test");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("test");
|
||||
Check.That(responseMessage.Headers).ContainsKey("x");
|
||||
Check.That(responseMessage.Headers["x"]).Contains("text/plain");
|
||||
Check.That(responseMessage.Headers["x"]).Contains("http://localhost/foo");
|
||||
@@ -170,7 +175,8 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
// Assign
|
||||
var body = new BodyData
|
||||
{
|
||||
BodyAsString = "abc"
|
||||
BodyAsString = "abc",
|
||||
DetectedBodyType = BodyType.String
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "POST", ClientIp, body);
|
||||
|
||||
@@ -182,7 +188,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(responseMessage.Body).Equals("test http://localhost:1234 1234 http localhost");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).Equals("test http://localhost:1234 1234 http localhost");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -193,6 +199,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var bodyData = new BodyData
|
||||
{
|
||||
BodyAsJson = JsonConvert.DeserializeObject(jsonString),
|
||||
DetectedBodyType = BodyType.Json,
|
||||
Encoding = Encoding.UTF8
|
||||
};
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost/foo_array"), "POST", ClientIp, bodyData);
|
||||
@@ -205,7 +212,7 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(JsonConvert.SerializeObject(responseMessage.BodyAsJson)).Equals("[\"first\",\"/foo_array\",\"test 1\",\"test 2\",\"last\"]");
|
||||
Check.That(JsonConvert.SerializeObject(responseMessage.BodyData.BodyAsJson)).Equals("[\"first\",\"/foo_array\",\"test 1\",\"test 2\",\"last\"]");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,39 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
{
|
||||
private const string ClientIp = "::1";
|
||||
|
||||
[Theory]
|
||||
[InlineData("Content-Length", "1024")]
|
||||
[InlineData("Transfer-Encoding", "identity")]
|
||||
[InlineData("Location", "http://test")]
|
||||
public async Task Response_ProvideResponse_WithHeader_SingleValue(string headerName, string headerValue)
|
||||
{
|
||||
// Assign
|
||||
var requestMock = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp);
|
||||
IResponseBuilder builder = Response.Create().WithHeader(headerName, headerValue);
|
||||
|
||||
// Act
|
||||
var response = await builder.ProvideResponseAsync(requestMock);
|
||||
|
||||
// Assert
|
||||
Check.That(response.Headers[headerName].ToString()).Equals(headerValue);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Test", new[] { "one" })]
|
||||
[InlineData("Test", new[] { "a", "b" })]
|
||||
public async Task Response_ProvideResponse_WithHeader_MultipleValues(string headerName, string[] headerValues)
|
||||
{
|
||||
// Assign
|
||||
var requestMock = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp);
|
||||
IResponseBuilder builder = Response.Create().WithHeader(headerName, headerValues);
|
||||
|
||||
// Act
|
||||
var response = await builder.ProvideResponseAsync(requestMock);
|
||||
|
||||
// Assert
|
||||
Check.That(response.Headers[headerName].ToArray()).Equals(headerValues);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Response_ProvideResponse_WithHeaders_SingleValue()
|
||||
{
|
||||
|
||||
@@ -30,14 +30,14 @@ namespace WireMock.Net.Tests.ResponseBuilders
|
||||
{
|
||||
// Assign
|
||||
var headers = new Dictionary<string, string[]> { { "Content-Type", new[] { "application/xml" } } };
|
||||
var request = new RequestMessage(new UrlDetails($"{_server.Urls[0]}/{_guid}"), "POST", "::1", new BodyData { BodyAsJson = new { a = 1 } }, headers);
|
||||
var request = new RequestMessage(new UrlDetails($"{_server.Urls[0]}/{_guid}"), "POST", "::1", new BodyData { DetectedBodyType = BodyType.Json, BodyAsJson = new { a = 1 } }, headers);
|
||||
var response = Response.Create().WithProxy(_server.Urls[0]);
|
||||
|
||||
// Act
|
||||
var responseMessage = await response.ProvideResponseAsync(request);
|
||||
|
||||
// Assert
|
||||
Check.That(responseMessage.Body).IsEqualTo("{\"p\":42}");
|
||||
Check.That(responseMessage.BodyData.BodyAsString).IsEqualTo("{\"p\":42}");
|
||||
Check.That(responseMessage.StatusCode).IsEqualTo(201);
|
||||
Check.That(responseMessage.Headers["Content-Type"].ToString()).IsEqualTo("application/json");
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
using NFluent;
|
||||
using WireMock.Models;
|
||||
using WireMock.ResponseBuilders;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests
|
||||
{
|
||||
public class ResponseTests
|
||||
{
|
||||
private const string ClientIp = "::1";
|
||||
|
||||
[Theory]
|
||||
[InlineData("Content-Length", "1024")]
|
||||
[InlineData("Transfer-Encoding", "identity")]
|
||||
[InlineData("Location", "http://test")]
|
||||
public async void Response_Create_WithHeader(string headerName, string headerValue)
|
||||
{
|
||||
// Assign
|
||||
var requestMock = new RequestMessage(new UrlDetails("http://localhost/foo"), "PUT", ClientIp);
|
||||
IResponseBuilder builder = Response.Create().WithHeader(headerName, headerValue);
|
||||
|
||||
// Act
|
||||
var response = await builder.ProvideResponseAsync(requestMock);
|
||||
|
||||
// Assert
|
||||
Check.That(response.Headers[headerName].ToString()).Equals(headerValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
92
test/WireMock.Net.Tests/Serialization/LogEntryMapperTests.cs
Normal file
92
test/WireMock.Net.Tests/Serialization/LogEntryMapperTests.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using NFluent;
|
||||
using WireMock.Logging;
|
||||
using WireMock.Models;
|
||||
using WireMock.Serialization;
|
||||
using WireMock.Util;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.Serialization
|
||||
{
|
||||
public class LogEntryMapperTests
|
||||
{
|
||||
[Fact]
|
||||
public void LogEntryMapper_Map_LogEntry_Check_BodyTypeBytes()
|
||||
{
|
||||
// Assign
|
||||
var logEntry = new LogEntry
|
||||
{
|
||||
RequestMessage = new RequestMessage(
|
||||
new UrlDetails("http://localhost"),
|
||||
"post",
|
||||
"::1",
|
||||
new BodyData
|
||||
{
|
||||
DetectedBodyType = BodyType.Bytes,
|
||||
BodyAsBytes = new byte[] { 0 }
|
||||
}
|
||||
),
|
||||
ResponseMessage = new ResponseMessage
|
||||
{
|
||||
BodyData = new BodyData
|
||||
{
|
||||
DetectedBodyType = BodyType.Bytes,
|
||||
BodyAsBytes = new byte[] { 0 }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = LogEntryMapper.Map(logEntry);
|
||||
|
||||
// Assert
|
||||
Check.That(result.Request.DetectedBodyType).IsEqualTo("Bytes");
|
||||
Check.That(result.Request.DetectedBodyTypeFromContentType).IsEqualTo("None");
|
||||
Check.That(result.Request.BodyAsBytes).ContainsExactly(new byte[] { 0 });
|
||||
Check.That(result.Request.Body).IsNull();
|
||||
Check.That(result.Request.BodyAsJson).IsNull();
|
||||
|
||||
Check.That(result.Response.DetectedBodyType).IsEqualTo(BodyType.Bytes);
|
||||
Check.That(result.Response.DetectedBodyTypeFromContentType).IsEqualTo(BodyType.None);
|
||||
Check.That(result.Response.BodyAsBytes).ContainsExactly(new byte[] { 0 });
|
||||
Check.That(result.Response.Body).IsNull();
|
||||
Check.That(result.Response.BodyAsJson).IsNull();
|
||||
Check.That(result.Response.BodyAsFile).IsNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LogEntryMapper_Map_LogEntry_Check_ResponseBodyTypeFile()
|
||||
{
|
||||
// Assign
|
||||
var logEntry = new LogEntry
|
||||
{
|
||||
RequestMessage = new RequestMessage(new UrlDetails("http://localhost"), "get", "::1"
|
||||
),
|
||||
ResponseMessage = new ResponseMessage
|
||||
{
|
||||
BodyData = new BodyData
|
||||
{
|
||||
DetectedBodyType = BodyType.File,
|
||||
BodyAsFile = "test"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = LogEntryMapper.Map(logEntry);
|
||||
|
||||
// Assert
|
||||
Check.That(result.Request.DetectedBodyType).IsNull();
|
||||
Check.That(result.Request.DetectedBodyTypeFromContentType).IsNull();
|
||||
Check.That(result.Request.BodyAsBytes).IsNull();
|
||||
Check.That(result.Request.Body).IsNull();
|
||||
Check.That(result.Request.BodyAsJson).IsNull();
|
||||
|
||||
Check.That(result.Response.DetectedBodyType).IsEqualTo(BodyType.File);
|
||||
Check.That(result.Response.DetectedBodyTypeFromContentType).IsEqualTo(BodyType.None);
|
||||
Check.That(result.Request.BodyAsBytes).IsNull();
|
||||
Check.That(result.Response.Body).IsNull();
|
||||
Check.That(result.Response.BodyAsJson).IsNull();
|
||||
Check.That(result.Response.BodyAsFile).IsEqualTo("test");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using Moq;
|
||||
using System;
|
||||
using Moq;
|
||||
using NFluent;
|
||||
using WireMock.Admin.Mappings;
|
||||
using WireMock.Matchers;
|
||||
using WireMock.Serialization;
|
||||
using Xunit;
|
||||
@@ -36,7 +38,7 @@ namespace WireMock.Net.Tests.Serialization
|
||||
var matcherMock2 = new Mock<IStringMatcher>();
|
||||
|
||||
// Act
|
||||
var models = MatcherMapper.Map(new [] { matcherMock1.Object, matcherMock2.Object });
|
||||
var models = MatcherMapper.Map(new[] { matcherMock1.Object, matcherMock2.Object });
|
||||
|
||||
// Assert
|
||||
Check.That(models).HasSize(2);
|
||||
@@ -73,5 +75,61 @@ namespace WireMock.Net.Tests.Serialization
|
||||
// Assert
|
||||
Check.That(model.IgnoreCase).Equals(true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_MatcherModel_Null()
|
||||
{
|
||||
// Act
|
||||
var result = MatcherMapper.Map((MatcherModel)null);
|
||||
|
||||
// Assert
|
||||
Check.That(result).IsNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_MatcherModel_Exception()
|
||||
{
|
||||
// Assign
|
||||
var model = new MatcherModel { Name = "test" };
|
||||
|
||||
// Act and Assert
|
||||
Check.ThatCode(() => MatcherMapper.Map(model)).Throws<NotSupportedException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_MatcherModel_LinqMatcher_Pattern()
|
||||
{
|
||||
// Assign
|
||||
var model = new MatcherModel
|
||||
{
|
||||
Name = "LinqMatcher",
|
||||
Pattern = "p"
|
||||
};
|
||||
|
||||
// Act
|
||||
var matcher = (LinqMatcher)MatcherMapper.Map(model);
|
||||
|
||||
// Assert
|
||||
Check.That(matcher.MatchBehaviour).IsEqualTo(MatchBehaviour.AcceptOnMatch);
|
||||
Check.That(matcher.GetPatterns()).ContainsExactly("p");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_MatcherModel_LinqMatcher_Patterns()
|
||||
{
|
||||
// Assign
|
||||
var model = new MatcherModel
|
||||
{
|
||||
Name = "LinqMatcher",
|
||||
Patterns = new[] { "p1", "p2" }
|
||||
};
|
||||
|
||||
// Act
|
||||
var matcher = (LinqMatcher)MatcherMapper.Map(model);
|
||||
|
||||
// Assert
|
||||
Check.That(matcher.MatchBehaviour).IsEqualTo(MatchBehaviour.AcceptOnMatch);
|
||||
Check.That(matcher.GetPatterns()).ContainsExactly("p1", "p2");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,49 +9,63 @@ namespace WireMock.Net.Tests.Util
|
||||
{
|
||||
public class BodyParserTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task BodyParser_Parse_ApplicationJson()
|
||||
[Theory]
|
||||
[InlineData("application/json", "{ \"x\": 1 }", BodyType.Json, BodyType.Json)]
|
||||
[InlineData("application/json; charset=utf-8", "{ \"x\": 1 }", BodyType.Json, BodyType.Json)]
|
||||
[InlineData("application/json; odata.metadata=minimal", "{ \"x\": 1 }", BodyType.Json, BodyType.Json)]
|
||||
[InlineData("application/vnd.api+json", "{ \"x\": 1 }", BodyType.Json, BodyType.Json)]
|
||||
[InlineData("application/vnd.test+json", "{ \"x\": 1 }", BodyType.Json, BodyType.Json)]
|
||||
public async Task BodyParser_Parse_ContentTypeJson(string contentType, string bodyAsJson, BodyType detectedBodyType, BodyType detectedBodyTypeFromContentType)
|
||||
{
|
||||
// Assign
|
||||
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes("{ \"x\": 1 }"));
|
||||
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(bodyAsJson));
|
||||
|
||||
// Act
|
||||
var body = await BodyParser.Parse(memoryStream, "application/json");
|
||||
var body = await BodyParser.Parse(memoryStream, contentType);
|
||||
|
||||
// Assert
|
||||
Check.That(body.BodyAsBytes).IsNull();
|
||||
Check.That(body.BodyAsBytes).IsNotNull();
|
||||
Check.That(body.BodyAsJson).IsNotNull();
|
||||
Check.That(body.BodyAsString).Equals("{ \"x\": 1 }");
|
||||
Check.That(body.BodyAsString).Equals(bodyAsJson);
|
||||
Check.That(body.DetectedBodyType).IsEqualTo(detectedBodyType);
|
||||
Check.That(body.DetectedBodyTypeFromContentType).IsEqualTo(detectedBodyTypeFromContentType);
|
||||
}
|
||||
|
||||
[Fact] // http://jsonapi.org/
|
||||
public async Task BodyParser_Parse_ApplicationJsonApi()
|
||||
[Theory]
|
||||
[InlineData("application/xml", "<xml>hello</xml>", BodyType.String, BodyType.String)]
|
||||
[InlineData("something", "hello", BodyType.String, BodyType.Bytes)]
|
||||
public async Task BodyParser_Parse_ContentTypeString(string contentType, string bodyAsString, BodyType detectedBodyType, BodyType detectedBodyTypeFromContentType)
|
||||
{
|
||||
// Assign
|
||||
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes("{ \"x\": 1 }"));
|
||||
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(bodyAsString));
|
||||
|
||||
// Act
|
||||
var body = await BodyParser.Parse(memoryStream, "application/vnd.api+json");
|
||||
var body = await BodyParser.Parse(memoryStream, contentType);
|
||||
|
||||
// Assert
|
||||
Check.That(body.BodyAsBytes).IsNull();
|
||||
Check.That(body.BodyAsJson).IsNotNull();
|
||||
Check.That(body.BodyAsString).Equals("{ \"x\": 1 }");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task BodyParser_Parse_ApplicationXml()
|
||||
{
|
||||
// Assign
|
||||
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes("<xml>hello</xml>"));
|
||||
|
||||
// Act
|
||||
var body = await BodyParser.Parse(memoryStream, "application/xml; charset=UTF-8");
|
||||
|
||||
// Assert
|
||||
Check.That(body.BodyAsBytes).IsNull();
|
||||
Check.That(body.BodyAsBytes).IsNotNull();
|
||||
Check.That(body.BodyAsJson).IsNull();
|
||||
Check.That(body.BodyAsString).Equals("<xml>hello</xml>");
|
||||
Check.That(body.BodyAsString).Equals(bodyAsString);
|
||||
Check.That(body.DetectedBodyType).IsEqualTo(detectedBodyType);
|
||||
Check.That(body.DetectedBodyTypeFromContentType).IsEqualTo(detectedBodyTypeFromContentType);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, "hello", BodyType.String, BodyType.Bytes)]
|
||||
public async Task BodyParser_Parse_ContentTypeIsNull(string contentType, string bodyAsString, BodyType detectedBodyType, BodyType detectedBodyTypeFromContentType)
|
||||
{
|
||||
// Assign
|
||||
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(bodyAsString));
|
||||
|
||||
// Act
|
||||
var body = await BodyParser.Parse(memoryStream, contentType);
|
||||
|
||||
// Assert
|
||||
Check.That(body.BodyAsBytes).IsNotNull();
|
||||
Check.That(body.BodyAsJson).IsNull();
|
||||
Check.That(body.BodyAsString).Equals(bodyAsString);
|
||||
Check.That(body.DetectedBodyType).IsEqualTo(detectedBodyType);
|
||||
Check.That(body.DetectedBodyTypeFromContentType).IsEqualTo(detectedBodyTypeFromContentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="FluentMockServerTests.Proxy.cs" />
|
||||
<Compile Remove="FluentMockServerTests.Proxy2.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -27,17 +28,19 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Threading" Version="4.3.0" />
|
||||
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
|
||||
<PackageReference Include="MimeKitLite" Version="2.0.1" />
|
||||
<PackageReference Include="Moq" Version="4.8.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||
<PackageReference Include="NFluent" Version="2.2.0" />
|
||||
<PackageReference Include="OpenCover" Version="4.6.519" />
|
||||
<PackageReference Include="ReportGenerator" Version="3.1.2" />
|
||||
<PackageReference Include="SimMetrics.Net" Version="1.0.4" />
|
||||
<PackageReference Include="System.Threading" Version="4.3.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.8.18" />
|
||||
<PackageReference Include="xunit" Version="2.4.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.8.18" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
|
||||
|
||||
Reference in New Issue
Block a user