Exemplo n.º 1
0
        public void DbQueryWaitStepOk()
        {
            var step = new DbQueryStep();

            step.ConnectionString     = "Data Source=.\\btsloc;Initial Catalog=BizUnitDb;Integrated Security=True";
            step.SQLQuery             = new SqlQueryExtended();
            step.SQLQuery.RawSqlQuery = "CREATE TABLE dbo.Test ( Value int NOT NULL ); INSERT INTO dbo.Test Values (1);";
            step.NumberOfRowsExpected = 0;
            step.Execute(new Context());

            var target = new DbQueryWaitStep();

            target.ConnectionString         = "Data Source=.\\btsloc;Initial Catalog=BizUnitDb;Integrated Security=True";
            target.DelayBeforeCheck         = 1;
            target.Timeout                  = 50000;
            target.SQLQuery                 = new SqlQueryExtended();
            target.SQLQuery.RawSqlQuery     = "SELECT * FROM dbo.Test WHERE Value = {0}";
            target.SQLQuery.QueryParameters = new Collection <object>();
            target.SQLQuery.QueryParameters.Add(1);
            target.NumberOfRowsExpected = 1;

            try
            {
                target.Execute(new Context());
            }
            finally
            {
                step.SQLQuery.RawSqlQuery = "DROP TABLE dbo.Test;";
                step.NumberOfRowsExpected = 0;
                step.Execute(new Context());
            }
        }
Exemplo n.º 2
0
        public void DbQueryWaitStepNok()
        {
            var step = new DbQueryStep();

            step.ConnectionString     = "Data Source=.\\btsloc;Initial Catalog=BizUnitDb;Integrated Security=True";
            step.SQLQuery             = new SqlQueryExtended();
            step.SQLQuery.RawSqlQuery = "CREATE TABLE dbo.Test ( Value int NOT NULL ); INSERT INTO dbo.Test Values (1);";
            step.NumberOfRowsExpected = 0;
            step.Execute(new Context());

            var target = new DbQueryWaitStep();

            target.ConnectionString         = "Data Source=.\\btsloc;Initial Catalog=BizUnitDb;Integrated Security=True";
            target.DelayBeforeCheck         = 1;
            target.Timeout                  = 5000;
            target.SQLQuery                 = new SqlQueryExtended();
            target.SQLQuery.RawSqlQuery     = "SELECT * FROM dbo.Test WHERE Value = {0}";
            target.SQLQuery.QueryParameters = new Collection <object>();
            target.SQLQuery.QueryParameters.Add(1);
            target.NumberOfRowsExpected = 2;

            try
            {
                target.Execute(new Context());
                throw new AssertFailedException("Wait succeeded");
            }
            catch (Exception ex)
            {
                testContextInstance.WriteLine("Found exception: {0}", ex.GetType());
            }
            finally
            {
                step.SQLQuery.RawSqlQuery = "DROP TABLE dbo.Test;";
                step.NumberOfRowsExpected = 0;
                step.Execute(new Context());
            }
        }