-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ksqlDB.RestApi.Client]: added Exploded table function support integr…
…ation test
- Loading branch information
1 parent
448fe8a
commit c28d758
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
Tests/ksqlDB.RestApi.Client.IntegrationTests/KSql/Linq/FunctionsTests.cs
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,64 @@ | ||
using FluentAssertions; | ||
using ksqlDb.RestApi.Client.IntegrationTests.KSql.RestApi; | ||
using ksqlDb.RestApi.Client.IntegrationTests.Models; | ||
using ksqlDB.RestApi.Client.KSql.Linq; | ||
using ksqlDB.RestApi.Client.KSql.Query.Functions; | ||
using NUnit.Framework; | ||
|
||
namespace ksqlDb.RestApi.Client.IntegrationTests.KSql.Linq | ||
{ | ||
public class FunctionsTests : Infrastructure.IntegrationTests | ||
{ | ||
private static TweetsProvider? tweetsProvider; | ||
|
||
private static readonly string TweetsTopicName = "tweetsFunctionTestTopic"; | ||
protected static string TweetsStreamName = "tweetsFunctionTest"; | ||
|
||
[OneTimeSetUp] | ||
public static async Task ClassInitialize() | ||
{ | ||
RestApiProvider = KSqlDbRestApiProvider.Create(); | ||
|
||
tweetsProvider = new TweetsProvider(RestApiProvider); | ||
|
||
await tweetsProvider.CreateTweetsStream(TweetsStreamName, TweetsTopicName); | ||
|
||
await tweetsProvider.InsertTweetAsync(TweetsProvider.Tweet1, TweetsStreamName); | ||
await tweetsProvider.InsertTweetAsync(TweetsProvider.Tweet2, TweetsStreamName); | ||
} | ||
|
||
[OneTimeTearDown] | ||
public static async Task ClassCleanup() | ||
{ | ||
await RestApiProvider.DropStreamAndTopic(TweetsStreamName); | ||
|
||
tweetsProvider = null; | ||
} | ||
|
||
[Test] | ||
public async Task Explode() | ||
{ | ||
await Explode(Context.CreateQueryStream<Tweet>(TweetsStreamName)); | ||
} | ||
|
||
private async Task Explode(IQbservable<Tweet> querySource) | ||
{ | ||
//Arrange | ||
int expectedItemsCount = 3; | ||
|
||
string[] array1 = ["a", "b"]; | ||
int[] array2 = [1, 2, 3]; | ||
|
||
var source = querySource | ||
.Select(l => new { Result = array1.Explode(), Result1 = array2.Explode() }) | ||
.ToAsyncEnumerable(); | ||
|
||
//Act | ||
var actualValues = await CollectActualValues(source, expectedItemsCount); | ||
|
||
//Assert | ||
var results = actualValues.FirstOrDefault(c => c.Result == array1[0] && c.Result1 == array2[0]); | ||
results.Should().NotBeNull(); | ||
} | ||
} | ||
} |