public void TestBasicOperations()
{
SqlConnectionUtilities.XSafeCommand(_connDesc,
"CREATE TABLE TestTable (field1 int, field2 varchar(100))", null);
SqlConnectionUtilities.XSafeCommand(_connDesc,
"INSERT INTO TestTable VALUES (1, 'hi')", null);
SqlConnectionUtilities.XSafeCommand(_connDesc,
"INSERT INTO TestTable VALUES (99, 'longer string')", null);
Assert.AreEqual(2, SqlConnectionUtilities.XSafeIntQuery(_connDesc,
"SELECT COUNT(*) FROM TestTable", null), "Should have inserted two records.");
ArrayList sqlParams = new ArrayList();
sqlParams.Add("hi");
Assert.AreEqual(1, SqlConnectionUtilities.XSafeCommand(_connDesc,
"DELETE FROM TestTable WHERE field2 = ?", sqlParams),
"Should have deleted one record.");
Assert.AreEqual(0, SqlConnectionUtilities.XSafeCommand(_connDesc,
"DELETE FROM TestTable WHERE field2 = ?", sqlParams),
"Record is already gone, should delete none this time.");
// Give it a moment to finish the updates.
Thread.Sleep(2000);
SqlConnectionUtilities.XSafeCommand(_connDesc,
"DROP TABLE TestTable", null);
}