예제 #1
0
파일: CountTest.cs 프로젝트: say25/RepoDb
        public void ThrowExceptionOnMySqlConnectionCountAsyncWithHints()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new MySqlConnection(Database.ConnectionString))
            {
                // Act
                connection.CountAsync <CompleteTable>((object)null,
                                                      hints: "WhatEver").Wait();
            }
        }
예제 #2
0
 public void TestSqlTransactionForCountAsync()
 {
     using (var connection = new MySqlConnection(Database.ConnectionString))
     {
         // Prepare
         using (var transaction = connection.EnsureOpen().BeginTransaction())
         {
             // Act
             connection.CountAsync <CompleteTable>(it => it.Id != 0, transaction: transaction).Wait();
         }
     }
 }
예제 #3
0
파일: CountTest.cs 프로젝트: say25/RepoDb
        public void ThrowExceptionOnMySqlConnectionCountAsyncViaTableNameWithHints()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new MySqlConnection(Database.ConnectionString))
            {
                // Act
                connection.CountAsync(ClassMappedNameCache.Get <CompleteTable>(),
                                      (object)null,
                                      hints: "WhatEver").Wait();
            }
        }
예제 #4
0
파일: CountTest.cs 프로젝트: say25/RepoDb
        public void TestMySqlConnectionCountAsyncViaQueryField()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new MySqlConnection(Database.ConnectionString))
            {
                // Act
                var result = connection.CountAsync <CompleteTable>(new QueryField("Id", tables.First().Id)).Result;

                // Assert
                Assert.AreEqual(tables.Where(e => e.Id == tables.First().Id).Count(), result);
            }
        }
예제 #5
0
파일: CountTest.cs 프로젝트: say25/RepoDb
        public void TestMySqlConnectionCountAsyncWithoutExpression()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new MySqlConnection(Database.ConnectionString))
            {
                // Act
                var result = connection.CountAsync <CompleteTable>((object)null).Result;

                // Assert
                Assert.AreEqual(tables.Count(), result);
            }
        }
예제 #6
0
파일: CountTest.cs 프로젝트: say25/RepoDb
        public void TestMySqlConnectionCountAsyncViaTableNameViaDynamic()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new MySqlConnection(Database.ConnectionString))
            {
                // Act
                var result = connection.CountAsync(ClassMappedNameCache.Get <CompleteTable>(),
                                                   new { tables.First().Id }).Result;

                // Assert
                Assert.AreEqual(tables.Where(e => e.Id == tables.First().Id).Count(), result);
            }
        }
예제 #7
0
파일: CountTest.cs 프로젝트: say25/RepoDb
        public void TestMySqlConnectionCountAsyncViaExpression()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);
            var ids    = new[] { tables.First().Id, tables.Last().Id };

            using (var connection = new MySqlConnection(Database.ConnectionString))
            {
                // Act
                var result = connection.CountAsync <CompleteTable>(e => ids.Contains(e.Id)).Result;

                // Assert
                Assert.AreEqual(tables.Where(e => ids.Contains(e.Id)).Count(), result);
            }
        }
예제 #8
0
파일: CountTest.cs 프로젝트: say25/RepoDb
        public void TestMySqlConnectionCountAsyncViaQueryFields()
        {
            // Setup
            var tables      = Database.CreateCompleteTables(10);
            var queryFields = new[]
            {
                new QueryField("Id", Operation.GreaterThan, tables.First().Id),
                new QueryField("Id", Operation.LessThan, tables.Last().Id)
            };

            using (var connection = new MySqlConnection(Database.ConnectionString))
            {
                // Act
                var result = connection.CountAsync <CompleteTable>(queryFields).Result;

                // Assert
                Assert.AreEqual(tables.Where(e => e.Id > tables.First().Id&& e.Id < tables.Last().Id).Count(), result);
            }
        }