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); }
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); }