-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
80 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using NUnit.Framework; | ||
using SchemaZen.Library.Models; | ||
|
||
namespace SchemaZen.Tests { | ||
|
||
[TestFixture] | ||
public class ConstraintTester { | ||
|
||
[TestFixture] | ||
public class ScriptCreate { | ||
|
||
private static Constraint SetUp() { | ||
return new Constraint("test", "INDEX", "a,b") { | ||
Table = new Table("dbo", "test") | ||
}; | ||
} | ||
|
||
[Test] | ||
public void clustered_index() { | ||
var c = SetUp(); | ||
c.Clustered = true; | ||
Assert.AreEqual( | ||
"CREATE CLUSTERED INDEX [test] ON [dbo].[test] ([a], [b])", | ||
c.ScriptCreate()); | ||
} | ||
|
||
[Test] | ||
public void nonclustered_index() { | ||
var c = SetUp(); | ||
c.Clustered = false; | ||
Assert.AreEqual( | ||
"CREATE NONCLUSTERED INDEX [test] ON [dbo].[test] ([a], [b])", | ||
c.ScriptCreate()); | ||
} | ||
|
||
[Test] | ||
public void columnstore_index() { | ||
var c = SetUp(); | ||
c.ColumnStore = true; | ||
Assert.AreEqual( | ||
"CREATE NONCLUSTERED COLUMNSTORE INDEX [test] ON [dbo].[test] ([a], [b])", | ||
c.ScriptCreate()); | ||
} | ||
|
||
[Test] | ||
public void primary_key() { | ||
var c = SetUp(); | ||
c.Type = "PRIMARY KEY"; | ||
Assert.AreEqual( | ||
"CONSTRAINT [test] PRIMARY KEY NONCLUSTERED ([a], [b])", | ||
c.ScriptCreate()); | ||
} | ||
|
||
[Test] | ||
public void foreign_key() { | ||
var c = SetUp(); | ||
c.Type = "FOREIGN KEY"; | ||
Assert.AreEqual( | ||
"CONSTRAINT [test] FOREIGN KEY NONCLUSTERED ([a], [b])", | ||
c.ScriptCreate()); | ||
} | ||
|
||
[Test] | ||
public void check_constraint() { | ||
var c = Constraint.CreateCheckedConstraint("test", true, "[a]>(1)"); | ||
Assert.AreEqual( | ||
"CONSTRAINT [test] CHECK NOT FOR REPLICATION [a]>(1)", | ||
c.ScriptCreate()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters