public void TestMySqlConnectionMergeAllAsDynamicsViaTableNameForNonIdentityForEmptyTable() { // Setup var tables = Helper.CreateNonIdentityCompleteTablesAsDynamics(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.MergeAll(ClassMappedNameCache.Get <NonIdentityCompleteTable>(), tables); // Assert Assert.AreEqual(tables.Count, connection.CountAll <NonIdentityCompleteTable>()); // Assert Assert.AreEqual(tables.Count, result); // Act var queryResult = connection.QueryAll <NonIdentityCompleteTable>(); // Assert Assert.AreEqual(tables.Count, queryResult.Count()); tables.ForEach(table => Helper.AssertMembersEquality(table, queryResult.First(e => e.Id == table.Id))); } }
public void TestMySqlConnectionMergeAllAsyncAsDynamicsViaTableNameForIdentityForNonEmptyTableWithQualifiers() { // Setup var tables = Database.CreateCompleteTables(10).AsList(); var qualifiers = new[] { new Field("Id", typeof(long)) }; using (var connection = new MySqlConnection(Database.ConnectionString)) { // Setup tables.ForEach(table => Helper.UpdateCompleteTableProperties(table)); // Act var result = connection.MergeAllAsync(ClassMappedNameCache.Get <CompleteTable>(), tables, qualifiers).Result; // Assert Assert.AreEqual(tables.Count, connection.CountAll <CompleteTable>()); // Act var queryResult = connection.QueryAll <CompleteTable>(); // Assert Assert.AreEqual(tables.Count, queryResult.Count()); tables.ForEach(table => Helper.AssertPropertiesEquality(table, queryResult.First(e => e.Id == table.Id))); } }
public void TestMySqlConnectionMergeAsyncAsExpandoObjectViaTableNameForIdentityForNonEmptyTable() { // Setup var table = Database.CreateCompleteTables(1).First(); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Setup var entity = Helper.CreateCompleteTablesAsExpandoObjects(1).First(); ((IDictionary <string, object>)entity)["Id"] = table.Id; // Act var result = connection.MergeAsync <long>(ClassMappedNameCache.Get <CompleteTable>(), entity).Result; // Assert Assert.AreEqual(1, connection.CountAll <CompleteTable>()); Assert.AreEqual(table.Id, result); Assert.AreEqual(((dynamic)table).Id, result); // Act var queryResult = connection.Query <CompleteTable>(result); // Assert Helper.AssertMembersEquality(queryResult.First(), entity); } }
public void TestMySqlConnectionMergeAsyncAsDynamicViaTableNameForIdentityForNonEmptyTableWithQualifiers() { // Setup var table = Database.CreateCompleteTables(1).First(); var qualifiers = new[] { new Field("Id", typeof(long)) }; using (var connection = new MySqlConnection(Database.ConnectionString)) { // Setup Helper.UpdateCompleteTableProperties(table); // Act var result = connection.MergeAsync(ClassMappedNameCache.Get <CompleteTable>(), table, qualifiers: qualifiers).Result; // Assert Assert.AreEqual(1, connection.CountAll <CompleteTable>()); Assert.AreEqual(table.Id, Convert.ToInt64(result)); // Act var queryResult = connection.Query <CompleteTable>(result); // Assert Helper.AssertPropertiesEquality(table, queryResult.First()); } }
public void TestMySqlConnectionMergeForIdentityForNonEmptyTableWithQualifiers() { // Setup var table = Database.CreateCompleteTables(1).First(); var qualifiers = new[] { new Field("Id", typeof(long)) }; using (var connection = new MySqlConnection(Database.ConnectionString)) { // Setup Helper.UpdateCompleteTableProperties(table); table.ColumnInt = 0; table.ColumnChar = "C"; // Act var result = connection.Merge <CompleteTable>(table, qualifiers: qualifiers); // Assert Assert.AreEqual(1, connection.CountAll <CompleteTable>()); Assert.AreEqual(table.Id, Convert.ToInt64(result)); // Act var queryResult = connection.Query <CompleteTable>(result); // Assert Helper.AssertPropertiesEquality(table, queryResult.First()); } }
public void TestMySqlConnectionMergeViaTableNameForIdentityForNonEmptyTable() { // Setup var table = Database.CreateCompleteTables(1).First(); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Setup Helper.UpdateCompleteTableProperties(table); // Act var result = connection.Merge(ClassMappedNameCache.Get <CompleteTable>(), table); // Assert Assert.AreEqual(1, connection.CountAll <CompleteTable>()); Assert.AreEqual(table.Id, Convert.ToInt64(result)); // Act var queryResult = connection.Query <CompleteTable>(result); // Assert Helper.AssertPropertiesEquality(table, queryResult.First()); } }
public void TestMySqlConnectionMergeAllViaTableNameAsyncForIdentityForNonEmptyTable() { // Setup var tables = Database.CreateCompleteTables(10).AsList(); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Setup tables.ForEach(table => Helper.UpdateCompleteTableProperties(table)); // Act var result = connection.MergeAllAsync(ClassMappedNameCache.Get <CompleteTable>(), tables).Result; // Assert Assert.AreEqual(tables.Count, connection.CountAll <CompleteTable>()); // Act var queryResult = connection.QueryAll <CompleteTable>(); // Assert Assert.AreEqual(tables.Count, queryResult.Count()); tables.ForEach(table => Helper.AssertMembersEquality(table, queryResult.First(e => e.Id == table.Id))); } }
public void TestMySqlConnectionMergeAllAsyncAsExpandoObjectViaTableNameForIdentityForNonEmptyTable() { // Setup var entities = Database.CreateCompleteTables(10).AsList(); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Setup var tables = Helper.CreateCompleteTablesAsExpandoObjects(10).AsList(); tables.ForEach(e => ((IDictionary <string, object>)e)["Id"] = entities[tables.IndexOf(e)].Id); // Act var result = connection.MergeAllAsync(ClassMappedNameCache.Get <CompleteTable>(), tables).Result; // Assert Assert.AreEqual(entities.Count, connection.CountAll <CompleteTable>()); Assert.IsTrue(tables.All(table => ((dynamic)table).Id > 0)); // Act var queryResult = connection.QueryAll <CompleteTable>(); // Assert Assert.AreEqual(entities.Count, queryResult.Count()); tables.ForEach(table => Helper.AssertMembersEquality(queryResult.First(e => e.Id == ((dynamic)table).Id), table)); } }
public void ThrowExceptionOnMySqlConnectionCountAllWithHints() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act connection.CountAll <CompleteTable>(hints: "WhatEver"); } }
public void ThrowExceptionOnMySqlConnectionCountAllViaTableNameWithHints() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act connection.CountAll(ClassMappedNameCache.Get <CompleteTable>(), hints: "WhatEver"); } }
public void TestSqlTransactionForCountAll() { using (var connection = new MySqlConnection(Database.ConnectionString)) { // Prepare using (var transaction = connection.EnsureOpen().BeginTransaction()) { // Act connection.CountAll <CompleteTable>(transaction: transaction); } } }
public void TestMySqlConnectionCountAll() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.CountAll <CompleteTable>(); // Assert Assert.AreEqual(tables.Count(), result); } }
public void TestMySqlConnectionTruncateAsyncViaTableNameWithoutExpression() { // Setup var tables = Database.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.TruncateAsync(ClassMappedNameCache.Get <CompleteTable>()).Result; var countResult = connection.CountAll <CompleteTable>(); // Assert Assert.AreEqual(0, countResult); } }
public void TestMySqlConnectionMergeForIdentityForEmptyTable() { // Setup var table = Helper.CreateCompleteTables(1).First(); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.Merge <CompleteTable>(table); var queryResult = connection.Query <CompleteTable>(result); // Assert Assert.AreEqual(1, connection.CountAll <CompleteTable>()); Helper.AssertPropertiesEquality(table, queryResult.First()); } }
public void TestMySqlConnectionMergeAsyncAsExpandoObjectViaTableNameForIdentityForEmptyTable() { // Setup var table = Helper.CreateCompleteTablesAsExpandoObjects(1).First(); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.MergeAsync(ClassMappedNameCache.Get <CompleteTable>(), table).Result; var queryResult = connection.Query <CompleteTable>(result); // Assert Assert.AreEqual(1, connection.CountAll <CompleteTable>()); Assert.IsTrue(((dynamic)table).Id == Convert.ToInt64(result)); Helper.AssertMembersEquality(queryResult.First(), table); } }
public void TestMySqlConnectionForInsertForMySqlMapAttribute() { // Setup var table = CreateAttributeTables(1).First(); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act connection.Insert <AttributeTable>(table); // Assert Assert.AreEqual(1, connection.CountAll <AttributeTable>()); // Query var queryResult = connection.QueryAll <AttributeTable>().First(); // Assert Helper.AssertPropertiesEquality(table, queryResult); } }
public void TestSqlTransactionForMergeAsyncAsRolledBack() { // Setup var entity = Helper.CreateCompleteTables(1).First(); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Prepare var transaction = connection.EnsureOpen().BeginTransaction(); // Act connection.MergeAsync <CompleteTable>(entity, transaction: transaction).Wait(); // Act transaction.Rollback(); // Assert Assert.AreEqual(0, connection.CountAll <CompleteTable>()); } }
public void TestMySqlConnectionForInsertAllForMySqlMapAttribute() { // Setup var tables = CreateAttributeTables(10).AsList(); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act connection.InsertAll <AttributeTable>(tables); // Assert Assert.AreEqual(tables.Count, connection.CountAll <AttributeTable>()); // Query var queryResult = connection.QueryAll <AttributeTable>(); // Assert tables.ForEach(table => Helper.AssertPropertiesEquality(table, queryResult.First(e => e.Id == table.Id))); } }
public void TestSqlTransactionForInsertAsCommitted() { // Setup var entity = Helper.CreateCompleteTables(1).First(); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Prepare using (var transaction = connection.EnsureOpen().BeginTransaction()) { // Act connection.Insert <CompleteTable>(entity, transaction: transaction); // Act transaction.Commit(); } // Assert Assert.AreEqual(1, connection.CountAll <CompleteTable>()); } }
public void TestSqlTransactionForInsertAllAsRolledBack() { // Setup var entities = Helper.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Prepare using (var transaction = connection.EnsureOpen().BeginTransaction()) { // Act connection.InsertAll <CompleteTable>(entities, transaction: transaction); // Act transaction.Rollback(); } // Assert Assert.AreEqual(0, connection.CountAll <CompleteTable>()); } }
public void TestMySqlConnectionInsertAllForNonIdentity() { // Setup var tables = Helper.CreateNonIdentityCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.InsertAll <NonIdentityCompleteTable>(tables); // Assert Assert.AreEqual(tables.Count, connection.CountAll <NonIdentityCompleteTable>()); Assert.AreEqual(tables.Count, result); // Act var queryResult = connection.QueryAll <NonIdentityCompleteTable>(); // Assert tables.ForEach(table => Helper.AssertPropertiesEquality(table, queryResult.First(e => e.Id == table.Id))); } }
public void TestSqlTransactionForMergeAllAsyncAsCommitted() { // Setup var entities = Helper.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Prepare using (var transaction = connection.EnsureOpen().BeginTransaction()) { // Act connection.MergeAllAsync <CompleteTable>(entities, transaction: transaction).Wait(); // Act transaction.Commit(); } // Assert Assert.AreEqual(entities.Count, connection.CountAll <CompleteTable>()); } }
public void TestMySqlConnectionInsertForNonIdentity() { // Setup var table = Helper.CreateNonIdentityCompleteTables(1).First(); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.Insert <NonIdentityCompleteTable>(table); // Assert Assert.AreEqual(1, connection.CountAll <NonIdentityCompleteTable>()); Assert.AreEqual(table.Id, result); // Act var queryResult = connection.Query <NonIdentityCompleteTable>(result); // Assert Assert.AreEqual(1, queryResult?.Count()); Helper.AssertPropertiesEquality(table, queryResult.First()); } }
public void TestMySqlConnectionMergeAsyncAsDynamicViaTableNameForIdentityForEmptyTable() { // Setup var table = Helper.CreateCompleteTablesAsDynamics(1).First(); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.MergeAsync(ClassMappedNameCache.Get <CompleteTable>(), (object)table).Result; // Assert Assert.AreEqual(1, connection.CountAll <CompleteTable>()); Assert.IsTrue(Convert.ToInt64(result) > 0); // Act var queryResult = connection.Query <CompleteTable>(result); // Assert Helper.AssertPropertiesEquality(table, queryResult.First()); } }
public void TestMySqlConnectionInsertAllAsyncViaTableNameAsExpandoObjectsForNonIdentity() { // Setup var tables = Helper.CreateNonIdentityCompleteTablesAsExpandoObjects(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.InsertAllAsync(ClassMappedNameCache.Get <NonIdentityCompleteTable>(), tables).Result; // Assert Assert.AreEqual(tables.Count, connection.CountAll <NonIdentityCompleteTable>()); Assert.AreEqual(tables.Count, result); // Act var queryResult = connection.QueryAll <NonIdentityCompleteTable>(); // Assert tables.ForEach(table => Helper.AssertMembersEquality(queryResult.First(e => e.Id == ((dynamic)table).Id), table)); } }
public void TestMySqlConnectionInsertAllViaTableNameAsyncForIdentity() { // Setup var tables = Helper.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.InsertAllAsync(ClassMappedNameCache.Get <CompleteTable>(), tables).Result; // Assert Assert.AreEqual(tables.Count, connection.CountAll <CompleteTable>()); Assert.AreEqual(tables.Count, result); // Act var queryResult = connection.QueryAll <CompleteTable>(); // Assert tables.ForEach(table => Helper.AssertPropertiesEquality(table, queryResult.First(e => e.Id == table.Id))); } }
public void TestMySqlConnectionMergeAllAsyncForIdentityForEmptyTable() { // Setup var tables = Helper.CreateCompleteTables(10); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.MergeAllAsync <CompleteTable>(tables).Result; // Assert Assert.AreEqual(tables.Count, connection.CountAll <CompleteTable>()); Assert.AreEqual(tables.Count, result); // Act var queryResult = connection.QueryAll <CompleteTable>(); // Assert Assert.AreEqual(tables.Count, queryResult.Count()); tables.ForEach(table => Helper.AssertPropertiesEquality(table, queryResult.First(e => e.Id == table.Id))); } }
public void TestMySqlConnectionInsertAsyncForIdentity() { // Setup var table = Helper.CreateCompleteTables(1).First(); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.InsertAsync <CompleteTable>(table).Result; // Assert Assert.AreEqual(1, connection.CountAll <CompleteTable>()); Assert.IsTrue(Convert.ToInt64(result) > 0); Assert.IsTrue(table.Id > 0); // Act var queryResult = connection.Query <CompleteTable>(result); // Assert Assert.AreEqual(1, queryResult?.Count()); Helper.AssertPropertiesEquality(table, queryResult.First()); } }
public void TestMySqlConnectionInsertAsyncViaTableNameAsDynamicForNonIdentity() { // Setup var table = Helper.CreateNonIdentityCompleteTablesAsDynamics(1).First(); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.InsertAsync(ClassMappedNameCache.Get <NonIdentityCompleteTable>(), (object)table).Result; // Assert Assert.AreEqual(1, connection.CountAll <NonIdentityCompleteTable>()); Assert.AreEqual(table.Id, result); // Act var queryResult = connection.Query <NonIdentityCompleteTable>(result); // Assert Assert.AreEqual(1, queryResult?.Count()); Helper.AssertMembersEquality(queryResult.First(), table); } }
public void TestMySqlConnectionInsertViaTableNameAsExpandoObjectForNonIdentity() { // Setup var table = Helper.CreateNonIdentityCompleteTablesAsExpandoObjects(1).First(); using (var connection = new MySqlConnection(Database.ConnectionString)) { // Act var result = connection.Insert(ClassMappedNameCache.Get <NonIdentityCompleteTable>(), table); // Assert Assert.AreEqual(1, connection.CountAll <NonIdentityCompleteTable>()); Assert.IsTrue(Convert.ToInt64(result) > 0); // Act var queryResult = connection.Query <NonIdentityCompleteTable>(result); // Assert Assert.AreEqual(1, queryResult?.Count()); Helper.AssertMembersEquality(queryResult.First(), table); } }