-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathExtensionMethodTests.cs
More file actions
61 lines (47 loc) · 1.71 KB
/
ExtensionMethodTests.cs
File metadata and controls
61 lines (47 loc) · 1.71 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
51
52
53
54
55
56
57
58
59
60
61
using System.Linq;
using System.Threading.Tasks;
using EntityFrameworkCore.Projectables.FunctionalTests.Helpers;
using Microsoft.EntityFrameworkCore;
using VerifyXunit;
using Xunit;
namespace EntityFrameworkCore.Projectables.FunctionalTests.ExtensionMethods
{
[UsesVerify]
public class ExtensionMethodTests
{
[Fact]
public Task ExtensionOnPrimitive()
{
using var dbContext = new SampleDbContext<Entity>();
var query = dbContext.Set<Entity>()
.Select(x => x.Id.Squared());
return Verifier.Verify(query.ToQueryString());
}
[Fact]
public Task SelectProjectableExtensionMethod()
{
using var dbContext = new SampleDbContext<Entity>();
var query = dbContext.Set<Entity>()
.Select(x => x.Foo());
return Verifier.Verify(query.ToQueryString());
}
[Fact]
public Task SelectProjectableExtensionMethod2()
{
using var dbContext = new SampleDbContext<Entity>();
var query = dbContext.Set<Entity>()
.Select(x => x.Foo2());
return Verifier.Verify(query.ToQueryString());
}
[Fact]
public Task ExtensionMethodAcceptingDbContext()
{
using var dbContext = new SampleDbContext<Entity>(Infrastructure.CompatibilityMode.Full);
var sampleQuery = dbContext.Set<Entity>()
.Select(x => dbContext.Set<Entity>().Where(y => y.Id > x.Id).FirstOrDefault());
var query = dbContext.Set<Entity>()
.Select(x => x.LeadingEntity(dbContext));
return Verifier.Verify(query.ToQueryString());
}
}
}