forked from ThatRendle/Simple.Data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNaturalJoinTest.cs
More file actions
53 lines (46 loc) · 2.29 KB
/
NaturalJoinTest.cs
File metadata and controls
53 lines (46 loc) · 2.29 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
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using NUnit.Framework;
using Simple.Data.Ado;
using Simple.Data.Mocking.Ado;
namespace Simple.Data.IntegrationTest
{
[TestFixture]
public class NaturalJoinTest : DatabaseIntegrationContext
{
protected override void SetSchema(MockSchemaProvider schemaProvider)
{
schemaProvider.SetTables(new[] { "dbo", "Customer", "BASE TABLE" },
new[] { "dbo", "Orders", "BASE TABLE" });
schemaProvider.SetColumns(new[] { "dbo", "Customer", "CustomerId" },
new[] { "dbo", "Orders", "OrderId" },
new[] { "dbo", "Orders", "CustomerId" },
new[] { "dbo", "Orders", "OrderDate" });
schemaProvider.SetPrimaryKeys(new object[] { "dbo", "Customer", "CustomerId", 0 });
schemaProvider.SetForeignKeys(new object[] { "FK_Orders_Customer", "dbo", "Orders", "CustomerId", "dbo", "Customer", "CustomerId", 0 });
}
[Test]
public void NaturalJoinCreatesCorrectCommand()
{
var orderDate = new DateTime(2010, 1, 1);
const string expectedSql =
"select [dbo].[Customer].[CustomerId] from [dbo].[Customer] join [dbo].[Orders] on ([dbo].[Customer].[CustomerId] = [dbo].[Orders].[CustomerId]) where [dbo].[Orders].[OrderDate] = @p1";
_db.Customer.Find(_db.Customer.Orders.OrderDate == orderDate);
GeneratedSqlIs(expectedSql);
Parameter(0).Is(orderDate);
}
[Test]
public void NaturalJoinViaFindAllCreatesCorrectCommand()
{
var orderDate = new DateTime(2010, 1, 1);
const string expectedSql =
"select [dbo].[Customer].[CustomerId] from [dbo].[Customer] join [dbo].[Orders] on ([dbo].[Customer].[CustomerId] = [dbo].[Orders].[CustomerId]) where [dbo].[Orders].[OrderDate] = @p1";
_db.Customer.FindAll(_db.Customer.Orders.OrderDate == orderDate).ToList<dynamic>();
GeneratedSqlIs(expectedSql);
Parameter(0).Is(orderDate);
}
}
}