forked from lmm713281/etlbox
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade dependencies to modern SQLServer and PGSQL drivers
Added NEtDateTimeKind to address TZ/noTZ ambiguity Address https://www.npgsql.org/doc/release-notes/6.0.html#major-changes-to-timestamp-mapping incopatibility Address dotnet/SqlClient#1402 new SQL Server encryption defaults
- Loading branch information
Showing
29 changed files
with
439 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,87 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using ALE.ETLBox; | ||
using ALE.ETLBox.ConnectionManager; | ||
using ALE.ETLBox.ControlFlow; | ||
using ALE.ETLBox.Helper; | ||
using ALE.ETLBox.Logging; | ||
using ALE.ETLBoxTests.Fixtures; | ||
using System; | ||
using System.Collections.Generic; | ||
using Xunit; | ||
|
||
namespace ALE.ETLBoxTests.ControlFlowTests | ||
namespace ALE.ETLBoxTests.ControlFlowTests; | ||
|
||
[Collection("ControlFlow")] | ||
public class SqlTaskBulkInsertTests | ||
{ | ||
[Collection("ControlFlow")] | ||
public class SqlTaskBulkInsertTests | ||
public SqlTaskBulkInsertTests(ControlFlowDatabaseFixture dbFixture) | ||
{ | ||
} | ||
|
||
public static IEnumerable<object[]> Connections => RuntimeInformation.IsOSPlatform(OSPlatform.Windows) | ||
? Config.AllSqlConnections("ControlFlow").Concat(Config.AccessConnection("ControlFlow")) | ||
: Config.AllSqlConnections("ControlFlow"); | ||
|
||
public static IEnumerable<object[]> ConnectionsWithValue(int value) | ||
{ | ||
return Config.AllSqlConnectionsWithValue("ControlFlow", value); | ||
} | ||
|
||
|
||
[Theory] | ||
[MemberData(nameof(Connections))] | ||
//If access fails with "Internal OLE Automation error", download and install: https://www.microsoft.com/en-us/download/confirmation.aspx?id=50040 | ||
//see also: https://stackoverflow.com/questions/54632928/internal-ole-automation-error-in-ms-access-using-oledb | ||
public void StringArray(IConnectionManager connection) | ||
{ | ||
public static IEnumerable<object[]> Connections => Config.AllSqlConnections("ControlFlow"); | ||
public static IEnumerable<object[]> ConnectionsWithValue(int value) | ||
=> Config.AllSqlConnectionsWithValue("ControlFlow", value); | ||
public static IEnumerable<object[]> Access => Config.AccessConnection("ControlFlow"); | ||
//Arrange | ||
var destTable = new TwoColumnsTableFixture(connection, "BulkInsert2Columns"); | ||
|
||
public SqlTaskBulkInsertTests(ControlFlowDatabaseFixture dbFixture) | ||
{ } | ||
var data = new TableData<string[]>(destTable.TableDefinition); | ||
string[] values = { "1", "Test1" }; | ||
data.Rows.Add(values); | ||
string[] values2 = { "2", "Test2" }; | ||
data.Rows.Add(values2); | ||
string[] values3 = { "3", "Test3" }; | ||
data.Rows.Add(values3); | ||
|
||
//Act | ||
SqlTask.BulkInsert(connection, "Bulk insert demo data", data, "BulkInsert2Columns"); | ||
|
||
[Theory, MemberData(nameof(Connections)) | ||
, MemberData(nameof(Access))] //If access fails with "Internal OLE Automation error", download and install: https://www.microsoft.com/en-us/download/confirmation.aspx?id=50040 | ||
//see also: https://stackoverflow.com/questions/54632928/internal-ole-automation-error-in-ms-access-using-oledb | ||
//Assert | ||
destTable.AssertTestData(); | ||
|
||
public void StringArray(IConnectionManager connection) | ||
if (connection.GetType() == typeof(AccessOdbcConnectionManager)) | ||
connection.Close(); | ||
//Assert connection is closed | ||
Assert.True(connection.State == null); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(ConnectionsWithValue), 0)] | ||
[MemberData(nameof(ConnectionsWithValue), 2)] | ||
[MemberData(nameof(ConnectionsWithValue), 3)] | ||
public void WithIdentityShift(IConnectionManager connection, int identityIndex) | ||
{ | ||
//SQLite does not support Batch Insert on Non Nullable Identity Columns | ||
if (connection.GetType() != typeof(SQLiteConnectionManager)) | ||
{ | ||
//Arrange | ||
TwoColumnsTableFixture destTable = new TwoColumnsTableFixture(connection, "BulkInsert2Columns"); | ||
var destTable = | ||
new FourColumnsTableFixture(connection, "BulkInsert4Columns", identityIndex); | ||
|
||
TableData<string[]> data = new TableData<string[]>(destTable.TableDefinition); | ||
string[] values = { "1", "Test1" }; | ||
var data = new TableData(destTable.TableDefinition, 2); | ||
object[] values = { "Test1", null, 1.2 }; | ||
data.Rows.Add(values); | ||
string[] values2 = { "2", "Test2" }; | ||
object[] values2 = { "Test2", 4711, 1.23 }; | ||
data.Rows.Add(values2); | ||
string[] values3 = { "3", "Test3" }; | ||
object[] values3 = { "Test3", 185, 1.234 }; | ||
data.Rows.Add(values3); | ||
|
||
//Act | ||
SqlTask.BulkInsert(connection, "Bulk insert demo data", data, "BulkInsert2Columns"); | ||
SqlTask.BulkInsert(connection, "Bulk insert demo data", data, "BulkInsert4Columns"); | ||
|
||
//Assert | ||
destTable.AssertTestData(); | ||
|
||
if (connection.GetType() == typeof(AccessOdbcConnectionManager)) | ||
connection.Close(); | ||
//Assert connection is closed | ||
Assert.True(connection.State == null); | ||
} | ||
|
||
[Theory, MemberData(nameof(ConnectionsWithValue), 0), | ||
MemberData(nameof(ConnectionsWithValue), 2), | ||
MemberData(nameof(ConnectionsWithValue), 3)] | ||
public void WithIdentityShift(IConnectionManager connection, int identityIndex) | ||
{ | ||
//SQLite does not support Batch Insert on Non Nullable Identity Columns | ||
if (connection.GetType() != typeof(SQLiteConnectionManager)) | ||
{ | ||
//Arrange | ||
FourColumnsTableFixture destTable = new FourColumnsTableFixture(connection, "BulkInsert4Columns", identityIndex); | ||
|
||
TableData data = new TableData(destTable.TableDefinition, 2); | ||
object[] values = { "Test1", null, 1.2 }; | ||
data.Rows.Add(values); | ||
object[] values2 = { "Test2", 4711, 1.23 }; | ||
data.Rows.Add(values2); | ||
object[] values3 = { "Test3", 185, 1.234 }; | ||
data.Rows.Add(values3); | ||
|
||
//Act | ||
SqlTask.BulkInsert(connection, "Bulk insert demo data", data, "BulkInsert4Columns"); | ||
|
||
//Assert | ||
destTable.AssertTestData(); | ||
} | ||
} | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.