Skip to content

Commit 30db14c

Browse files
authored
SqlBulkTruncation (#331)
* This commit adds more tests for AE. Such as TestExecuteXmlReader, TestBeginAndEndExecuteReaderWithAsyncCallback, TestSqlCommandCancel, TestSqlCommandCancellationToken * code clean up * Resolving PR comments. * Fixing issues on AE tests. * fixing open SqlDataReader * Fixing some Failings on the pipeline tests. * fix TargetFrameWork issue * SqlBulkTruncation * Taking XMLReader test out. * fixing hard coded table name issue. * BulkCopy Truncation * Fixing Primary key issue * Update SqlBulkCopyTruncation.cs * more changes for SqlBulkCopyTruncation and AEV2 * Adding * bulkCopy * SwlBulkCopyTest * TestBulkCopy * Fix SqlBulkcopyTruncation * SqlBulkTruncation * Final SqlBulkCopyTruncations * SqlBulkCopy * sqlBulk * sqlBulkCopy * sqlBulkCopy
1 parent 2d01403 commit 30db14c

File tree

9 files changed

+972
-26
lines changed

9 files changed

+972
-26
lines changed

src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/ApiShould.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,10 +1809,8 @@ public void TestSqlCommandSequentialAccessCodePaths(string connection, CommandBe
18091809
}
18101810
}
18111811
}
1812-
18131812
}
18141813

1815-
[SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp)]
18161814
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringSetupForAE))]
18171815
[ClassData(typeof(AEConnectionStringProvider))]
18181816
public void TestExecuteXmlReader(string connection)
@@ -1822,20 +1820,20 @@ public void TestExecuteXmlReader(string connection)
18221820
IList<object> values = GetValues(dataHint: 60);
18231821
int numberOfRows = 10;
18241822

1825-
// Insert a bunch of rows in to the table.
1823+
// Insert a bunch of rows in to the table.
18261824
int rowsAffected = InsertRows(tableName: tableName, numberofRows: numberOfRows, values: values, connection: connection);
18271825
Assert.True(rowsAffected == numberOfRows, "number of rows affected is unexpected.");
18281826

18291827
using (SqlConnection sqlConnection = new SqlConnection(connection))
18301828
{
18311829
sqlConnection.Open();
18321830

1833-
// select the set of rows that were inserted just now.
1831+
// select the set of rows that were inserted just now.
18341832
using (SqlCommand sqlCommand = new SqlCommand($"SELECT LastName FROM [{tableName}] WHERE FirstName = @FirstName AND CustomerId = @CustomerId FOR XML AUTO;", sqlConnection, transaction: null, columnEncryptionSetting: SqlCommandColumnEncryptionSetting.Enabled))
18351833
{
18361834
if (DataTestUtility.EnclaveEnabled)
18371835
{
1838-
//Increase Time out for enclave-enabled server.
1836+
//Increase Time out for enclave-enabled server.
18391837
sqlCommand.CommandTimeout = 90;
18401838
}
18411839
sqlCommand.Parameters.Add(@"CustomerId", SqlDbType.Int);
@@ -1849,11 +1847,6 @@ public void TestExecuteXmlReader(string connection)
18491847

18501848
var ex = Assert.Throws<SqlException>(() => sqlCommand.ExecuteXmlReader());
18511849
Assert.Equal($"'FOR XML' clause is unsupported for encrypted columns.{Environment.NewLine}Statement(s) could not be prepared.", ex.Message);
1852-
1853-
//string xmlResult;
1854-
IAsyncResult asyncResult = sqlCommand.BeginExecuteXmlReader();
1855-
1856-
Assert.Throws<SqlException>(() => sqlCommand.EndExecuteXmlReader(asyncResult));
18571850
}
18581851
}
18591852
}

src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/ExceptionsGenericError.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
66
{
7-
public class ExceptionsGenericErrors : IClassFixture<ExceptionGenericErrorFixture> {
8-
7+
public class ExceptionsGenericErrors : IClassFixture<ExceptionGenericErrorFixture>
8+
{
99
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringSetupForAE), nameof(DataTestUtility.IsNotAzureServer), Skip = "ActiveIssue 10036")]
1010
[ClassData(typeof(AEConnectionStringProvider))]
11-
public void TestCommandOptionWithNoTceFeature (string connectionString) {
11+
public void TestCommandOptionWithNoTceFeature(string connectionString)
12+
{
1213
SqlConnectionStringBuilder sb = new SqlConnectionStringBuilder(connectionString);
13-
CertificateUtility.ChangeServerTceSetting (false, sb); // disable TCE on engine.
14+
CertificateUtility.ChangeServerTceSetting(false, sb); // disable TCE on engine.
1415
using (SqlConnection conn = CertificateUtility.GetOpenConnection(false, sb, fSuppressAttestation: true))
1516
{
1617
using (SqlCommand cmd = new SqlCommand(ExceptionGenericErrorFixture.encryptedProcedureName, conn, null, SqlCommandColumnEncryptionSetting.Enabled))
@@ -23,12 +24,13 @@ public void TestCommandOptionWithNoTceFeature (string connectionString) {
2324
}
2425
}
2526
// Turn on TCE now
26-
CertificateUtility.ChangeServerTceSetting (true, sb); // enable tce
27+
CertificateUtility.ChangeServerTceSetting(true, sb); // enable tce
2728
}
2829

2930
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringSetupForAE), nameof(DataTestUtility.IsNotAzureServer))]
3031
[ClassData(typeof(AEConnectionStringProvider))]
31-
public void TestDataAdapterAndEncrytionSetting (string connectionString) {
32+
public void TestDataAdapterAndEncrytionSetting(string connectionString)
33+
{
3234
SqlConnectionStringBuilder sb = new SqlConnectionStringBuilder(connectionString);
3335
// Create a new SqlCommand for select and delete
3436
using (SqlConnection conn = CertificateUtility.GetOpenConnection(false, sb))
@@ -56,7 +58,7 @@ public void TestDataAdapterAndEncrytionSetting (string connectionString) {
5658
rowInserted["c1"] = 5;
5759
table.Rows.Add(rowInserted);
5860
adapter.UpdateBatchSize = 0; // remove batch size limit
59-
// run batch update
61+
// run batch update
6062

6163
string expectedErrorMessage = "SqlCommandColumnEncryptionSetting should be identical on all commands (SelectCommand, InsertCommand, UpdateCommand, DeleteCommand) when doing batch updates.";
6264
InvalidOperationException e = Assert.Throws<InvalidOperationException>(() => adapter.Update(dataset));
@@ -67,7 +69,8 @@ public void TestDataAdapterAndEncrytionSetting (string connectionString) {
6769

6870
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringSetupForAE), nameof(DataTestUtility.IsNotAzureServer))]
6971
[ClassData(typeof(AEConnectionStringProvider))]
70-
public void TestInvalidForceColumnEncryptionSetting(string connectionString) {
72+
public void TestInvalidForceColumnEncryptionSetting(string connectionString)
73+
{
7174
SqlConnectionStringBuilder sb = new SqlConnectionStringBuilder(connectionString);
7275
using (SqlConnection conn = CertificateUtility.GetOpenConnection(false, sb))
7376
{
@@ -85,7 +88,8 @@ public void TestInvalidForceColumnEncryptionSetting(string connectionString) {
8588

8689
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringSetupForAE), nameof(DataTestUtility.IsNotAzureServer))]
8790
[ClassData(typeof(AEConnectionStringProvider))]
88-
public void TestParamUnexpectedEncryptionMD(string connectionString) {
91+
public void TestParamUnexpectedEncryptionMD(string connectionString)
92+
{
8993
SqlConnectionStringBuilder sb = new SqlConnectionStringBuilder(connectionString);
9094
using (SqlConnection conn = CertificateUtility.GetOpenConnection(true, sb))
9195
{

0 commit comments

Comments
 (0)