forked from zzzprojects/System.Linq.Dynamic.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntitiesTests.LastAsync.cs
More file actions
50 lines (42 loc) · 1.35 KB
/
EntitiesTests.LastAsync.cs
File metadata and controls
50 lines (42 loc) · 1.35 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
50
#if EFCORE
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.DynamicLinq;
#else
using System.Data.Entity;
using EntityFramework.DynamicLinq;
#endif
using System.Threading.Tasks;
using Xunit;
namespace System.Linq.Dynamic.Core.Tests
{
public partial class EntitiesTests
{
// [Maybe not supported : https://msdn.microsoft.com/en-us/library/bb738550.aspx]
#if LASTSUPPORTED
[Fact]
public async Task Entities_LastAsync()
{
//Arrange
PopulateTestData(1, 0);
var expectedQueryable1 = _context.Blogs.Where(b => b.BlogId > 0);
var expected = await expectedQueryable1.LastAsync();
//Act
IQueryable queryable1 = _context.Blogs.Where("BlogId > 0");
var result = await queryable1.LastAsync();
//Assert
Assert.Equal(expected, result);
}
[Fact]
public async Task Entities_LastAsync_Predicate()
{
//Arrange
PopulateTestData(1, 0);
var expected = await EntityFrameworkQueryableExtensions.LastAsync(_context.Blogs, b => b.BlogId > 0);
//Act
var result = await (_context.Blogs.AsQueryable() as IQueryable).LastAsync("it.BlogId > 0");
//Assert
Assert.Equal(expected, result);
}
#endif
}
}