Beispiel #1
0
         , 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

        public void StringArray(IConnectionManager connection)
        {
            //Arrange
            TwoColumnsTableFixture destTable = new TwoColumnsTableFixture(connection, "BulkInsert2Columns");

            TableData <string[]> 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");

            //Assert
            destTable.AssertTestData();

            if (connection.GetType() == typeof(AccessOdbcConnectionManager))
            {
                connection.Close();
            }
            //Assert connection is closed
            Assert.True(connection.State == null);
        }
Beispiel #2
0
        public void OneTransactionAndParallelWriting(IConnectionManager connection)
        {
            if (connection.ConnectionManagerType == ConnectionManagerType.SQLite)
            {
                return;
            }
            if (connection.ConnectionManagerType == ConnectionManagerType.Oracle)
            {
                return;
            }

            //Arrange
            TwoColumnsTableFixture s2c = new TwoColumnsTableFixture(connection, "TransactionSourceParallelWrite");

            s2c.InsertTestData();
            TwoColumnsTableFixture      d2c1      = new TwoColumnsTableFixture(connection, "TransactionDest1");
            TwoColumnsTableFixture      d2c2      = new TwoColumnsTableFixture(connection, "TransactionDest2");
            DbSource <MySimpleRow>      source    = new DbSource <MySimpleRow>(connection, "TransactionSourceParallelWrite");
            DbDestination <MySimpleRow> dest1     = new DbDestination <MySimpleRow>(connection, "TransactionDest1", batchSize: 2);
            DbDestination <MySimpleRow> dest2     = new DbDestination <MySimpleRow>(connection, "TransactionDest2", batchSize: 2);
            Multicast <MySimpleRow>     multicast = new Multicast <MySimpleRow>();

            //Act & Assert
            Assert.ThrowsAny <Exception>(() =>
            {
                try
                {
                    connection.BeginTransaction(System.Data.IsolationLevel.ReadCommitted);
                    source.LinkTo(multicast);
                    multicast.LinkTo(dest1);
                    multicast.LinkTo(dest2);

                    source.Execute();
                    dest1.Wait();
                    dest2.Wait();
                }
                catch
                {
                    throw;
                }
                finally
                {
                    connection.RollbackTransaction();
                    connection.Close();
                }
            });
            if (connection.GetType() == typeof(MySqlConnectionManager))
            {
                Task.Delay(200).Wait(); //MySql needs a little bit longer to free resources
            }
        }
 public void Setup()
 {
     try
     {
         ConnectionManager.Open();
         var _clienteRepository = new ClienteRepository {
             ConnectionManager = ConnectionManager
         };
         _clienteRepository.Setup();
     }
     catch { }
     finally
     {
         ConnectionManager.Close();
         ConnectionManager.Open();
     }
 }
Beispiel #4
0
        public void CloseConnectionDuringTransaction(IConnectionManager connection)
        {
            //Arrange
            TwoColumnsTableFixture s2c = new TwoColumnsTableFixture(connection, "TransactionSource");

            s2c.InsertTestData();
            TwoColumnsTableFixture      d2c    = new TwoColumnsTableFixture(connection, "TransactionDest");
            DbSource <MySimpleRow>      source = new DbSource <MySimpleRow>(connection, "TransactionSource");
            DbDestination <MySimpleRow> dest   = new DbDestination <MySimpleRow>(connection, "TransactionDest", batchSize: 2);

            //Act & Assert
            connection.BeginTransaction();
            source.LinkTo(dest);
            source.Execute();
            dest.Wait();
            Assert.Equal(3, RowCountTask.Count(connection, "TransactionDest"));
            connection.Close();
            Assert.Equal(0, RowCountTask.Count(connection, "TransactionDest"));

            //Assert Connections are closed
            Assert.True(dest.BulkInsertConnectionManager.State == null);
            Assert.True(connection.State == null);
        }