Example #1
0
        public void TestPostgreSqlConnectionAverageAsyncWithHints()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new NpgsqlConnection(Database.ConnectionString))
            {
                // Act
                connection.AverageAsync <CompleteTable>(e => e.ColumnInteger,
                                                        (object)null,
                                                        hints: "WhatEver").Wait();
            }
        }
Example #2
0
        public void TestPostgreSqlConnectionAverageAsyncViaTableNameWithHints()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new NpgsqlConnection(Database.ConnectionString))
            {
                // Act
                connection.AverageAsync(ClassMappedNameCache.Get <CompleteTable>(),
                                        Field.Parse <CompleteTable>(e => e.ColumnInteger).First(),
                                        (object)null,
                                        hints: "WhatEver").Wait();
            }
        }
Example #3
0
        public void TestPostgreSqlConnectionAverageAsyncWithoutExpression()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new NpgsqlConnection(Database.ConnectionString))
            {
                // Act
                var result = connection.AverageAsync <CompleteTable>(e => e.ColumnInteger,
                                                                     (object)null).Result;

                // Assert
                Assert.AreEqual(tables.Average(e => e.ColumnInteger), Convert.ToDouble(result));
            }
        }
Example #4
0
        public void TestPostgreSqlConnectionAverageAsyncViaTableNameWithoutExpression()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new NpgsqlConnection(Database.ConnectionString))
            {
                // Act
                var result = connection.AverageAsync(ClassMappedNameCache.Get <CompleteTable>(),
                                                     Field.Parse <CompleteTable>(e => e.ColumnInteger).First(),
                                                     (object)null).Result;

                // Assert
                Assert.AreEqual(tables.Average(e => e.ColumnInteger), Convert.ToDouble(result));
            }
        }
Example #5
0
        public void TestPostgreSqlConnectionAverageAsyncWithExpression()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new NpgsqlConnection(Database.ConnectionString))
            {
                // Act
                var ids    = new[] { tables.First().Id, tables.Last().Id };
                var result = connection.AverageAsync <CompleteTable>(e => e.ColumnInteger,
                                                                     e => ids.Contains(e.Id)).Result;

                // Assert
                Assert.AreEqual(tables.Where(e => ids.Contains(e.Id)).Average(e => e.ColumnInteger), Convert.ToDouble(result));
            }
        }
Example #6
0
        public void TestPostgreSqlConnectionAverageAsyncViaTableNameWithExpression()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new NpgsqlConnection(Database.ConnectionString))
            {
                // Act
                var ids    = new[] { tables.First().Id, tables.Last().Id };
                var result = connection.AverageAsync(ClassMappedNameCache.Get <CompleteTable>(),
                                                     Field.Parse <CompleteTable>(e => e.ColumnInteger).First(),
                                                     new QueryField("Id", Operation.In, ids)).Result;

                // Assert
                Assert.AreEqual(tables.Where(e => ids.Contains(e.Id)).Average(e => e.ColumnInteger), Convert.ToDouble(result));
            }
        }