CurtHagenlocher commented on code in PR #1287:
URL: https://github.com/apache/arrow-adbc/pull/1287#discussion_r1391545100


##########
csharp/test/Apache.Arrow.Adbc.Tests/ClientTests.cs:
##########
@@ -31,6 +33,143 @@ namespace Apache.Arrow.Adbc.Tests
     /// </summary>
     public class ClientTests
     {
+        /// <summary>
+        /// Validates if the client execute updates.
+        /// </summary>
+        /// <param name="adbcConnection">The <see 
cref="Adbc.Client.AdbcConnection"/> to use.</param>
+        /// <param name="testConfiguration">The <see 
cref="TestConfiguration"/> to use</param>
+        /// <param name="queries">The queries to run</param>
+        /// <param name="expectedResults">The expected results (one per 
query)</param>
+        public static void CanClientExecuteUpdate(Adbc.Client.AdbcConnection 
adbcConnection,
+            TestConfiguration testConfiguration,
+            string[] queries,
+            List<int> expectedResults)
+        {
+            if (adbcConnection == null) throw new 
ArgumentNullException(nameof(adbcConnection));
+            if (testConfiguration == null) throw new 
ArgumentNullException(nameof(testConfiguration));
+            if (queries == null) throw new 
ArgumentNullException(nameof(queries));
+            if (expectedResults == null) throw new 
ArgumentNullException(nameof(expectedResults));
+            if (queries.Length != expectedResults.Count) throw new 
ArgumentException($"{nameof(queries)} and {nameof(expectedResults)} must have 
the same number of values");
+
+            adbcConnection.Open();
+
+            for (int i = 0; i < queries.Length; i++)
+            {
+                string query = queries[i];
+                AdbcCommand adbcCommand = adbcConnection.CreateCommand();
+                adbcCommand.CommandText = query;
+
+                int rows = adbcCommand.ExecuteNonQuery();
+
+                Assert.Equal(expectedResults[i], rows);
+            }
+        }
+
+        /// <summary>
+        /// Validates if the client can get the schema.
+        /// </summary>
+        /// <param name="adbcConnection">The <see 
cref="Adbc.Client.AdbcConnection"/> to use.</param>
+        /// <param name="testConfiguration">The <see 
cref="TestConfiguration"/> to use</param>
+        public static void CanClientGetSchema(Adbc.Client.AdbcConnection 
adbcConnection, TestConfiguration testConfiguration)
+        {
+            if (adbcConnection == null) throw new 
ArgumentNullException(nameof(adbcConnection));
+            if (testConfiguration == null) throw new 
ArgumentNullException(nameof(testConfiguration));
+
+            AdbcCommand adbcCommand = new AdbcCommand(testConfiguration.Query, 
adbcConnection);
+
+            adbcConnection.Open();
+
+            AdbcDataReader reader = 
adbcCommand.ExecuteReader(CommandBehavior.SchemaOnly);
+
+            DataTable table = reader.GetSchemaTable();
+
+            // there is one row per field
+            Assert.Equal(testConfiguration.Metadata.ExpectedColumnCount, 
table.Rows.Count);
+        }
+
+        /// <summary>
+        /// Validates if the client can connect to a live server and
+        /// parse the results.
+        /// </summary>
+        /// <param name="adbcConnection">The <see 
cref="Adbc.Client.AdbcConnection"/> to use.</param>
+        /// <param name="testConfiguration">The <see 
cref="TestConfiguration"/> to use</param>
+        public static void CanClientExecuteQuery(Adbc.Client.AdbcConnection 
adbcConnection, TestConfiguration testConfiguration)
+        {
+            if (adbcConnection == null) throw new 
ArgumentNullException(nameof(adbcConnection));
+            if (testConfiguration == null) throw new 
ArgumentNullException(nameof(testConfiguration));
+
+            long count = 0;
+
+            AdbcCommand adbcCommand = new AdbcCommand(testConfiguration.Query, 
adbcConnection);

Review Comment:
   DbCommand is IDisposable; would be good to "using" it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to