Esempio n. 1
0
        public void ExecuteQuerySingleOrDefault()
        {
            var query = new DbQuery("SELECT @parameter1 AS [Column]");

            DbAssert.AreEqual(new { Column = 1 }, connection => query.QuerySingleOrDefault(connection, new { parameter1 = 1 }));
        }
Esempio n. 2
0
        public void ExecuteQuerySingleThrowsOnNoRows()
        {
            var query = new DbQuery("SELECT @parameter1 AS [Column] WHERE 1 = 0");

            DbAssert.AreEqual(new { Column = 1 }, connection => query.QuerySingle(connection, new { parameter1 = 1 }));
        }
Esempio n. 3
0
        public void ExecuteQuerySingleThrowsOnTwoRows()
        {
            var query = new DbQuery("SELECT @parameter1 AS [Column] UNION SELECT @parameter2 AS [Column] ");

            DbAssert.AreEqual(new { Column = 1 }, connection => query.QuerySingle(connection, new { parameter1 = 1, parameter2 = 2 }));
        }
Esempio n. 4
0
        public void ExecuteQueryFirstOrDefaultReturnsFirstRowOnTwoRows()
        {
            var query = new DbQuery("SELECT @parameter1 AS [Column] UNION SELECT @parameter2 AS [Column] ");

            DbAssert.AreEqual(new { Column = 1 }, connection => query.QueryFirstOrDefault(connection, new { parameter1 = 1, parameter2 = 2 }));
        }
Esempio n. 5
0
        public void ExecuteQueryFirstOrDefaultReturnsDefaultOnNoRows()
        {
            var query = new DbQuery("SELECT @parameter1 AS [Column] WHERE 1 = 0");

            DbAssert.AreEqual(null, connection => query.QueryFirstOrDefault(connection, new { parameter1 = 1 }));
        }
Esempio n. 6
0
        public void ExecuteQuerySingleOrDefaultThrowsOnDuplicateColumnNames()
        {
            var query = new DbQuery("SELECT 1 AS [Column], 2 AS [Column]");

            DbAssert.AreEqual(1, connection => query.QueryFirst(connection));
        }
Esempio n. 7
0
        public void ExecuteQuerySingle()
        {
            var query = new DbQuery("SELECT @parameter1 AS [Column]");

            DbAssert.AreEqual(1, connection => query.QuerySingle <int>(connection, new { parameter1 = 1 }));
        }
Esempio n. 8
0
        public void ExecuteQueryFirstThrowsOnNoRows()
        {
            var query = new DbQuery("SELECT @parameter1 AS [Column] WHERE 1 = 0");

            DbAssert.AreEqual(1, connection => query.QueryFirst <int>(connection, new { parameter1 = 1 }));
        }