mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-21 08:39:00 +01:00
Use Guid.TryParseExact with format "D" (#1148)
This commit is contained in:
@@ -105,7 +105,7 @@ public class ResponseWithHandlebarsRandomTests
|
||||
[Theory]
|
||||
[InlineData(ReplaceNodeOptions.EvaluateAndTryToConvert, JTokenType.Guid)]
|
||||
[InlineData(ReplaceNodeOptions.Evaluate, JTokenType.String)]
|
||||
public async Task Response_ProvideResponseAsync_Handlebars_Random1_Guid(ReplaceNodeOptions options, JTokenType expected)
|
||||
public async Task Response_ProvideResponseAsync_Handlebars_Random_Guid(ReplaceNodeOptions options, JTokenType expected)
|
||||
{
|
||||
// Assign
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "GET", ClientIp);
|
||||
@@ -114,7 +114,8 @@ public class ResponseWithHandlebarsRandomTests
|
||||
.WithBodyAsJson(new
|
||||
{
|
||||
Guid1 = "{{Random Type=\"Guid\" Uppercase=false}}",
|
||||
Guid2 = "{{Random Type=\"Guid\"}}"
|
||||
Guid2 = "{{Random Type=\"Guid\"}}",
|
||||
Guid3 = "{{ String.Replace (Random Type=\"Guid\") \"-\" \"\" }}"
|
||||
})
|
||||
.WithTransformer(options);
|
||||
|
||||
@@ -127,6 +128,27 @@ public class ResponseWithHandlebarsRandomTests
|
||||
jObject["Guid2"]!.Type.Should().Be(expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Response_ProvideResponseAsync_Handlebars_Random_StringReplaceGuid()
|
||||
{
|
||||
// Assign
|
||||
var request = new RequestMessage(new UrlDetails("http://localhost:1234"), "GET", ClientIp);
|
||||
|
||||
var responseBuilder = Response.Create()
|
||||
.WithBodyAsJson(new
|
||||
{
|
||||
MyGuid = "{{ String.Replace (Random Type=\"Guid\") \"-\" \"\" }}"
|
||||
})
|
||||
.WithTransformer();
|
||||
|
||||
// Act
|
||||
var response = await responseBuilder.ProvideResponseAsync(_mappingMock.Object, request, _settings).ConfigureAwait(false);
|
||||
|
||||
// Assert
|
||||
var jObject = JObject.FromObject(response.Message.BodyData!.BodyAsJson!);
|
||||
jObject["MyGuid"]!.Type.Should().Be(JTokenType.String);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Response_ProvideResponseAsync_Handlebars_Random1_StringList()
|
||||
{
|
||||
|
||||
@@ -97,7 +97,7 @@ public class StringUtilsTests
|
||||
isConverted.Should().Be(expectedConversion);
|
||||
if (isConverted)
|
||||
{
|
||||
((double) convertedValue).Should().BeApproximately(expectedValue, 0.01);
|
||||
((double)convertedValue).Should().BeApproximately(expectedValue, 0.01);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -106,6 +106,10 @@ public class StringUtilsTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("3F2504E04F8911D39A0C0305E82C3301", false)]
|
||||
[InlineData("{3F2504E04F8911D39A0C0305E82C3301}", false)]
|
||||
[InlineData("(3F2504E04F8911D39A0C0305E82C3301)", false)]
|
||||
[InlineData("{0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}", false)]
|
||||
[InlineData("3F2504E0-4F89-11D3-9A0C-0305E82C3301", true)]
|
||||
[InlineData("00000000-0000-0000-0000-000000000000", true)]
|
||||
[InlineData("3f2504e0-4f89-11d3-9a0c-0305e82c3301", true)] // Lowercase Guid
|
||||
|
||||
Reference in New Issue
Block a user