forked from zzzprojects/System.Linq.Dynamic.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntitiesTests.Any.cs
More file actions
49 lines (39 loc) · 1.42 KB
/
EntitiesTests.Any.cs
File metadata and controls
49 lines (39 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using Xunit;
namespace System.Linq.Dynamic.Core.Tests
{
public partial class EntitiesTests
{
[Fact]
public void Entities_Any()
{
//Arrange
PopulateTestData(1, 0);
var expectedQueryable1 = _context.Blogs.Where(b => b.BlogId > 0);
bool expectedAny1 = expectedQueryable1.Any();
var expectedQueryable2 = _context.Blogs.Where(b => b.BlogId > 9999);
bool expectedAny2 = expectedQueryable2.Any();
//Act
IQueryable queryable1 = _context.Blogs.Where("BlogId > 0");
bool any1 = queryable1.Any();
IQueryable queryable2 = _context.Blogs.Where("BlogId > 9999");
bool any2 = queryable2.Any();
//Assert
Assert.Equal(expectedAny1, any1);
Assert.Equal(expectedAny2, any2);
}
[Fact]
public void Entities_Any_Predicate()
{
//Arrange
PopulateTestData(1, 0);
bool expectedAny1 = _context.Blogs.Any(b => b.BlogId > 0);
bool expectedAny2 = _context.Blogs.Any(b => b.BlogId > 9999);
//Act
bool any1 = _context.Blogs.AsQueryable().Any("it.BlogId > 0");
bool any2 = _context.Blogs.AsQueryable().Any("it.BlogId > 9999");
//Assert
Assert.Equal(expectedAny1, any1);
Assert.Equal(expectedAny2, any2);
}
}
}