1- using FluentAssertions ;
1+ using System . Collections . Generic ;
2+ using System . Linq . Dynamic . Core . Exceptions ;
3+ using System . Linq . Dynamic . Core . NewtonsoftJson . Config ;
4+ using FluentAssertions ;
25using Newtonsoft . Json . Linq ;
36using Xunit ;
47
@@ -506,4 +509,62 @@ public void Where_With_Select()
506509 var first = result . First ( ) ;
507510 first . Value < string > ( ) . Should ( ) . Be ( "Doe" ) ;
508511 }
512+
513+ //[Fact]
514+ //public void Where_OptionalProperty()
515+ //{
516+ // // Arrange
517+ // var config = new NewtonsoftJsonParsingConfig
518+ // {
519+ // ConvertObjectToSupportComparison = true
520+ // };
521+ // var array =
522+ // """
523+ // [
524+ // {
525+ // "Name": "John",
526+ // "Age": 30
527+ // },
528+ // {
529+ // "Name": "Doe"
530+ // }
531+ // ]
532+ // """;
533+
534+ // // Act
535+ // var result = JArray.Parse(array).Where(config, "Age > 30").Select("Name");
536+
537+ // // Assert
538+ // result.Should().HaveCount(1);
539+ // var first = result.First();
540+ // first.Value<string>().Should().Be("John");
541+ //}
542+
543+ [ Theory ]
544+ [ InlineData ( "notExisting == true" ) ]
545+ [ InlineData ( "notExisting == \" true\" " ) ]
546+ [ InlineData ( "notExisting == 1" ) ]
547+ [ InlineData ( "notExisting == \" 1\" " ) ]
548+ [ InlineData ( "notExisting == \" something\" " ) ]
549+ [ InlineData ( "notExisting > 1" ) ]
550+ [ InlineData ( "true == notExisting" ) ]
551+ [ InlineData ( "\" true\" == notExisting" ) ]
552+ [ InlineData ( "1 == notExisting" ) ]
553+ [ InlineData ( "\" 1\" == notExisting" ) ]
554+ [ InlineData ( "\" something\" == notExisting" ) ]
555+ [ InlineData ( "1 < notExisting" ) ]
556+ public void Where_NonExistingMember_EmptyResult ( string predicate )
557+ {
558+ // Arrange
559+ var config = new NewtonsoftJsonParsingConfig
560+ {
561+ ConvertObjectToSupportComparison = true
562+ } ;
563+
564+ // Act
565+ var result = _source . Where ( config , predicate ) ;
566+
567+ // Assert
568+ result . Should ( ) . BeEmpty ( ) ;
569+ }
509570}
0 commit comments