Added Utf8SupportTest.
authorKeerat Singh <v-kesin@microsoft.com>
Fri, 13 Jul 2018 17:18:52 +0000 (10:18 -0700)
committerKeerat Singh <v-kesin@microsoft.com>
Fri, 13 Jul 2018 17:18:52 +0000 (10:18 -0700)
Commit migrated from https://github.com/dotnet/corefx/commit/7fc013c17fb2b2cea007b7403c175b81bcb2f8d3

src/libraries/System.Data.SqlClient/tests/ManualTests/SQL/Utf8SupportTest/Utf8SupportTest.cs [new file with mode: 0644]
src/libraries/System.Data.SqlClient/tests/ManualTests/System.Data.SqlClient.ManualTesting.Tests.csproj

diff --git a/src/libraries/System.Data.SqlClient/tests/ManualTests/SQL/Utf8SupportTest/Utf8SupportTest.cs b/src/libraries/System.Data.SqlClient/tests/ManualTests/SQL/Utf8SupportTest/Utf8SupportTest.cs
new file mode 100644 (file)
index 0000000..536d878
--- /dev/null
@@ -0,0 +1,35 @@
+using Xunit;
+
+namespace System.Data.SqlClient.ManualTesting.Tests
+{
+    public static class Utf8SupportTest
+    {
+        [CheckConnStrSetupFact]
+        public static void CheckSupportUtf8ConnectionProperty()
+        {
+            using (SqlConnection connection = new SqlConnection(DataTestUtility.TcpConnStr))
+            using (SqlCommand command = new SqlCommand())
+            {
+                command.Connection = connection;
+                command.CommandText = "SELECT CONNECTIONPROPERTY('SUPPORT_UTF8')";
+                connection.Open();
+
+                using (SqlDataReader reader = command.ExecuteReader())
+                {
+                    while (reader.Read())
+                    {
+                        // CONNECTIONPROPERTY('SUPPORT_UTF8') returns NULL in SQLServer versions that don't support UTF-8.
+                        if (!reader.IsDBNull(0))
+                        {
+                            Assert.Equal(1, reader.GetInt32(0));
+                        }
+                        else
+                        {
+                            Console.WriteLine("CONNECTIONPROPERTY('SUPPORT_UTF8') is not supported on this SQLServer");
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
index db6cc18..76f0639 100644 (file)
     <Compile Include="SQL\UdtTest\UdtTest.cs" />
     <Compile Include="SQL\UdtTest\UdtTest2.cs" />
     <Compile Include="SQL\UdtTest\UdtTestHelpers.cs" />
+    <Compile Include="SQL\Utf8SupportTest\Utf8SupportTest.cs" />
     <Compile Include="SQL\WeakRefTest\WeakRefTest.cs" />
     <Compile Include="SQL\WeakRefTestYukonSpecific\WeakRefTestYukonSpecific.cs" />
     <Compile Include="XUnitAssemblyAttributes.cs" />