Skip to content

Commit e5bcb38

Browse files
Copilotjaviercn
andcommitted
Fix compilation error by adding InternalsVisibleTo and proper test structure for QuickGrid tests
Co-authored-by: javiercn <[email protected]>
1 parent ca4430e commit e5bcb38

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/Microsoft.AspNetCore.Components.QuickGrid.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@
2323
<Reference Include="Microsoft.AspNetCore.Components.Web" />
2424
</ItemGroup>
2525

26+
<ItemGroup>
27+
<InternalsVisibleTo Include="Microsoft.AspNetCore.Components.QuickGrid.Tests" />
28+
</ItemGroup>
29+
2630
</Project>

src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/test/GridSortTest.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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;
45
using System.Linq.Expressions;
56

67
namespace 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
}

src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/test/Microsoft.AspNetCore.Components.QuickGrid.Tests.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
<Reference Include="Microsoft.AspNetCore.Components.QuickGrid" />
1010
</ItemGroup>
1111

12+
13+
1214
<ItemGroup>
13-
<Compile Include="$(ComponentsSharedSourceRoot)test\**\*.cs" LinkBase="Helpers" />
15+
<GlobalUsings Include="Xunit" />
1416
</ItemGroup>
1517

1618
</Project>

0 commit comments

Comments
 (0)