Skip to content

Commit 7953b75

Browse files
Added a new test for the fetch strategies
1 parent 6b13e42 commit 7953b75

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
namespace DotNetToolkit.Repository.Test.Data
2+
{
3+
public class Customer
4+
{
5+
public int Id { get; set; }
6+
public string Name { get; set; }
7+
public CustomerAddress Address { get; set; }
8+
public CustomerPhone Phone { get; set; }
9+
}
10+
11+
public class CustomerPhone
12+
{
13+
public int Id { get; set; }
14+
public string PhoneNumber { get; set; }
15+
public Customer Customer { get; set; }
16+
}
17+
18+
public class CustomerAddress
19+
{
20+
public int Id { get; set; }
21+
public string Street { get; set; }
22+
public string City { get; set; }
23+
public string State { get; set; }
24+
public Customer Customer { get; set; }
25+
}
26+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
namespace DotNetToolkit.Repository.Test
2+
{
3+
using Data;
4+
using FetchStrategies;
5+
using Xunit;
6+
7+
public class FetchStrategyTests
8+
{
9+
[Fact]
10+
public void Include()
11+
{
12+
var strategy = new FetchStrategy<Customer>()
13+
.Include(x => x.Address)
14+
.Include(x => x.Phone)
15+
.Include(x => x.Phone.Customer);
16+
17+
Assert.Contains("Address", strategy.IncludePaths);
18+
Assert.Contains("Phone", strategy.IncludePaths);
19+
Assert.Contains("Phone.Customer", strategy.IncludePaths);
20+
}
21+
22+
[Fact]
23+
public void Include_Property_Names()
24+
{
25+
var strategy = new FetchStrategy<Customer>()
26+
.Include("Address")
27+
.Include("Phone")
28+
.Include("Phone.Customer");
29+
30+
Assert.Contains("Address", strategy.IncludePaths);
31+
Assert.Contains("Phone", strategy.IncludePaths);
32+
Assert.Contains("Phone.Customer", strategy.IncludePaths);
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)