예제 #1
0
        public void TestQueryDataTableWithParameter()
        {
            //arrange
            bool expect = true;
            bool actual = true;
            IDatabaseAccess target = new SqlClientDataAccess(this._ConnectionString);
            DataTable result;
            DataAccessCommand command = new DataAccessCommand();

            //act
            command.SqlCommand =
            @"SELECT *
              FROM tableName
             WHERE columanName=@Value";
            command.AddParameter("Value", "value");
            result = target.QueryWithDataTable(command);
            actual = (result != null);

            //assert
            Assert.AreEqual(expect, actual);
        }
예제 #2
0
        public void TestQueryDataTableException()
        {
            //arrange
            bool expect = true;
            bool actual = true;
            IDatabaseAccess target = new SqlClientDataAccess(this._ConnectionString);
            DataTable result;
            DataAccessCommand command = new DataAccessCommand();
            string errMessage = "";

            //act
            command.SqlCommand =
            @"SELECT *
              FROM tableName
             WHERE columanName=@Value";
            command.AddParameter("Value", "value");

            try
            {
                result = target.QueryWithDataTable(command);
            }
            catch (CommandExecutionExeception ex)
            {
                errMessage = ex.DetailErrorMessage;
                actual = (errMessage != "");
            }

            //assert
            Assert.AreEqual(expect, actual);
        }