Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private SqlVector(int length)
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/CreateNull/*' />
public static SqlVector<T> CreateNull(int length) => new(length);

/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/ctor2/*' />
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/ctor1/*' />
public SqlVector(ReadOnlyMemory<T> memory)
{
(_elementType, _elementSize) = GetTypeFieldsOrThrow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@ public static class DataTestUtility
//SQL Server EngineEdition
private static string s_sqlServerEngineEdition;

// JSON Column type
public static readonly bool IsJsonSupported = false;

// VECTOR column type
public static readonly bool IsVectorSupported = false;

// Azure Synapse EngineEditionId == 6
// More could be read at https://learn.microsoft.com/en-us/sql/t-sql/functions/serverproperty-transact-sql?view=sql-server-ver16#propertyname
public static bool IsAzureSynapse
Expand Down Expand Up @@ -179,7 +173,6 @@ static DataTestUtility()
ManagedIdentitySupported = c.ManagedIdentitySupported;
IsManagedInstance = c.IsManagedInstance;
AliasName = c.AliasName;
IsJsonSupported = c.IsJsonSupported;

#if NETFRAMEWORK
System.Net.ServicePointManager.SecurityProtocol |= System.Net.SecurityProtocolType.Tls12;
Expand Down Expand Up @@ -456,6 +449,11 @@ public static bool IsNotAzureServer()
return !AreConnStringsSetup() || !Utils.IsAzureSqlServer(new SqlConnectionStringBuilder(TCPConnectionString).DataSource);
}

public static bool IsAzureServer()
{
return AreConnStringsSetup() && Utils.IsAzureSqlServer(new SqlConnectionStringBuilder(TCPConnectionString).DataSource);
}

public static bool IsNotNamedInstance()
{
return !AreConnStringsSetup() || !new SqlConnectionStringBuilder(TCPConnectionString).DataSource.Contains(@"\");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@
<Compile Include="SQL\DataSourceParserTest\DataSourceParserTest.cs" />
<Compile Include="SQL\InstanceNameTest\InstanceNameTest.cs" />
<Compile Include="SQL\IntegratedAuthenticationTest\IntegratedAuthenticationTest.cs" />
<Compile Include="SQL\JsonTest\JsonBulkCopyTest.cs" />
<Compile Include="SQL\JsonTest\JsonStreamTest.cs" />
<Compile Include="SQL\JsonTest\JsonTest.cs" />
<Compile Include="SQL\KerberosTests\KerberosTest.cs" />
<Compile Include="SQL\KerberosTests\KerberosTicketManager\KerberosTicketManager.cs" />
<Compile Include="SQL\LocalDBTest\LocalDBTest.cs" />
Expand Down Expand Up @@ -212,6 +215,9 @@
<Compile Include="SQL\UdtTest\UdtTest2.cs" />
<Compile Include="SQL\UdtTest\UdtTestHelpers.cs" />
<Compile Include="SQL\Utf8SupportTest\Utf8SupportTest.cs" />
<Compile Include="SQL\VectorTest\VectorTypeBackwardCompatibilityTests.cs" />
<Compile Include="SQL\VectorTest\NativeVectorFloat32Tests.cs" />
<Compile Include="SQL\VectorTest\VectorAPIValidationTest.cs" />
<Compile Include="SQL\WeakRefTest\WeakRefTest.cs" />
<Compile Include="SQL\WeakRefTestYukonSpecific\WeakRefTestYukonSpecific.cs" />
<Compile Include="SQL\ParameterTest\DateTimeVariantTest.cs" />
Expand Down Expand Up @@ -293,11 +299,6 @@
<Compile Include="SQL\Common\SystemDataInternals\TdsParserStateObjectHelper.cs" />
<Compile Include="SQL\ConnectionTestWithSSLCert\CertificateTest.cs" />
<Compile Include="SQL\ConnectionTestWithSSLCert\CertificateTestWithTdsServer.cs" />
<Compile Include="SQL\JsonTest\JsonBulkCopyTest.cs" />
<Compile Include="SQL\JsonTest\JsonStreamTest.cs" />
<Compile Include="SQL\JsonTest\JsonTest.cs" />
<Compile Include="SQL\VectorTest\VectorTypeBackwardCompatibilityTests.cs" />
<Compile Include="SQL\VectorTest\NativeVectorFloat32Tests.cs" />
<Compile Include="SQL\SqlCommand\SqlCommandStoredProcTest.cs" />
<Compile Include="TracingTests\TestTdsServer.cs" />
<Compile Include="XUnitAssemblyAttributes.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests.SQL.JsonTest
public class JsonBulkCopyTest
{
private readonly ITestOutputHelper _output;
private static readonly string _generatedJsonFile = DataTestUtility.GenerateRandomCharacters("randomRecords");
private static readonly string _outputFile = DataTestUtility.GenerateRandomCharacters("serverResults");
private static readonly string _sourceTableName = DataTestUtility.GenerateObjectName();
private static readonly string _destinationTableName = DataTestUtility.GenerateObjectName();
private static readonly string _generatedJsonFile = DataTestUtility.GetUniqueName("randomRecords");
private static readonly string _outputFile = DataTestUtility.GetUniqueName("serverResults");
private static readonly string _sourceTableName = DataTestUtility.GetUniqueName("jsonBulkCopySrcTable", true);
private static readonly string _destinationTableName = DataTestUtility.GetUniqueName("jsonBulkCopyDestTable", true);

public JsonBulkCopyTest(ITestOutputHelper output)
{
_output = output;
}

public static IEnumerable<object[]> JsonBulkCopyTestData()
{
yield return new object[] { CommandBehavior.Default, false, 300, 100 };
yield return new object[] { CommandBehavior.Default, true, 300, 100 };
yield return new object[] { CommandBehavior.SequentialAccess, false, 300, 100 };
yield return new object[] { CommandBehavior.SequentialAccess, true, 300, 100 };
yield return new object[] { CommandBehavior.Default, false, 30, 10 };
yield return new object[] { CommandBehavior.Default, true, 30, 10 };
yield return new object[] { CommandBehavior.SequentialAccess, false, 30, 10 };
yield return new object[] { CommandBehavior.SequentialAccess, true, 30, 10 };
}

private void PopulateData(int noOfRecords, int rows)
Expand Down Expand Up @@ -87,7 +87,7 @@ private void PrintJsonDataToFileAndCompare(SqlConnection connection)
try
{
DeleteFile(_outputFile);
using (SqlCommand command = new SqlCommand("SELECT [data] FROM [" + _destinationTableName + "]", connection))
using (SqlCommand command = new SqlCommand("SELECT [data] FROM " + _destinationTableName, connection))
{
using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.SequentialAccess))
{
Expand Down Expand Up @@ -125,7 +125,7 @@ private async Task PrintJsonDataToFileAndCompareAsync(SqlConnection connection)
try
{
DeleteFile(_outputFile);
using (SqlCommand command = new SqlCommand("SELECT [data] FROM [" + _destinationTableName + "]", connection))
using (SqlCommand command = new SqlCommand("SELECT [data] FROM " + _destinationTableName, connection))
{
using (SqlDataReader reader = await command.ExecuteReaderAsync(CommandBehavior.SequentialAccess))
{
Expand Down Expand Up @@ -159,7 +159,7 @@ private async Task PrintJsonDataToFileAndCompareAsync(SqlConnection connection)

private void StreamJsonFileToServer(SqlConnection connection)
{
using (SqlCommand cmd = new SqlCommand("INSERT INTO [" + _sourceTableName + "] (data) VALUES (@jsondata)", connection))
using (SqlCommand cmd = new SqlCommand("INSERT INTO " + _sourceTableName + " (data) VALUES (@jsondata)", connection))
{
using (StreamReader jsonFile = File.OpenText(_generatedJsonFile))
{
Expand All @@ -171,7 +171,7 @@ private void StreamJsonFileToServer(SqlConnection connection)

private async Task StreamJsonFileToServerAsync(SqlConnection connection)
{
using (SqlCommand cmd = new SqlCommand("INSERT INTO [" + _sourceTableName + "] (data) VALUES (@jsondata)", connection))
using (SqlCommand cmd = new SqlCommand("INSERT INTO " + _sourceTableName + " (data) VALUES (@jsondata)", connection))
{
using (StreamReader jsonFile = File.OpenText(_generatedJsonFile))
{
Expand Down Expand Up @@ -265,7 +265,7 @@ private async Task BulkCopyDataAsync(CommandBehavior cb, bool enableStraming, in
}
}

[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.IsJsonSupported))]
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.IsAzureServer))]
[MemberData(
nameof(JsonBulkCopyTestData)
#if NETFRAMEWORK
Expand All @@ -289,7 +289,7 @@ public void TestJsonBulkCopy(CommandBehavior cb, bool enableStraming, int jsonAr
}
}

[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.IsJsonSupported))]
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.IsAzureServer))]
[MemberData(
nameof(JsonBulkCopyTestData)
#if NETFRAMEWORK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class JsonRecord
public class JsonStreamTest
{
private readonly ITestOutputHelper _output;
private static readonly string _jsonFile = "randomRecords.json";
private static readonly string _outputFile = "serverRecords.json";
private static readonly string _jsonFile = DataTestUtility.GetUniqueName("randomRecords") + ".json";
private static readonly string _outputFile = DataTestUtility.GetUniqueName("serverRecords") + ".json";

public JsonStreamTest(ITestOutputHelper output)
{
Expand Down Expand Up @@ -157,10 +157,10 @@ private void DeleteFile(string filename)
}
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsJsonSupported))]
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsAzureServer))]
public void TestJsonStreaming()
{
GenerateJsonFile(10000, _jsonFile);
GenerateJsonFile(1000, _jsonFile);
using (SqlConnection connection = new SqlConnection(DataTestUtility.TCPConnectionString))
{
connection.Open();
Expand All @@ -173,10 +173,10 @@ public void TestJsonStreaming()
}
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsJsonSupported))]
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsAzureServer))]
public async Task TestJsonStreamingAsync()
{
GenerateJsonFile(10000, _jsonFile);
GenerateJsonFile(1000, _jsonFile);
using (SqlConnection connection = new SqlConnection(DataTestUtility.TCPConnectionString))
{
await connection.OpenAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private void ValidateNullJson(SqlDataReader reader)
}
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsJsonSupported))]
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsAzureServer))]
public void TestJsonWrite()
{
string tableName = DataTestUtility.GenerateObjectName();
Expand Down Expand Up @@ -137,7 +137,7 @@ public void TestJsonWrite()
}
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsJsonSupported))]
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsAzureServer))]
public async Task TestJsonWriteAsync()
{
string tableName = DataTestUtility.GenerateObjectName();
Expand Down Expand Up @@ -201,7 +201,7 @@ public async Task TestJsonWriteAsync()
}
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsJsonSupported))]
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsAzureServer))]
public void TestJsonRead()
{
string tableName = DataTestUtility.GenerateObjectName();
Expand Down Expand Up @@ -260,7 +260,7 @@ public void TestJsonRead()
}
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsJsonSupported))]
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsAzureServer))]
public async Task TestJsonReadAsync()
{
string tableName = DataTestUtility.GenerateObjectName();
Expand Down Expand Up @@ -319,7 +319,7 @@ public async Task TestJsonReadAsync()
}
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsJsonSupported))]
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsAzureServer))]
public void TestNullJson()
{
string tableName = DataTestUtility.GenerateObjectName();
Expand Down Expand Up @@ -350,7 +350,7 @@ public void TestNullJson()
DataTestUtility.DropTable(connection, tableName);
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsJsonSupported))]
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsAzureServer))]
public void TestJsonAPIs()
{
string tableName = DataTestUtility.GenerateObjectName();
Expand Down Expand Up @@ -398,7 +398,7 @@ public void TestJsonAPIs()
}
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsJsonSupported))]
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsAzureServer))]
public void TestJsonWithMARS()
{
string table1Name = DataTestUtility.GenerateObjectName();
Expand Down Expand Up @@ -454,7 +454,7 @@ public void TestJsonWithMARS()
}
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsJsonSupported))]
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsAzureServer))]
public void TestJsonSPParams()
{
string tableName = DataTestUtility.GenerateObjectName();
Expand Down
Loading
Loading