Skip to content

Commit dc6fa18

Browse files
committed
tests
1 parent d6b966e commit dc6fa18

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

test/System.Linq.Dynamic.Core.Tests/Parser/MethodFinderTest.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,11 @@ public class MethodFinderTest
1212
public void Method_ToString_OnDynamicLinq_And_SystemLinq_ShouldBeEqual()
1313
{
1414
// Arrange
15-
var config = new ParsingConfig
16-
{
17-
// AllowEqualsAndToStringMethodsOnObject = true
18-
};
19-
2015
Expression<Func<int, string>> expr = x => x.ToString();
2116

2217
var selector = "ToString()";
2318
var prm = Parameter(typeof(int));
24-
var parser = new ExpressionParser([prm], selector, [], config);
19+
var parser = new ExpressionParser([prm], selector, [], ParsingConfig.Default);
2520

2621
// Act
2722
var expression = parser.Parse(null);

test/System.Linq.Dynamic.Core.Tests/QueryableTests.Where.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Linq.Dynamic.Core.Tests.Helpers.Models;
77
using System.Linq.Expressions;
88
using System.Text;
9-
using Docker.DotNet.Models;
109
using FluentAssertions;
1110
using Xunit;
1211

@@ -495,6 +494,28 @@ public void Where_Dynamic_NullPropagation_Test2_On_NullableDoubleToString_When_A
495494
result.Should().ContainInOrder(5, 50);
496495
}
497496

497+
[Fact]
498+
public void Where_Dynamic_ToStringOnGuid()
499+
{
500+
// Arrange
501+
const string fieldName = "Id";
502+
const string value = "F370C09";
503+
var data = new List<DataWithId>
504+
{
505+
new(Guid.NewGuid(), "bla1"),
506+
new(Guid.NewGuid(), "bla2"),
507+
new(Guid.NewGuid(), "bla3"),
508+
new(Guid.NewGuid(), "bla4"),
509+
new(new Guid("F370C098-8A29-4CF0-9B58-7F3CE258B607"), "bla5")
510+
}.AsQueryable();
511+
512+
// Act
513+
var result = data.Where(fieldName + ".ToString().StartsWith(\"" + value.ToLowerInvariant() + "\")").ToArray();
514+
515+
// Assert
516+
result.Should().HaveCount(1);
517+
}
518+
498519
[ExcludeFromCodeCoverage]
499520
private class PersonWithObject
500521
{
@@ -525,4 +546,7 @@ public class Foo
525546

526547
public DateTime DateTime { get; set; }
527548
}
549+
550+
[ExcludeFromCodeCoverage]
551+
public record DataWithId(Guid Id, string Field);
528552
}

0 commit comments

Comments
 (0)