diff --git a/test/Atc.Kusto.Tests/Atc.Kusto.Tests.csproj b/test/Atc.Kusto.Tests/Atc.Kusto.Tests.csproj index 29a64bf..a71b387 100644 --- a/test/Atc.Kusto.Tests/Atc.Kusto.Tests.csproj +++ b/test/Atc.Kusto.Tests/Atc.Kusto.Tests.csproj @@ -6,6 +6,14 @@ true + + + + + + + + all diff --git a/test/Atc.Kusto.Tests/KustoScriptMissingResourceTests.cs b/test/Atc.Kusto.Tests/KustoScriptMissingResourceTests.cs new file mode 100644 index 0000000..2e9b929 --- /dev/null +++ b/test/Atc.Kusto.Tests/KustoScriptMissingResourceTests.cs @@ -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(script.GetQueryText); + } +} \ No newline at end of file diff --git a/test/Atc.Kusto.Tests/KustoScriptTests.cs b/test/Atc.Kusto.Tests/KustoScriptTests.cs new file mode 100644 index 0000000..729731f --- /dev/null +++ b/test/Atc.Kusto.Tests/KustoScriptTests.cs @@ -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()); + } +} \ No newline at end of file diff --git a/test/Atc.Kusto.Tests/KustoScriptTests.kusto b/test/Atc.Kusto.Tests/KustoScriptTests.kusto new file mode 100644 index 0000000..8323292 --- /dev/null +++ b/test/Atc.Kusto.Tests/KustoScriptTests.kusto @@ -0,0 +1,2 @@ +MySampleTableForUnitTest +| project X, Y, Z \ No newline at end of file