public void SmallIntMappingTest() { // Create the Table: CreateTable(tableDefinition); // Create the Test Data: var entity0 = new TestEntity() { Int32 = 10, String = "Hello World" }; var entity1 = new TestEntity() { Int32 = 20, String = "Hello World 2.0" }; // Save the test data as Bulk: subject.Write(connection, transaction, new[] { entity0, entity1 }); // Check if we have inserted the correct amount of rows: Assert.AreEqual(2, GetRowCount(tableDefinition)); // Now get all results and order them by their Int32 value: var orderedResults = GetAll(tableDefinition).OrderBy(x => x.Int32).ToArray(); // And assert the result: Assert.AreEqual(10, orderedResults[0].Int32); Assert.AreEqual("Hello World", orderedResults[0].String); Assert.AreEqual(20, orderedResults[1].Int32); Assert.AreEqual("Hello World 2.0", orderedResults[1].String); }
public void OneMillionEntitiesTest() { // Bulk Options: var bulkOptions = new BulkCopyOptions(70000, TimeSpan.FromSeconds(30), true, SqlBulkCopyOptions.Default); // Build the Test Subject: var subject = new SqlServerBulkInsert <TestEntity>(new TestEntityMapping(), bulkOptions); // Create the Table: CreateTable(tableDefinition); // One Million Entities: var numberOfEntities = 1000000; // Create the Enumerable Test Data: var data = GenerateEntities(numberOfEntities); // Save the test data as Bulk: subject.Write(connection, transaction, data); // Check if we have inserted the correct amount of rows: Assert.AreEqual(numberOfEntities, GetRowCount(tableDefinition)); }