Skip to content

Commit e8c1391

Browse files
committed
#21 : update some Distinct tests
1 parent 8c7fa4f commit e8c1391

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

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

+26-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
using Xunit;
1+
using System.Collections.Generic;
2+
using System.Linq.Dynamic.Core.Tests.Helpers.Models;
3+
using Xunit;
24

35
namespace System.Linq.Dynamic.Core.Tests
46
{
57
public partial class QueryableTests
68
{
79
[Fact]
8-
public void Distinct_Basic()
10+
public void Distinct()
911
{
1012
//Arrange
1113
var list = new[] { 1, 2, 2, 3 };
@@ -20,7 +22,7 @@ public void Distinct_Basic()
2022
}
2123

2224
[Fact]
23-
public void Distinct_Basic_Dynamic()
25+
public void Distinct_Dynamic_1()
2426
{
2527
//Arrange
2628
var list = new[]
@@ -37,5 +39,26 @@ public void Distinct_Basic_Dynamic()
3739
//Assert
3840
Assert.Equal(expected, result);
3941
}
42+
43+
[Fact]
44+
public void Distinct_Dynamic_2()
45+
{
46+
//Arrange
47+
var list = new[]
48+
{
49+
new User { UserName = "a", Income = 1 },
50+
new User { UserName = "a", Income = 2 },
51+
new User { UserName = "b", Income = 1 }
52+
};
53+
54+
//Act
55+
var expected = list.Select(u => u.UserName).Distinct().ToArray();
56+
57+
IQueryable queryable = list.AsQueryable();
58+
var result = queryable.Select("UserName").Distinct().ToDynamicArray<string>();
59+
60+
//Assert
61+
Assert.Equal(expected, result);
62+
}
4063
}
4164
}

0 commit comments

Comments
 (0)