Пример #1
0
        public void TestPostgreSqlConnectionAverageWithHints()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new NpgsqlConnection(Database.ConnectionString))
            {
                // Act
                connection.Average <CompleteTable>(e => e.ColumnInteger,
                                                   (object)null,
                                                   hints: "WhatEver");
            }
        }
Пример #2
0
        public void TestPostgreSqlConnectionAverageViaTableNameWithHints()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

            using (var connection = new NpgsqlConnection(Database.ConnectionString))
            {
                // Act
                connection.Average(ClassMappedNameCache.Get <CompleteTable>(),
                                   Field.Parse <CompleteTable>(e => e.ColumnInteger).First(),
                                   (object)null,
                                   hints: "WhatEver");
            }
        }
Пример #3
0
        public void TestPostgreSqlConnectionAverageWithoutExpression()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

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

                // Assert
                Assert.AreEqual(tables.Average(e => e.ColumnInteger), Convert.ToDouble(result));
            }
        }
Пример #4
0
        public void TestPostgreSqlConnectionAverageWithExpression()
        {
            // 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.Average <CompleteTable>(e => e.ColumnInteger,
                                                                e => ids.Contains(e.Id));

                // Assert
                Assert.AreEqual(tables.Where(e => ids.Contains(e.Id)).Average(e => e.ColumnInteger), Convert.ToDouble(result));
            }
        }
Пример #5
0
        public void TestPostgreSqlConnectionAverageViaTableNameWithoutExpression()
        {
            // Setup
            var tables = Database.CreateCompleteTables(10);

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

                // Assert
                Assert.AreEqual(tables.Average(e => e.ColumnInteger), Convert.ToDouble(result));
            }
        }
Пример #6
0
        public void TestPostgreSqlConnectionAverageViaTableNameWithExpression()
        {
            // 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.Average(ClassMappedNameCache.Get <CompleteTable>(),
                                                Field.Parse <CompleteTable>(e => e.ColumnInteger).First(),
                                                new QueryField("Id", Operation.In, ids));

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