From 424ef56750c9298ba59c05bbbe740a14691f87e1 Mon Sep 17 00:00:00 2001 From: xiaolei li <85657333+xleili@users.noreply.github.com> Date: Thu, 17 Mar 2022 16:27:12 +0800 Subject: [PATCH] =?UTF-8?q?[TD-13948]:csharp=20connector=20test=20cas?= =?UTF-8?q?e=20add=20database=20fixture=20and=20e=E2=80=A6=20(#10793)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [TD-13948]:csharp connector test case add database fixture and execute order * [TD-13948]:run CI --- .../C#/src/test/FunctionTest/FetchFields.cs | 21 +++++++-- .../C#/src/test/FunctionTest/FetchLength.cs | 5 ++- .../C#/src/test/FunctionTest/InsertCn.cs | 29 ++++++++----- .../src/test/FunctionTest/StmtNormalTable.cs | 43 ++++++++++++------- .../C#/src/test/FunctionTest/StmtStable.cs | 35 ++++++++++----- 5 files changed, 91 insertions(+), 42 deletions(-) diff --git a/src/connector/C#/src/test/FunctionTest/FetchFields.cs b/src/connector/C#/src/test/FunctionTest/FetchFields.cs index 67f24fe1a6..b0a5859d4d 100644 --- a/src/connector/C#/src/test/FunctionTest/FetchFields.cs +++ b/src/connector/C#/src/test/FunctionTest/FetchFields.cs @@ -4,19 +4,32 @@ using TDengineDriver; using System.Collections.Generic; using Xunit; using Test.UtilsTools.ResultSet; +using Test.Fixture; +using Test.Case.Attributes; + namespace Cases { - public class FetchFieldsCases + [TestCaseOrderer("XUnit.Case.Orderers.TestExeOrderer", "Cases.ExeOrder")] + [Collection("Database collection")] + public class FetchFieldCases { + + DatabaseFixture database; + + + public FetchFieldCases(DatabaseFixture fixture) + { + this.database = fixture; + } /// xiaolei /// FetchFieldsCases.TestFetchFieldsJsonTag /// test taos_fetch_fields(), check the meta data /// FetchFields.cs /// pass or failed - [Fact(DisplayName = "FetchFieldsCases.TestFetchFieldsJsonTag()")] - public void TestFetchFieldsJsonTag() + [Fact(DisplayName = "FetchFieldsCases.TestFetchFieldJsonTag()"),TestExeOrder(1),Trait("Category", "FetchFieldJsonTag")] + public void TestFetchFieldJsonTag() { - IntPtr conn = UtilsTools.TDConnection(); + IntPtr conn = database.conn; IntPtr _res = IntPtr.Zero; string tableName = "fetch_fields"; var expectResMeta = new List { diff --git a/src/connector/C#/src/test/FunctionTest/FetchLength.cs b/src/connector/C#/src/test/FunctionTest/FetchLength.cs index 130b53bfc8..928e1dfa92 100644 --- a/src/connector/C#/src/test/FunctionTest/FetchLength.cs +++ b/src/connector/C#/src/test/FunctionTest/FetchLength.cs @@ -4,8 +4,11 @@ using System.Collections.Generic; using Xunit; using TDengineDriver; using Test.UtilsTools.ResultSet; +using Test.Case.Attributes; namespace Cases { + [TestCaseOrderer("XUnit.Case.Orderers.TestExeOrderer", "Cases.ExeOrder")] + public class FetchLengthCase { /// xiaolei @@ -13,7 +16,7 @@ namespace Cases /// TD-12103 C# connector fetch_row with binary data retrieving error /// FetchLength.cs /// pass or failed - [Fact(DisplayName = "Skip FetchLengthCase.TestRetrieveBinary()")] + [Fact(DisplayName = "FetchLengthCase.TestRetrieveBinary()"),TestExeOrder(1)] public void TestRetrieveBinary() { IntPtr conn = UtilsTools.TDConnection(); diff --git a/src/connector/C#/src/test/FunctionTest/InsertCn.cs b/src/connector/C#/src/test/FunctionTest/InsertCn.cs index 3406f1cad4..51931340f5 100644 --- a/src/connector/C#/src/test/FunctionTest/InsertCn.cs +++ b/src/connector/C#/src/test/FunctionTest/InsertCn.cs @@ -5,19 +5,28 @@ using Test.UtilsTools.DataSource; using Xunit; using System.Collections.Generic; using Test.UtilsTools.ResultSet; +using Test.Case.Attributes; +using Test.Fixture; namespace Cases { + [TestCaseOrderer("XUnit.Case.Orderers.TestExeOrderer", "Cases.ExeOrder")] + [Collection("Database collection")] public class InsertCNCases { + DatabaseFixture database; + public InsertCNCases(DatabaseFixture fixture) + { + this.database = fixture; + } /// xiaolei /// InsertCNCases.TestNTable /// Test insert Chinese characters into normal table's nchar column /// InsertCn.cs /// pass or failed - [Fact(DisplayName = "InsertCNCases.TestNTable()")] + [Fact(DisplayName = "InsertCNCases.TestNTable"), TestExeOrder(1)] public void TestNTable() { - IntPtr conn = UtilsTools.TDConnection(); + IntPtr conn = database.conn; IntPtr _res = IntPtr.Zero; string tableName = "cn_insert_nchar_ntable"; // var expectResData = new List { "1637064040000", "true", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "XI", "XII", "{\"k1\": \"v1\"}" }; @@ -68,10 +77,10 @@ namespace Cases /// test insert Chinese character into stable's nchar column,both tag and column /// InsertCn.cs /// pass or failed - [Fact(DisplayName = "InsertCNCases.TestSTable()")] + [Fact(DisplayName = "InsertCNCases.TestSTable()"), TestExeOrder(2)] public void TestSTable() { - IntPtr conn = UtilsTools.TDConnection(); + IntPtr conn = database.conn; IntPtr _res = IntPtr.Zero; string tableName = "cn_insert_nchar_stable"; var colData = new List{1637064040000,1,"涛思数据", @@ -122,10 +131,10 @@ namespace Cases /// test insert Chinese character into normal table's multiple nchar columns /// InsertCn.cs /// pass or failed - [Fact(DisplayName = "InsertCNCases.TestInsertMultiNTable()")] + [Fact(DisplayName = "InsertCNCases.TestInsertMultiNTable()"), TestExeOrder(3)] public void TestInsertMultiNTable() { - IntPtr conn = UtilsTools.TDConnection(); + IntPtr conn = database.conn; IntPtr _res = IntPtr.Zero; string tableName = "cn_multi_insert_nchar_ntable"; var colData = new List{1637064040000,1,"涛思数据","保利广场","Beijing","China", @@ -140,7 +149,7 @@ namespace Cases }; String dropTb = "drop table if exists " + tableName; - String createTb = $"create table if not exists {tableName} (ts timestamp,v4 int,blob nchar(200),location nchar(200),city binary(100),country binary(200));"; + String createTb = $"create table if not exists {tableName} (ts timestamp,v4 int,blob nchar(200),location nchar(200),city binary(100),coutry binary(200));"; String insertSql = UtilsTools.ConstructInsertSql(tableName, "", colData, null, 9); String selectSql = "select * from " + tableName; String dropSql = "drop table " + tableName; @@ -174,10 +183,10 @@ namespace Cases /// test insert Chinese character into stable's multiple nchar columns /// InsertCn.cs /// pass or failed - [Fact(DisplayName = "InsertCNCases.TestInsertMultiSTable()")] + [Fact(DisplayName = "InsertCNCases.TestInsertMultiSTable()"), TestExeOrder(4)] public void TestInsertMultiSTable() { - IntPtr conn = UtilsTools.TDConnection(); + IntPtr conn = database.conn; IntPtr _res = IntPtr.Zero; string tableName = "cn_multi_insert_nchar_stable"; var colData = new List{1637064040000,1,"涛思数据","保利广场","Beijing","China", @@ -233,4 +242,4 @@ namespace Cases } } } -} \ No newline at end of file +} diff --git a/src/connector/C#/src/test/FunctionTest/StmtNormalTable.cs b/src/connector/C#/src/test/FunctionTest/StmtNormalTable.cs index 418b6f9400..72983dd02d 100644 --- a/src/connector/C#/src/test/FunctionTest/StmtNormalTable.cs +++ b/src/connector/C#/src/test/FunctionTest/StmtNormalTable.cs @@ -5,16 +5,27 @@ using Test.UtilsTools.DataSource; using Xunit; using System.Collections.Generic; using Test.UtilsTools.ResultSet; +using Test.Fixture; +using Test.Case.Attributes; + namespace Cases { + [TestCaseOrderer("XUnit.Case.Orderers.TestExeOrderer", "Cases.ExeOrder")] + [Collection("Database collection")] public class NormalTableStmtCases { + DatabaseFixture database; + + public NormalTableStmtCases(DatabaseFixture fixture) + { + this.database = fixture; + } /// xiaolei /// NormalTableStmtCases.TestBindSingleLineCN /// Test stmt insert single line of chinese character into normal table by column after column /// StmtNormalTable.cs /// pass or failed - [Fact(DisplayName = "NormalTableStmtCases.TestBindSingleLineCN()")] + [Fact(DisplayName = "NormalTableStmtCases.TestBindSingleLineCN()"),TestExeOrder(2),Trait("Category", "bindParamCN")] public void TestBindSingleLineCN() { string tableName = "ntb_stmt_cases_test_bind_single_line_cn"; @@ -42,7 +53,7 @@ namespace Cases List expectResData = DataSource.GetNTableCNRowData(); List expectResMeta = DataSource.GetMetaFromDDL(createTb); - IntPtr conn = UtilsTools.TDConnection(); + IntPtr conn = database.conn; UtilsTools.ExecuteUpdate(conn, dropSql); UtilsTools.ExecuteUpdate(conn, createTb); @@ -80,7 +91,7 @@ namespace Cases /// Test stmt insert single line of chinese character into normal table by column after column /// StmtNormalTable.cs /// pass or failed - [Fact(DisplayName = "NormalTableStmtCases.TestBindColumnCN()")] + [Fact(DisplayName = "NormalTableStmtCases.TestBindColumnCN()"),TestExeOrder(4),Trait("Category", "bindSingleColumnCN")] public void TestBindColumnCN() { string tableName = "ntb_stmt_cases_test_bind_column_cn"; @@ -107,7 +118,7 @@ namespace Cases TAOS_MULTI_BIND[] mBind = DataSource.GetMultiBindCNArr(); List expectResMeta = DataSource.GetMetaFromDDL(createTb); - IntPtr conn = UtilsTools.TDConnection(); + IntPtr conn = database.conn; UtilsTools.ExecuteUpdate(conn, dropSql); UtilsTools.ExecuteUpdate(conn, createTb); @@ -162,7 +173,7 @@ namespace Cases /// Test stmt insert single line of chinese character into normal table by column after column /// StmtNormalTable.cs /// pass or failed - [Fact(DisplayName = "NormalTableStmtCases.TestBindMultiLineCN()")] + [Fact(DisplayName = "NormalTableStmtCases.TestBindMultiLineCN()"),TestExeOrder(6),Trait("Category", "bindParamBatchCN")] public void TestBindMultiLineCN() { string tableName = "ntb_stmt_cases_test_bind_multi_lines_cn"; @@ -189,7 +200,7 @@ namespace Cases List expectResData = DataSource.GetMultiBindCNRowData(); List expectResMeta = DataSource.GetMetaFromDDL(createTb); - IntPtr conn = UtilsTools.TDConnection(); ; + IntPtr conn = database.conn; ; UtilsTools.ExecuteUpdate(conn, dropSql); UtilsTools.ExecuteUpdate(conn, createTb); @@ -231,7 +242,7 @@ namespace Cases /// Test stmt insert single line data into normal table /// StmtNormalTable.cs /// pass or failed - [Fact(DisplayName = "NormalTableStmtCases.TestBindSingleLine")] + [Fact(DisplayName = "NormalTableStmtCases.TestBindSingleLine"),TestExeOrder(3),Trait("Category", "BindSingleColumn")] public void TestBindSingleLine() { string tableName = "ntb_stmt_cases_test_bind_single_line"; @@ -259,7 +270,7 @@ namespace Cases List expectResData = DataSource.GetNTableRowData(); List expectResMeta = DataSource.GetMetaFromDDL(createTb); - IntPtr conn = UtilsTools.TDConnection(); + IntPtr conn = database.conn; UtilsTools.ExecuteQuery(conn, dropSql); UtilsTools.ExecuteQuery(conn, createTb); @@ -296,14 +307,14 @@ namespace Cases } /// xiaolei - /// NTableMultipleLine.TestBindMultiLine + /// NormalTableStmtCases.TestBindMultiLine /// Test stmt insert multiple rows of data into normal table /// StmtNormalTable.cs /// pass or failed - [Fact(DisplayName = "NormalTableStmtCases.TestBindMultiLine()")] + [Fact(DisplayName = "NormalTableStmtCases.TestBindMultiLine()"),TestExeOrder(5),Trait("Category", "bindParamBatch")] public void TestBindMultiLine() { - string tableName = "normal_table_stmt_cases_test_bind_multi_lines"; + string tableName = "ntb_stmt_case_test_bind_multi_lines"; String createTb = $"create table if not exists {tableName} " + " (" + "ts timestamp," + @@ -327,7 +338,7 @@ namespace Cases TAOS_MULTI_BIND[] mBind = DataSource.GetMultiBindArr(); List expectResMeta = DataSource.GetMetaFromDDL(createTb); - IntPtr conn = UtilsTools.TDConnection(); + IntPtr conn = database.conn; UtilsTools.ExecuteUpdate(conn, dropSql); UtilsTools.ExecuteUpdate(conn, createTb); @@ -365,14 +376,14 @@ namespace Cases } /// xiaolei - /// NormalTableStmtCases.TestBindColumnCn + /// NormalTableStmtCases.TestBindColumn /// Test stmt insert multiple rows of data into normal table by column after column /// StmtNormalTable.cs /// pass or failed - [Fact(DisplayName = "NormalTableStmtCases.TestBindColumn()")] + [Fact(DisplayName = "NormalTableStmtCases.TestBindColumn()"),TestExeOrder(1),Trait("Category", "bindParam")] public void TestBindColumn() { - string tableName = "ntb_stmt_cases_test_bind_column_cn"; + string tableName = "ntb_stmt_cases_test_bind_column"; DataSource data = new DataSource(); String createTb = $"create table if not exists {tableName} " + " (" + @@ -398,7 +409,7 @@ namespace Cases List expectResMeta = DataSource.GetMetaFromDDL(createTb); - IntPtr conn = UtilsTools.TDConnection(); + IntPtr conn = database.conn; UtilsTools.ExecuteUpdate(conn, dropSql); UtilsTools.ExecuteUpdate(conn, createTb); diff --git a/src/connector/C#/src/test/FunctionTest/StmtStable.cs b/src/connector/C#/src/test/FunctionTest/StmtStable.cs index d2cf931e94..44ecb298ff 100644 --- a/src/connector/C#/src/test/FunctionTest/StmtStable.cs +++ b/src/connector/C#/src/test/FunctionTest/StmtStable.cs @@ -5,17 +5,30 @@ using Test.UtilsTools.DataSource; using System.Collections.Generic; using Test.UtilsTools.ResultSet; using Xunit; +using Test.Fixture; +using Test.Case.Attributes; namespace Cases { + [TestCaseOrderer("XUnit.Case.Orderers.TestExeOrderer", "Cases.ExeOrder")] + [Collection("Database collection")] + public class StableStmtCases { + + DatabaseFixture database; + + + public StableStmtCases(DatabaseFixture fixture) + { + this.database = fixture; + } /// xiaolei /// StableStmtCases.TestBindSingleLineCN /// Test stmt insert single line of chinese character into stable by column after column /// StmtSTable.cs /// pass or failed - [Fact(DisplayName = "StableStmtCases.TestBindSingleLineCN()")] + [Fact(DisplayName = "StableStmtCases.TestBindSingleLineCN()"),TestExeOrder(2),Trait("Category", "BindParamCN")] public void TestBindSingleLineCN() { string tableName = "stb_stmt_cases_test_bind_single_line_cn"; @@ -57,7 +70,7 @@ namespace Cases TAOS_BIND[] tags = DataSource.GetCNTags(); TAOS_BIND[] binds = DataSource.GetNTableCNRow(); - IntPtr conn = UtilsTools.TDConnection(); + IntPtr conn = database.conn; UtilsTools.ExecuteUpdate(conn, dropSql); UtilsTools.ExecuteUpdate(conn, createSql); @@ -99,7 +112,7 @@ namespace Cases /// Test stmt insert single line of chinese character into stable by column after column /// StmtSTable.cs /// pass or failed - [Fact(DisplayName = "StableStmtCases.TestBindColumnCN()")] + [Fact(DisplayName = "StableStmtCases.TestBindColumnCN()"),TestExeOrder(4),Trait("Category", "BindParamColumnCN")] public void TestBindColumnCN() { string tableName = "stb_stmt_cases_test_bindcolumn_cn"; @@ -141,7 +154,7 @@ namespace Cases List expectResMeta = DataSource.GetMetaFromDDL(createSql); List expectResData = DataSource.GetMultiBindStableCNRowData(); - IntPtr conn = UtilsTools.TDConnection(); + IntPtr conn = database.conn; UtilsTools.ExecuteUpdate(conn, dropSql); UtilsTools.ExecuteUpdate(conn, createSql); @@ -199,7 +212,7 @@ namespace Cases /// Test stmt insert single line of chinese character into stable by column after column /// StmtSTable.cs /// pass or failed - [Fact(DisplayName = "StableStmtCases.TestBindMultiLineCN()")] + [Fact(DisplayName = "StableStmtCases.TestBindMultiLineCN()"),TestExeOrder(6),Trait("Category", "BindParamBatchCN")] public void TestBindMultiLineCN() { string tableName = "stb_stmt_cases_test_bind_multi_line_cn"; @@ -241,7 +254,7 @@ namespace Cases List expectResMeta = DataSource.GetMetaFromDDL(createSql); List expectResData = DataSource.GetMultiBindStableCNRowData(); - IntPtr conn = UtilsTools.TDConnection(); + IntPtr conn = database.conn; UtilsTools.ExecuteUpdate(conn, dropSql); UtilsTools.ExecuteUpdate(conn, createSql); @@ -282,11 +295,11 @@ namespace Cases /// Test stmt insert single line into stable by column after column /// StmtSTable.cs /// pass or failed - [Fact(DisplayName = "StableStmtCases.TestBindMultiLine()")] + [Fact(DisplayName = "StableStmtCases.TestBindMultiLine()"),TestExeOrder(5),Trait("Category", "BindParamBatch")] public void TestBindMultiLine() { string tableName = "stb_stmt_cases_test_bind_multi_line"; - string createSql = $"create stable if not exists {tableName} " + + string createSql = $"create stable if not exists {tableName} " + "(ts timestamp," + "b bool," + "v1 tinyint," + @@ -324,7 +337,7 @@ namespace Cases List expectResMeta = DataSource.GetMetaFromDDL(createSql); List expectResData = DataSource.GetMultiBindStableRowData(); - IntPtr conn = UtilsTools.TDConnection(); + IntPtr conn = database.conn; UtilsTools.ExecuteUpdate(conn, dropSql); UtilsTools.ExecuteUpdate(conn, createSql); @@ -370,7 +383,7 @@ namespace Cases /// Test stmt insert single line of chinese character into stable by column after column /// StmtSTable.cs /// pass or failed - [Fact(DisplayName = "StableStmtCases.TestBindColumn()")] + [Fact(DisplayName = "StableStmtCases.TestBindColumn()"),TestExeOrder(3),Trait("Category", "BindParamColumn")] public void TestBindColumn() { string tableName = "stb_stmt_cases_test_bindcolumn"; @@ -412,7 +425,7 @@ namespace Cases List expectResMeta = DataSource.GetMetaFromDDL(createSql); List expectResData = DataSource.GetMultiBindStableRowData(); - IntPtr conn = UtilsTools.TDConnection(); + IntPtr conn = database.conn; UtilsTools.ExecuteUpdate(conn, dropSql); UtilsTools.ExecuteUpdate(conn, createSql); -- GitLab