-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathFunctionModelTests.cs
More file actions
74 lines (66 loc) · 2.51 KB
/
FunctionModelTests.cs
File metadata and controls
74 lines (66 loc) · 2.51 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
using FluentAssertions;
using KustoSchemaTools.Model;
namespace KustoSchemaTools.Tests.Model
{
public class FunctionModelTests
{
[Fact]
public void Function_Should_Initialize_With_Default_Values()
{
// Act
var function = new Function();
// Assert
function.Body.Should().BeNull();
function.Folder.Should().Be("");
function.DocString.Should().Be("");
function.Parameters.Should().Be("");
function.SkipValidation.Should().BeFalse();
function.View.Should().BeFalse();
function.Preformatted.Should().BeFalse();
}
[Fact]
public void Function_Should_Allow_Property_Assignment()
{
// Arrange
var function = new Function();
// Act
function.Body = "T | count";
function.Folder = "Analytics";
function.DocString = "Counts rows in table T";
function.Parameters = "(T: (*)";
function.SkipValidation = true;
function.View = true;
// Assert
function.Body.Should().Be("T | count");
function.Folder.Should().Be("Analytics");
function.DocString.Should().Be("Counts rows in table T");
function.Parameters.Should().Be("(T: (*)");
function.SkipValidation.Should().BeTrue();
function.View.Should().BeTrue();
}
[Fact]
public void Function_Should_Generate_Creation_Script()
{
// Arrange
var function = new Function
{
Body = "StormEvents | count\n",
Folder = "Weather",
DocString = "Count storm events",
Parameters = "tableName: string" // Provide valid parameters
};
// Act
var scripts = function.CreateScripts("CountStormEvents", true);
// Assert
scripts.Should().NotBeEmpty();
scripts.Should().HaveCount(1);
var script = scripts.First();
script.Kind.Should().Be("CreateOrAlterFunction");
script.Script.Text.Should().Contain(".create-or-alter function");
script.Script.Text.Should().Contain("CountStormEvents");
script.Script.Text.Should().Contain("StormEvents | count");
script.Script.Text.Should().Contain("Folder=```Weather```");
script.Script.Text.Should().Contain("DocString=```Count storm events```");
}
}
}