forked from ThatRendle/Simple.Data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSchemaQualifiedTests.cs
More file actions
67 lines (58 loc) · 2.07 KB
/
SchemaQualifiedTests.cs
File metadata and controls
67 lines (58 loc) · 2.07 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
56
57
58
59
60
61
62
63
64
65
66
67
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Simple.Data.SqlTest
{
using NUnit.Framework;
[TestFixture]
class SchemaQualifiedTests
{
[TestFixtureSetUp]
public void Setup()
{
DatabaseHelper.Reset();
}
[Test]
public void TestFindAllByIdWithSchemaQualification()
{
var db = DatabaseHelper.Open();
var dboCount = db.dbo.SchemaTable.FindAllById(1).ToList().Count;
var testCount = db.test.SchemaTable.FindAllById(1).ToList().Count;
Assert.AreEqual(1, dboCount);
Assert.AreEqual(0, testCount);
}
[Test]
public void TestFindWithSchemaQualification()
{
var db = DatabaseHelper.Open();
var dboActual = db.dbo.SchemaTable.FindById(1);
var testActual = db.test.SchemaTable.FindById(1);
Assert.IsNotNull(dboActual);
Assert.AreEqual("Pass", dboActual.Description);
Assert.IsNull(testActual);
}
[Test]
public void QueryWithSchemaQualifiedTableName()
{
var db = DatabaseHelper.Open();
var result = db.test.SchemaTable.QueryById(2)
.Select(db.test.SchemaTable.Id,
db.test.SchemaTable.Description)
.Single();
Assert.AreEqual(2, result.Id);
Assert.AreEqual("Pass", result.Description);
}
[Test]
public void QueryWithSchemaQualifiedTableNameAndAliases()
{
var db = DatabaseHelper.Open();
var result = db.test.SchemaTable.QueryById(2)
.Select(db.test.SchemaTable.Id.As("This"),
db.test.SchemaTable.Description.As("That"))
.Single();
Assert.AreEqual(2, result.This);
Assert.AreEqual("Pass", result.That);
}
}
}