Пример #1
0
        public void Execute_Integer_ScalarReturned()
        {
            SqlClient           session       = new SqlClientFactory().Instantiate(ConnectionStringReader.GetLocaleSql()) as SqlClient;
            var                 statement     = Mock.Of <IQuery>(x => x.Statement == "SELECT VALUE count(1) FROM FoF f WHERE f.label='person'");
            SqlCommandOperation cosmosdbQuery = new SqlCommandFactory().Instantiate(session, statement).Implementation as SqlCommandOperation;

            var engine = new SqlExecutionEngine(session.CreateClientOperation(), cosmosdbQuery);

            var age = engine.ExecuteScalar();

            Assert.That(age, Is.EqualTo(4));
        }
Пример #2
0
        public void Execute_NullString_ScalarReturned()
        {
            SqlClient           session       = new SqlClientFactory().Instantiate(ConnectionStringReader.GetLocaleSql()) as SqlClient;
            var                 statement     = Mock.Of <IQuery>(x => x.Statement == "SELECT VALUE p.lastName[0]._value FROM ROOT p WHERE p.label = 'person' and p.firstName[0]._value = 'Thomas'");
            SqlCommandOperation cosmosdbQuery = new SqlCommandFactory().Instantiate(session, statement).Implementation as SqlCommandOperation;

            var engine = new SqlExecutionEngine(session.CreateClientOperation(), cosmosdbQuery);

            var count = engine.ExecuteScalar();

            Assert.That(count, Is.Null);
        }
Пример #3
0
        public void ExecuteScalar_ValidQuery_DataSetFilled()
        {
            var query = "select top(1) CurrencyCode from [Sales].[Currency] where Name like '%Canad%'";
            var cmd   = new SqlCommand(query, new SqlConnection(ConnectionStringReader.GetSqlClient()))
            {
                CommandTimeout = 0
            };

            var qe    = new SqlExecutionEngine(cmd.Connection, cmd);
            var value = qe.ExecuteScalar();

            Assert.That(value, Is.EqualTo("CAD"));
        }