1- using FluentAssertions ;
1+ using System . Linq . Dynamic . Core . CustomTypeProviders ;
2+ using FluentAssertions ;
23using Xunit ;
34
45namespace System . Linq . Dynamic . Core . Tests . Parser
@@ -21,6 +22,67 @@ public void ParseMemberAccess_DictionaryIndex_On_Dynamic()
2122 expression . ToString ( ) . Should ( ) . Be ( "System.Linq.Dynamic.Core.Tests.Parser.ProductDynamic[].Where(Param_0 => ([Dynamic] == Convert(\" First Product\" , Object)))" ) ;
2223#endif
2324 }
25+
26+ [ Theory ]
27+ [ InlineData ( "Prop" , "TestProp" ) ]
28+ [ InlineData ( "Field" , "TestField" ) ]
29+ public void Parse_StaticPropertyOrField_In_StaticClass1 ( string name , string value )
30+ {
31+ // Arrange
32+ var queryable = new int [ 1 ] . AsQueryable ( ) ;
33+
34+ // Act
35+ var result = queryable . Select < string > ( $ "{ typeof ( StaticClassExample ) } .{ name } ") . First ( ) ;
36+
37+ // Assert
38+ Assert . Equal ( value , result ) ;
39+ }
40+
41+ [ Theory ]
42+ [ InlineData ( "Prop" , "TestProp" ) ]
43+ [ InlineData ( "Field" , "TestField" ) ]
44+ public void Parse_StaticPropertyOrField_In_NonStaticClass1 ( string name , string value )
45+ {
46+ // Arrange
47+ var queryable = new int [ 1 ] . AsQueryable ( ) ;
48+
49+ // Act
50+ var result = queryable . Select < string > ( $ "new { typeof ( NonStaticClassExample ) } ().{ name } ") . First ( ) ;
51+
52+ // Assert
53+ Assert . Equal ( value , result ) ;
54+ }
55+
56+ [ Theory ]
57+ [ InlineData ( "Prop" , "TestProp" ) ]
58+ [ InlineData ( "Field" , "TestField" ) ]
59+ public void Parse_StaticPropertyOrField_In_NonStaticClass2 ( string name , string value )
60+ {
61+ // Arrange
62+ var queryable = new [ ] { new NonStaticClassExample ( ) } . AsQueryable ( ) ;
63+
64+ // Act
65+ var result = queryable . Select < string > ( name ) . First ( ) ;
66+
67+ // Assert
68+ Assert . Equal ( value , result ) ;
69+ }
70+ }
71+
72+ [ DynamicLinqType ]
73+ public class StaticClassExample
74+ {
75+ public static string Prop { get ; set ; } = "TestProp" ;
76+
77+ public static string Field = "TestField" ;
78+ }
79+
80+ [ DynamicLinqType ]
81+ public class NonStaticClassExample
82+ {
83+ public static string Prop { get ; set ; } = "TestProp" ;
84+
85+ public static string Field = "TestField" ;
2486 }
2587
2688 public class ProductDynamic
0 commit comments