-
Notifications
You must be signed in to change notification settings - Fork 208
/
FindExpandTest.cs
71 lines (59 loc) · 2.27 KB
/
FindExpandTest.cs
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
62
63
64
65
66
67
68
69
70
71
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Simple.Data.OData.IntegrationTests
{
using Xunit;
public class FindExpandTest : TestBase
{
[Fact]
public void FindCategoryByNameExpandProducts()
{
// expected request: Categories?expand=Products&$filter=CategoryName+eq+'Beverages'
var category = _db.Category.WithProducts().FindByCategoryName("Beverages");
Assert.Equal("Beverages", category.CategoryName);
Assert.True(category.Products.Count > 0);
}
[Fact]
public void FindAllCategoriesWithProducts()
{
// expected request: Categories?expand=Products
var categories = _db.Category.All().WithProducts().ToList();
Assert.True(categories.Count > 0);
Assert.True(categories[0].Products.Count > 0);
}
[Fact]
public void FindAllProductsWithCategory()
{
// expected request: Products?expand=Category
var products = _db.Products.All().WithCategory().ToList();
Assert.True(products.Count > 0);
Assert.Equal("Beverages", products[0].Category.CategoryName);
}
[Fact]
public void GetCustomerExpandOrders()
{
// expected request: Customers('ALFKI')?$expand=Orders
var customer = _db.Customer.WithOrders().Get("ALFKI");
Assert.Equal("ALFKI", customer.CustomerID);
Assert.True(customer.Orders.Count > 0);
}
[Fact]
public void FindAllEmployeesExpandSubordinates()
{
// expected request: Employees?$expand=Subordinates
var employees = _db.Employees.All().WithSubordinates().ToList();
Assert.True(employees.Count > 0);
Assert.True(employees[0].Subordinates.Count > 0);
}
[Fact]
public void FindEmployeeWithSuperior()
{
// expected request: Employees?$expand=Superior&$filter=FirstName+eq+%27Nancy%27 and LastName+eq+%27Davolio%27
var employee = _db.Employees.WithSuperior().FindByFirstNameAndLastName("Nancy", "Davolio");
Assert.NotNull(employee);
Assert.NotNull(employee.Superior);
}
}
}