public async Task ReceiveArrayWithComplexElements() { //Arrange var httpResponseMessage = await restApiClient.ExecuteStatementAsync(new KSqlDbStatement(@" Drop type EventCategory; Drop table Events; ")); //Act httpResponseMessage = await restApiClient.CreateTypeAsync <EventCategory>(); httpResponseMessage = await restApiClient.CreateTableAsync <Event>(new EntityCreationMetadata() { KafkaTopic = "Events", Partitions = 1 }); var eventCategory = new EventCategory() { Name = "xyz" }; var testEvent = new Event { Id = 1, Places = new[] { "Place1", "Place2" }, Categories = new[] { eventCategory, new EventCategory { Name = "puk" } } }; var semaphoreSlim = new SemaphoreSlim(0, 1); var receivedValues = new List <Event>(); var subscription = Context.CreateQueryStream <Event>().Take(1) .Subscribe(value => { receivedValues.Add(value); }, error => { semaphoreSlim.Release(); }, () => { semaphoreSlim.Release(); }); httpResponseMessage = await restApiClient.InsertIntoAsync(testEvent); string responseContent = await httpResponseMessage.Content.ReadAsStringAsync(); //Assert await semaphoreSlim.WaitAsync(TimeSpan.FromSeconds(5)); receivedValues.Count.Should().Be(1); receivedValues[0].Places.Length.Should().Be(2); receivedValues[0].Categories.ToArray()[0].Name.Should().Be("xyz"); receivedValues[0].Categories.ToArray()[1].Name.Should().Be("puk"); using (subscription) { } }
public async Task ExecuteStatementAsync() { //Arrange KSqlDbStatement ksqlDbStatement = new(CreateTableStatement()); //Act var httpResponseMessage = await restApiClient.ExecuteStatementAsync(ksqlDbStatement); //Assert httpResponseMessage.StatusCode.Should().Be(HttpStatusCode.OK); string responseContent = await httpResponseMessage.Content.ReadAsStringAsync(); var responseObject = JsonSerializer.Deserialize <StatementResponse[]>(responseContent); responseObject?[0].CommandStatus.Status.Should().Be("SUCCESS"); responseObject?[0].CommandStatus.Message.Should().Be("Table created"); }
async Task <HttpResponseMessage> ExecuteAsync(string statement) { KSqlDbStatement ksqlDbStatement = new(statement); var httpResponseMessage = await restApiClient.ExecuteStatementAsync(ksqlDbStatement) .ConfigureAwait(false); string responseContent = await httpResponseMessage.Content.ReadAsStringAsync(); return(httpResponseMessage); }