forked from ThatRendle/Simple.Data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetTest.cs
More file actions
48 lines (44 loc) · 1.92 KB
/
GetTest.cs
File metadata and controls
48 lines (44 loc) · 1.92 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Simple.Data.Mocking.Ado;
namespace Simple.Data.IntegrationTest
{
[TestFixture]
public class GetTest : DatabaseIntegrationContext
{
protected override void SetSchema(MockSchemaProvider schemaProvider)
{
schemaProvider.SetTables(new[] { "dbo", "Users", "BASE TABLE" },
new[] { "dbo", "MyTable", "BASE TABLE" });
schemaProvider.SetColumns(new object[] { "dbo", "Users", "Id", true },
new[] { "dbo", "Users", "Name" },
new[] { "dbo", "Users", "Password" },
new[] { "dbo", "Users", "Age" },
new[] { "dbo", "MyTable", "Column1"},
new[] { "dbo", "MyTable", "Column2"});
schemaProvider.SetPrimaryKeys(
new object[] { "dbo", "Users", "Id", 0 },
new object[] { "dbo", "MyTable", "Column1", 0 },
new object[] { "dbo", "MyTable", "Column2", 1 });
}
private const string UsersColumns = "[dbo].[Users].[Id], [dbo].[Users].[Name], [dbo].[Users].[Password], [dbo].[Users].[Age]";
[Test]
public void TestGetWithSingleColumn()
{
_db.Users.Get(1);
GeneratedSqlIs("select " + UsersColumns + " from [dbo].[users] where [id] = @p1");
Parameter(0).Is(1);
}
[Test]
public void TestGetWithTwoColumns()
{
_db.MyTable.Get(1,2);
GeneratedSqlIs("select [dbo].[MyTable].[Column1], [dbo].[MyTable].[Column2] from [dbo].[MyTable] where [Column1] = @p1 and [Column2] = @p2");
Parameter(0).Is(1);
Parameter(1).Is(2);
}
}
}