-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add unit-tests for KustoScript
- Loading branch information
Per Kops
committed
Aug 23, 2024
1 parent
2897710
commit 9b69954
Showing
4 changed files
with
61 additions
and
0 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,14 @@ | ||
namespace Atc.Kusto.Tests; | ||
|
||
public sealed record KustoScriptMissingResourceTests : KustoScript | ||
{ | ||
[Fact] | ||
public void GetQueryText_ShouldThrowFileNotFoundException_WhenResourceDoesNotExist() | ||
{ | ||
// Arrange | ||
var script = new KustoScriptMissingResourceTests(); | ||
|
||
// Act & Assert | ||
Assert.Throws<FileNotFoundException>(script.GetQueryText); | ||
} | ||
} |
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,37 @@ | ||
namespace Atc.Kusto.Tests; | ||
|
||
public sealed record KustoScriptTests : KustoScript | ||
{ | ||
public string SampleProperty { get; set; } = string.Empty; | ||
|
||
[Fact] | ||
public void GetQueryText_ShouldReturnQueryText_WhenResourceExists() | ||
{ | ||
// Arrange | ||
var resourceName = $"{GetType().FullName}.kusto"; | ||
using var stream = GetType().Assembly.GetManifestResourceStream(resourceName)!; | ||
using var reader = new StreamReader(stream); | ||
var expectedResult = reader.ReadToEnd(); | ||
|
||
// Act | ||
var queryText = GetQueryText(); | ||
|
||
// Assert | ||
Assert.Equal(expectedResult, queryText); | ||
} | ||
|
||
[Fact] | ||
public void GetParameters_ShouldReturnCorrectParameters_WhenPropertiesArePresent() | ||
{ | ||
// Arrange | ||
SampleProperty = "SampleValue"; | ||
|
||
// Act | ||
var parameters = GetParameters(); | ||
|
||
// Assert | ||
Assert.Single(parameters); | ||
Assert.Equal("sampleProperty", parameters.Keys.First()); | ||
Assert.Equal("SampleValue", parameters.Values.First()); | ||
} | ||
} |
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,2 @@ | ||
MySampleTableForUnitTest | ||
| project X, Y, Z |