From dac42a88391589b4d1ce231785f58912f8a66fc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D1=8F=20=D0=91=D0=B8=D0=B7=D1=8E=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0?= Date: Tue, 28 Jan 2025 12:42:01 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=B0?= =?UTF-8?q?=20CreateHyperTable=5FFor=5FParameterData=5FReturn=5FSuccess?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UnitTestCheckHyperTables.cs | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/DD.Persistence.Database.Postgres.Test/UnitTestCheckHyperTables.cs b/DD.Persistence.Database.Postgres.Test/UnitTestCheckHyperTables.cs index 9c96454..f0b8749 100644 --- a/DD.Persistence.Database.Postgres.Test/UnitTestCheckHyperTables.cs +++ b/DD.Persistence.Database.Postgres.Test/UnitTestCheckHyperTables.cs @@ -1,5 +1,6 @@ using DD.Persistence.Database.Entity; using Mapster; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Npgsql; @@ -19,6 +20,8 @@ public class UnitTestCheckHyperTables : IClassFixture [Fact] public void CreateHyperTable_For_ParameterData_Return_Success() { + var chunksCount = 0; + var entity = new ParameterData() { DiscriminatorId = Guid.NewGuid(), @@ -45,24 +48,11 @@ public class UnitTestCheckHyperTables : IClassFixture context.ParameterData.Add(entity4); context.SaveChanges(); - } - var chunksCount = 0; - using (var connection = new NpgsqlConnection(_connectionString)) - { - connection.Open(); string sql = "select count(*) from (select show_chunks('parameter_data'));"; + var queryRow = context.Database.SqlQueryRaw(sql); - using (var command = new NpgsqlCommand(sql, connection)) - { - using (var reader = command.ExecuteReader()) - { - while (reader.Read()) - { - chunksCount += reader.GetInt32(0); - } - } - } + chunksCount = queryRow.AsEnumerable().FirstOrDefault(); } Assert.Equal(2, chunksCount);