forked from EFNext/EntityFrameworkCore.Projectables
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExplicitInterfaceImplementationTests.cs
More file actions
55 lines (44 loc) · 1.46 KB
/
ExplicitInterfaceImplementationTests.cs
File metadata and controls
55 lines (44 loc) · 1.46 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
using System;
using System.Linq;
using System.Threading.Tasks;
using EntityFrameworkCore.Projectables.FunctionalTests.Helpers;
using Microsoft.EntityFrameworkCore;
using VerifyXunit;
using Xunit;
#nullable disable
namespace EntityFrameworkCore.Projectables.FunctionalTests
{
[UsesVerify]
public class ExplicitInterfaceImplementationTests
{
public interface IStringId
{
string Id { get; }
}
public class Item : IStringId
{
public int Id { get; set; }
// Explicit interface implementation without [Projectable]
// This tests that GetImplementingProperty handles this scenario
string IStringId.Id => Id.ToString();
[Projectable]
public string FormattedId => Id.ToString();
}
[Fact]
public Task ProjectOverExplicitInterfaceImplementation()
{
using var dbContext = new SampleDbContext<Item>();
var query = dbContext.Set<Item>()
.Select(x => x.FormattedId);
return Verifier.Verify(query.ToQueryString());
}
[Fact]
public Task FilterOnExplicitInterfaceImplementation()
{
using var dbContext = new SampleDbContext<Item>();
var query = dbContext.Set<Item>()
.Where(x => x.FormattedId == "123");
return Verifier.Verify(query.ToQueryString());
}
}
}