public void BulkInsertNullCollection() { using (DatabaseConnector databaseConnector = new DatabaseConnector(connectionString)) { databaseConnector.BulkInsert("BulkData", null); } }
public void BulkInsertMissingMandatoryField() { IList<BulkData> source = new List<BulkData>(); int dataCount = 1; DateTime currentDate = DateTime.UtcNow; for (int i = 0; i < dataCount; i++) { BulkData bulkData = new BulkData(); bulkData.Name = string.Format("Name-{0}", i); if (i % 2 == 0) { bulkData.Value = i.ToString(); } source.Add(bulkData); } using (DatabaseConnector databaseConnector = new DatabaseConnector(connectionString)) { // Insere os registros. databaseConnector.BulkInsert("BulkData", source); } }
public void BulkInsertEmptyTableName() { using (DatabaseConnector databaseConnector = new DatabaseConnector(connectionString)) { databaseConnector.BulkInsert(string.Empty, new List<int>()); } }
public void BulkInsertAttribute() { IList<BulkDataAttribute> source = new List<BulkDataAttribute>(); int dataCount = 100; DateTime currentDate = DateTime.UtcNow; for (int i = 0; i < dataCount; i++) { BulkDataAttribute bulkDataAttribute = new BulkDataAttribute(); bulkDataAttribute.Banana = string.Format("Name-{0}", i); if (i % 2 == 0) { bulkDataAttribute.Maca = i.ToString(); } bulkDataAttribute.Goiaba = currentDate; source.Add(bulkDataAttribute); } string query = @"DELETE FROM BulkData;"; int actual = 0; using (DatabaseConnector databaseConnector = new DatabaseConnector(connectionString)) { // Limpa qualquer informação pré-existente. databaseConnector.ExecuteNonQuery(query); // Insere os registros. databaseConnector.BulkInsert("BulkData", source); // Exclui os registros e armazena a quantidade excluída. actual = databaseConnector.ExecuteNonQuery(query); } Assert.AreEqual(dataCount, actual); }