forked from sethreno/schemazen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FunctionTester.cs
46 lines (42 loc) · 1.05 KB
/
FunctionTester.cs
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
using System;
using System.Linq;
using NUnit.Framework;
using SchemaZen.Library.Models;
namespace SchemaZen.Tests {
[TestFixture]
public class FunctionTester {
private const string _exampleFunc = @"
CREATE FUNCTION [dbo].udf_GetDate()
RETURNS DATETIME AS
BEGIN
RETURN GETDATE()
END
";
[Test]
public void TestScript() {
var f = new Routine("dbo", "udf_GetDate", null) {
RoutineType = Routine.RoutineKind.Function,
Text = _exampleFunc
};
Console.WriteLine(f.ScriptCreate());
TestHelper.ExecBatchSql(f.ScriptCreate() + "\nGO", "");
TestHelper.ExecSql("drop function [dbo].[udf_GetDate]", "");
}
[Test]
public void TestScriptNoWarnings() {
var f = new Routine("dbo", "udf_GetDate", null) {
Text = _exampleFunc,
RoutineType = Routine.RoutineKind.Function
};
Assert.IsFalse(f.Warnings().Any());
}
[Test]
public void TestScriptWarnings() {
var f = new Routine("dbo", "udf_GetDate2", null) {
Text = _exampleFunc,
RoutineType = Routine.RoutineKind.Function
};
Assert.IsTrue(f.Warnings().Any());
}
}
}