-
-
Notifications
You must be signed in to change notification settings - Fork 121
Expand file tree
/
Copy pathForeignKeyStatementTest.cs
More file actions
116 lines (102 loc) · 4.9 KB
/
Copy pathForeignKeyStatementTest.cs
File metadata and controls
116 lines (102 loc) · 4.9 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SQLite.CodeFirst.Statement;
namespace SQLite.CodeFirst.Test.UnitTests.Statement
{
[TestClass]
public class ForeignKeyStatementTest : StatementTestBase
{
[TestMethod]
public void CreateStatementOneForeignKeyTest()
{
var foreignKeyStatement = new ForeignKeyStatement
{
CascadeDelete = false,
ForeignKey = new List<string> { "dummyForeignKey1" },
ForeignPrimaryKey = new List<string> { "dummForeignPrimaryKey1" },
ForeignTable = "dummyForeignTable"
};
string output = foreignKeyStatement.CreateStatement();
Assert.AreEqual("FOREIGN KEY ([dummyForeignKey1]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1])", output);
}
[TestMethod]
public void CreateStatementOneForeignKeyCascadeDeleteTest()
{
var foreignKeyStatement = new ForeignKeyStatement
{
CascadeDelete = true,
ForeignKey = new List<string> { "dummyForeignKey1" },
ForeignPrimaryKey = new List<string> { "dummForeignPrimaryKey1" },
ForeignTable = "dummyForeignTable"
};
string output = foreignKeyStatement.CreateStatement();
Assert.AreEqual("FOREIGN KEY ([dummyForeignKey1]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1]) ON DELETE CASCADE", output);
}
[TestMethod]
public void CreateStatementOneForeignKeyCascadeUpdateTest()
{
var foreignKeyStatement = new ForeignKeyStatement
{
CascadeUpdate = true,
ForeignKey = new List<string> { "dummyForeignKey1" },
ForeignPrimaryKey = new List<string> { "dummForeignPrimaryKey1" },
ForeignTable = "dummyForeignTable"
};
string output = foreignKeyStatement.CreateStatement();
Assert.AreEqual("FOREIGN KEY ([dummyForeignKey1]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1]) ON UPDATE CASCADE", output);
}
[TestMethod]
public void CreateStatementOneForeignKeyCascadeDeleteAndUpdateTest()
{
var foreignKeyStatement = new ForeignKeyStatement
{
CascadeDelete = true,
CascadeUpdate = true,
ForeignKey = new List<string> { "dummyForeignKey1" },
ForeignPrimaryKey = new List<string> { "dummForeignPrimaryKey1" },
ForeignTable = "dummyForeignTable"
};
string output = foreignKeyStatement.CreateStatement();
Assert.AreEqual("FOREIGN KEY ([dummyForeignKey1]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1]) ON DELETE CASCADE ON UPDATE CASCADE", output);
}
[TestMethod]
public void CreateStatementTwoForeignKeyTest()
{
var foreignKeyStatement = new ForeignKeyStatement
{
CascadeDelete = false,
ForeignKey = new List<string> { "dummyForeignKey1", "dummyForeignKey2" },
ForeignPrimaryKey = new List<string> { "dummForeignPrimaryKey1" },
ForeignTable = "dummyForeignTable"
};
string output = foreignKeyStatement.CreateStatement();
Assert.AreEqual("FOREIGN KEY ([dummyForeignKey1], [dummyForeignKey2]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1])", output);
}
[TestMethod]
public void CreateStatementTwoForeignKeyTwoPrimaryKeyTest()
{
var foreignKeyStatement = new ForeignKeyStatement
{
CascadeDelete = false,
ForeignKey = new List<string> { "dummyForeignKey1", "dummyForeignKey2" },
ForeignPrimaryKey = new List<string> { "dummForeignPrimaryKey1", "dummForeignPrimaryKey2" },
ForeignTable = "dummyForeignTable"
};
string output = foreignKeyStatement.CreateStatement();
Assert.AreEqual("FOREIGN KEY ([dummyForeignKey1], [dummyForeignKey2]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1], [dummForeignPrimaryKey2])", output);
}
[TestMethod]
public void CreateStatementOneForeignKeyTwoPrimaryKeyTest()
{
var foreignKeyStatement = new ForeignKeyStatement
{
CascadeDelete = false,
ForeignKey = new List<string> { "dummyForeignKey1" },
ForeignPrimaryKey = new List<string> { "dummForeignPrimaryKey1", "dummForeignPrimaryKey2" },
ForeignTable = "dummyForeignTable"
};
string output = foreignKeyStatement.CreateStatement();
Assert.AreEqual("FOREIGN KEY ([dummyForeignKey1]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1], [dummForeignPrimaryKey2])", output);
}
}
}