public void GetExecutorByWalkingTheStack_NonExistingName_ThrowsInvalidOperationException()
        {
            var finder   = new ConnectionExecutorFinder("Non_Existing_Name");
            var executor = finder.GetExecutorByWalkingTheStack();

            Console.WriteLine(executor);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes and returns an executable asserion based on the given
        /// sql. This sql will be executed as is, so no further accumulative
        /// build up is available here.
        /// </summary>
        /// <param name="sql">The SQL.</param>
        /// <returns>The executable assertion</returns>
        public static IExecutableAssertion WithSql(string sql)
        {
            var assertion = new SqlBasedAccumulativeAssertion(ConnectionExecutorFinder.GetSqlExecutor(null));

            assertion.SetSql(sql);
            return(assertion);
        }
        public void GetExecutorByWalkingTheStack_NotNamedInFinder_FindsDirectlyOnMethod()
        {
            var finder   = new ConnectionExecutorFinder(null);
            var executor = finder.GetExecutorByWalkingTheStack();

            Assert.IsTrue(executor is SqlServerProvider);
            Assert.AreEqual("K3", executor.ConnectionString);
        }
        public void GetExecutorByWalkingTheStack_NamedFromClass_IgnoresMethodAndGetsFromClass()
        {
            var finder   = new ConnectionExecutorFinder("OnClass");
            var executor = finder.GetExecutorByWalkingTheStack();

            Assert.IsTrue(executor is OracleProvider);
            Assert.AreEqual("K1", executor.ConnectionString);
        }
        public void GetExecutorByWalkingTheStack_NonNamed_FindsTheClassConnection()
        {
            var finder   = new ConnectionExecutorFinder(null);
            var executor = finder.GetExecutorByWalkingTheStack();

            Assert.IsTrue(executor is OracleProvider);
            Assert.AreEqual("K1", executor.ConnectionString);
        }
Esempio n. 6
0
        public void GetSqlExecutor()
        {
            var provider = ConnectionExecutorFinder.GetSqlExecutor("CAB");

            ////var mi = typeof (ConnectionExecutorFinderTests).GetMethod("GetSqlExecutor",
            ////    BindingFlags.Instance | BindingFlags.Public);
            //var mi = typeof(ConnectionExecutorFinderTests).GetMethod("GetSqlExecutor");

            //var attrib = Attribute.GetCustomAttributes(mi, typeof(AbstractConnectionAttribute));
        }
Esempio n. 7
0
        /// <summary>
        /// Commits the accumulative session, i.e. performs the actual
        /// changes in the database
        /// </summary>
        public void Commit()
        {
            var sqlExecutor = ConnectionExecutorFinder.GetSqlExecutor(connectionKey);

            // First, delete the rows from back to front
            for (int i = batches.Count - 1; i >= 0; i--)
            {
                batches[i].DoDelete(sqlExecutor);
            }

            // Then, insert the rows from front to back
            foreach (var batch in batches)
            {
                batch.DoWrite(sqlExecutor);
            }
        }
Esempio n. 8
0
 public void SetUp()
 {
     mocks = new MockRepository();
     ConnectionExecutorFinder.Reset();
 }
Esempio n. 9
0
 /// <summary>
 /// Returns a value query ready for further build up and then execution
 /// </summary>
 /// <param name="tableName"></param>
 /// <returns></returns>
 public static IValueQuery QueryForTable(string tableName)
 {
     return(new ValueQuery(tableName, ConnectionExecutorFinder.GetSqlExecutor(null)));
 }
Esempio n. 10
0
 /// <summary>
 /// Executes the non query (== a query without return resuts) directly
 /// against the database at once.
 /// </summary>
 /// <param name="sqlStatement">The SQL statement.</param>
 public static void ExecuteNonQuery(string sqlStatement, string connectionKey)
 {
     ConnectionExecutorFinder.GetSqlExecutor(connectionKey).ExecuteNonQuery(sqlStatement);
 }
Esempio n. 11
0
 /// <summary>
 /// Executes the non query (== a query without return resuts) directly
 /// against the database at once.
 /// </summary>
 /// <param name="sqlStatement">The SQL statement.</param>
 public static void ExecuteNonQuery(string sqlStatement)
 {
     ConnectionExecutorFinder.GetSqlExecutor(null).ExecuteNonQuery(sqlStatement);
 }
Esempio n. 12
0
        /// <summary>
        /// Returns an accumultaive adversary which is designed to
        /// receive further information identifying the concrete
        /// row to tamper with
        /// </summary>
        /// <param name="tableName">Name of the table.</param>
        /// <returns></returns>
        public IAccumulativeAdversary ForTable(string tableName)
        {
            var executor = ConnectionExecutorFinder.GetSqlExecutor(connectionKey);

            return(new ExecutableAdversary(executor, tableName));
        }
Esempio n. 13
0
 /// <summary>
 /// Initializes and returns an accumulative assertion where the name of the
 /// database table which the select will go against is set.
 /// </summary>
 /// <param name="tableName">Name of the table.</param>
 /// <returns>An accumulative assertion ready for further build up</returns>
 public IAccumulativeAssertion ForTable(string tableName)
 {
     return(new AccumulativeAssertion(ConnectionExecutorFinder.GetSqlExecutor(connectionName), tableName));
 }