forked from csharp-opensource/CSharp.OpenSource.LinqToKql
-
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.
- Loading branch information
Showing
2 changed files
with
62 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using CSharp.OpenSource.LinqToKql.Extensions; | ||
using CSharp.OpenSource.LinqToKql.Provider; | ||
using CSharp.OpenSource.LinqToKql.Test.Model; | ||
|
||
namespace CSharp.OpenSource.LinqToKql.Test.Provider; | ||
|
||
public class ProviderTests | ||
{ | ||
[Fact] | ||
public void CloneTest() | ||
{ | ||
var q = new LinqToKqlProvider<SampleObject>("test", expression: null, providerExecutor: null); | ||
var q1 = q.Where(x => x.Year == 8 && x.Description == "desc") | ||
.AsKQL() | ||
.Clone<Test1>(); | ||
var q2 = q1.Where(x => x.Test == "1") | ||
.AsKQL(); | ||
var kql = q2.TranslateToKQL(); | ||
var expected = string.Join(q1.Translator.PipeWithIndentation, ["test", "where Year == 8 and Description == 'desc'", "where Test == '1'"]); | ||
Assert.Equal(expected, kql); | ||
} | ||
|
||
[Fact] | ||
public void FromKQLTest() | ||
{ | ||
var q = new LinqToKqlProvider<SampleObject>("test", expression: null, providerExecutor: null); | ||
var q1 = q.Where(x => x.Year == 8 && x.Description == "desc") | ||
.FromKQL("| where 1 == 1", appendKQL: true) | ||
.FromKQL("where 2 == 2", appendKQL: true); | ||
var q2 = q1.FromKQL("newTable", appendKQL: false); | ||
|
||
var expected1 = string.Join(q1.Translator.PipeWithIndentation, ["test", "where Year == 8 and Description == 'desc'", "where 1 == 1", "where 2 == 2"]); | ||
var expected2 = "newTable"; | ||
var actual1 = q1.TranslateToKQL(); | ||
var actual2 = q2.TranslateToKQL(); | ||
Assert.Equal(expected1, actual1); | ||
Assert.Equal(expected2, actual2); | ||
} | ||
} | ||
|
||
public interface Test1 | ||
{ | ||
int Year { get; } | ||
string Test { get; } | ||
} |
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