Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 7fc013c

Browse files
author
Keerat Singh
committed
Added Utf8SupportTest.
1 parent 0c591e4 commit 7fc013c

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using Xunit;
2+
3+
namespace System.Data.SqlClient.ManualTesting.Tests
4+
{
5+
public static class Utf8SupportTest
6+
{
7+
[CheckConnStrSetupFact]
8+
public static void CheckSupportUtf8ConnectionProperty()
9+
{
10+
using (SqlConnection connection = new SqlConnection(DataTestUtility.TcpConnStr))
11+
using (SqlCommand command = new SqlCommand())
12+
{
13+
command.Connection = connection;
14+
command.CommandText = "SELECT CONNECTIONPROPERTY('SUPPORT_UTF8')";
15+
connection.Open();
16+
17+
using (SqlDataReader reader = command.ExecuteReader())
18+
{
19+
while (reader.Read())
20+
{
21+
// CONNECTIONPROPERTY('SUPPORT_UTF8') returns NULL in SQLServer versions that don't support UTF-8.
22+
if (!reader.IsDBNull(0))
23+
{
24+
Assert.Equal(1, reader.GetInt32(0));
25+
}
26+
else
27+
{
28+
Console.WriteLine("CONNECTIONPROPERTY('SUPPORT_UTF8') is not supported on this SQLServer");
29+
}
30+
}
31+
}
32+
}
33+
}
34+
}
35+
}

src/System.Data.SqlClient/tests/ManualTests/System.Data.SqlClient.ManualTesting.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
<Compile Include="SQL\UdtTest\UdtTest.cs" />
122122
<Compile Include="SQL\UdtTest\UdtTest2.cs" />
123123
<Compile Include="SQL\UdtTest\UdtTestHelpers.cs" />
124+
<Compile Include="SQL\Utf8SupportTest\Utf8SupportTest.cs" />
124125
<Compile Include="SQL\WeakRefTest\WeakRefTest.cs" />
125126
<Compile Include="SQL\WeakRefTestYukonSpecific\WeakRefTestYukonSpecific.cs" />
126127
<Compile Include="XUnitAssemblyAttributes.cs" />

0 commit comments

Comments
 (0)