11// Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the MIT license.
33
4+ using System . Globalization ;
45using System . Linq . Expressions ;
56
67namespace Microsoft . AspNetCore . Components . QuickGrid . Tests ;
@@ -147,21 +148,23 @@ public void ToPropertyName_MultipleSort_ReturnsAllProperties()
147148 public void ToPropertyName_InvalidExpression_ThrowsArgumentException ( )
148149 {
149150 // Arrange
150- Expression < Func < TestEntity , string > > invalidExpression = x => x . Name . ToUpper ( ) ;
151+ Expression < Func < TestEntity , string > > invalidExpression = x => x . Name . ToUpper ( CultureInfo . InvariantCulture ) ;
151152
152153 // Act & Assert
153- var exception = Assert . Throws < ArgumentException > ( ( ) => GridSort < TestEntity > . ByAscending ( invalidExpression ) ) ;
154+ var gridSort = GridSort < TestEntity > . ByAscending ( invalidExpression ) ;
155+ var exception = Assert . Throws < ArgumentException > ( ( ) => gridSort . ToPropertyList ( ascending : true ) ) ;
154156 Assert . Contains ( "The supplied expression can't be represented as a property name for sorting" , exception . Message ) ;
155157 }
156158
157159 [ Fact ]
158160 public void ToPropertyName_MethodCallExpression_ThrowsArgumentException ( )
159161 {
160162 // Arrange
161- Expression < Func < TestEntity , int > > invalidExpression = x => x . Name . Length ;
163+ Expression < Func < TestEntity , string > > invalidExpression = x => x . Name . Substring ( 0 , 1 ) ;
162164
163165 // Act & Assert
164- var exception = Assert . Throws < ArgumentException > ( ( ) => GridSort < TestEntity > . ByAscending ( invalidExpression ) ) ;
166+ var gridSort = GridSort < TestEntity > . ByAscending ( invalidExpression ) ;
167+ var exception = Assert . Throws < ArgumentException > ( ( ) => gridSort . ToPropertyList ( ascending : true ) ) ;
165168 Assert . Contains ( "The supplied expression can't be represented as a property name for sorting" , exception . Message ) ;
166169 }
167170
@@ -172,7 +175,8 @@ public void ToPropertyName_ConstantExpression_ThrowsArgumentException()
172175 Expression < Func < TestEntity , string > > invalidExpression = x => "constant" ;
173176
174177 // Act & Assert
175- var exception = Assert . Throws < ArgumentException > ( ( ) => GridSort < TestEntity > . ByAscending ( invalidExpression ) ) ;
178+ var gridSort = GridSort < TestEntity > . ByAscending ( invalidExpression ) ;
179+ var exception = Assert . Throws < ArgumentException > ( ( ) => gridSort . ToPropertyList ( ascending : true ) ) ;
176180 Assert . Contains ( "The supplied expression can't be represented as a property name for sorting" , exception . Message ) ;
177181 }
178182}
0 commit comments