public SnowflakeDbCommand(SnowflakeDbConnection connection)
 {
     this.connection  = connection;
     this.sfStatement = new SFStatement(connection.sfSession);
     // by default, no query timeout
     this.CommandTimeout = 0;
     parameterCollection = new SnowflakeDbParameterCollection();
 }
 public SnowflakeDbCommand(SnowflakeDbConnection connection)
 {
     logger.Debug("Constucting SnowflakeDbCommand class");
     this.connection  = connection;
     this.sfStatement = new SFStatement(connection.SfSession);
     // by default, no query timeout
     this.CommandTimeout = 0;
     parameterCollection = new SnowflakeDbParameterCollection();
 }
        public void TestSessionRenewDuringQueryExec()
        {
            Mock.MockRestSessionExpiredInQueryExec restRequester = new Mock.MockRestSessionExpiredInQueryExec();
            SFSession sfSession = new SFSession("account=test;user=test;password=test", null, restRequester);

            sfSession.Open();
            SFStatement     statement = new SFStatement(sfSession, restRequester);
            SFBaseResultSet resultSet = statement.Execute(0, "select 1", null, false);

            Assert.AreEqual(true, resultSet.Next());
            Assert.AreEqual("1", resultSet.GetString(0));
        }
        public void TestSessionRenew()
        {
            Mock.MockRestSessionExpired restRequester = new Mock.MockRestSessionExpired();
            SFSession sfSession = new SFSession("account=test;user=test;password=test", null, restRequester);

            sfSession.Open();
            SFStatement     statement = new SFStatement(sfSession, restRequester);
            SFBaseResultSet resultSet = statement.Execute(0, "select 1", null, false);

            Assert.AreEqual(true, resultSet.Next());
            Assert.AreEqual("1", resultSet.GetString(0));
            Assert.AreEqual("new_session_token", sfSession.sessionToken);
            Assert.AreEqual("new_master_token", sfSession.masterToken);
        }
        public void TestServiceName()
        {
            var       restRequester = new Mock.MockServiceName();
            SFSession sfSession     = new SFSession("account=test;user=test;password=test", null, restRequester);

            sfSession.Open();
            string expectServiceName = Mock.MockServiceName.INIT_SERVICE_NAME;

            Assert.AreEqual(expectServiceName, sfSession.ParameterMap[SFSessionParameter.SERVICE_NAME]);
            for (int i = 0; i < 5; i++)
            {
                SFStatement     statement = new SFStatement(sfSession, restRequester);
                SFBaseResultSet resultSet = statement.Execute(0, "SELECT 1", null, false);
                expectServiceName += "a";
                Assert.AreEqual(expectServiceName, sfSession.ParameterMap[SFSessionParameter.SERVICE_NAME]);
            }
        }