Workaround for: Random.Generate Type="Long" (#1034)

* Workaround for: Random.Generate Type="Long"

* x

* 11

* .

* 2
This commit is contained in:
Stef Heyenrath
2023-12-09 09:18:16 +01:00
committed by GitHub
parent c6c7ba13b4
commit 8e1b6f87f0
3 changed files with 32 additions and 11 deletions

View File

@@ -1,5 +1,6 @@
using System.Linq;
using System.Threading.Tasks;
using FluentAssertions;
using Moq;
using Newtonsoft.Json.Linq;
using NFluent;
@@ -149,7 +150,7 @@ public class ResponseWithHandlebarsRandomTests
}
[Fact]
public async Task Response_ProvideResponseAsync_Handlebars_Random2()
public async Task Response_ProvideResponseAsync_Handlebars_Random_Integer()
{
// Assign
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "GET", ClientIp);
@@ -168,4 +169,25 @@ public class ResponseWithHandlebarsRandomTests
JObject j = JObject.FromObject(response.Message.BodyData.BodyAsJson);
Check.That(j["Integer"].Value<int>()).IsStrictlyGreaterThan(10000000).And.IsStrictlyLessThan(99999999);
}
[Fact]
public async Task Response_ProvideResponseAsync_Handlebars_Random_Long()
{
// Assign
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "GET", ClientIp);
var responseBuilder = Response.Create()
.WithBodyAsJson(new
{
Long = "{{#Random Type=\"Long\" Min=1000000000 Max=9999999999}}{{this}}{{/Random}}",
})
.WithTransformer();
// Act
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false);
// Assert
var j = JObject.FromObject(response.Message.BodyData.BodyAsJson);
j["Long"].Value<long>().Should().BeInRange(1000000000, 9999999999);
}
}