mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
LinqMatcher (#431)
This commit is contained in:
@@ -151,7 +151,7 @@ namespace WireMock.Util
|
||||
break;
|
||||
|
||||
case JTokenType.Integer:
|
||||
castText = $"int({path})";
|
||||
castText = $"long({path})";
|
||||
break;
|
||||
|
||||
case JTokenType.Null:
|
||||
|
||||
@@ -70,12 +70,13 @@ namespace WireMock.Net.Tests.Matchers
|
||||
// Assign
|
||||
var input = new JObject
|
||||
{
|
||||
{ "Id", new JValue(9) },
|
||||
{ "IntegerId", new JValue(9) },
|
||||
{ "LongId", new JValue(long.MaxValue) },
|
||||
{ "Name", new JValue("Test") }
|
||||
};
|
||||
|
||||
// Act
|
||||
var matcher = new LinqMatcher("Id > 1 AND Name == \"Test\"");
|
||||
var matcher = new LinqMatcher("IntegerId > 1 AND LongId > 1 && Name == \"Test\"");
|
||||
double match = matcher.IsMatch(input);
|
||||
|
||||
// Assert
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace WireMock.Net.Tests.Util
|
||||
{"Flt", new JValue(10.0f)},
|
||||
{"Dbl", new JValue(Math.PI)},
|
||||
{"Check", new JValue(true)},
|
||||
{"Items", new JArray(new[] {new JValue(4), new JValue(8)})},
|
||||
{"Items", new JArray(new[] { new JValue(4), new JValue(8) })},
|
||||
{
|
||||
"Child", new JObject
|
||||
{
|
||||
@@ -61,7 +61,8 @@ namespace WireMock.Net.Tests.Util
|
||||
{"TS", new JValue(TimeSpan.FromMilliseconds(999))}
|
||||
}
|
||||
},
|
||||
{"Id", new JValue(9)},
|
||||
{"I", new JValue(9)},
|
||||
{"L", new JValue(long.MaxValue)},
|
||||
{"Name", new JValue("Test")}
|
||||
};
|
||||
|
||||
@@ -70,10 +71,10 @@ namespace WireMock.Net.Tests.Util
|
||||
|
||||
// Assert
|
||||
var queryable = new[] { j }.AsQueryable().Select(line);
|
||||
bool result = queryable.Any("Id > 4");
|
||||
bool result = queryable.Any("I > 1 && L > 1");
|
||||
Check.That(result).IsTrue();
|
||||
|
||||
Check.That(line).IsEqualTo("new (Uri(U) as U, null as N, Guid(G) as G, double(Flt) as Flt, double(Dbl) as Dbl, bool(Check) as Check, (new [] { int(Items[0]), int(Items[1])}) as Items, new (int(Child.ChildId) as ChildId, DateTime(Child.ChildDateTime) as ChildDateTime, TimeSpan(Child.TS) as TS) as Child, int(Id) as Id, string(Name) as Name)");
|
||||
Check.That(line).IsEqualTo("new (Uri(U) as U, null as N, Guid(G) as G, double(Flt) as Flt, double(Dbl) as Dbl, bool(Check) as Check, (new [] { long(Items[0]), long(Items[1])}) as Items, new (long(Child.ChildId) as ChildId, DateTime(Child.ChildDateTime) as ChildDateTime, TimeSpan(Child.TS) as TS) as Child, long(I) as I, long(L) as L, string(Name) as Name)");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -82,7 +83,7 @@ namespace WireMock.Net.Tests.Util
|
||||
// Assign
|
||||
var j = new JObject
|
||||
{
|
||||
{"B", new JValue(new byte[] {48, 49})}
|
||||
{ "B", new JValue(new byte[] {48, 49}) }
|
||||
};
|
||||
|
||||
// Act and Assert
|
||||
|
||||
Reference in New Issue
Block a user