banshee r3864 - in trunk/banshee: . tests/Hyena
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3864 - in trunk/banshee: . tests/Hyena
- Date: Fri, 2 May 2008 20:39:37 +0100 (BST)
Author: gburt
Date: Fri May 2 19:39:37 2008
New Revision: 3864
URL: http://svn.gnome.org/viewvc/banshee?rev=3864&view=rev
Log:
2008-05-02 Gabriel Burt <gabriel burt gmail com>
* tests/Hyena/SqliteCommandTests.cs: Update to not use ApplyValues; fix
the build.
Modified:
trunk/banshee/ChangeLog
trunk/banshee/tests/Hyena/SqliteCommandTests.cs
Modified: trunk/banshee/tests/Hyena/SqliteCommandTests.cs
==============================================================================
--- trunk/banshee/tests/Hyena/SqliteCommandTests.cs (original)
+++ trunk/banshee/tests/Hyena/SqliteCommandTests.cs Fri May 2 19:39:37 2008
@@ -9,15 +9,16 @@
[Test]
public void TestIdentifiesParameters ()
{
- HyenaSqliteCommand cmd = new HyenaSqliteCommand ("select foo from bar where baz = ?, bbz = ?, this = ?");
-
+ HyenaSqliteCommand cmd = null;
try {
- cmd.ApplyValues ("a", 32);
+ cmd = new HyenaSqliteCommand ("select foo from bar where baz = ?, bbz = ?, this = ?",
+ "a", 32);
Assert.Fail ("Should not have been able to pass 2 values to ApplyValues without exception");
} catch {}
try {
- cmd.ApplyValues ("a", 32, "22");
+ cmd = new HyenaSqliteCommand ("select foo from bar where baz = ?, bbz = ?, this = ?",
+ "a", 32, "22");
} catch {
Assert.Fail ("Should have been able to pass 3 values to ApplyValues without exception");
}
@@ -44,25 +45,30 @@
{
HyenaSqliteCommand cmd = new HyenaSqliteCommand ("select foo from bar where baz = ?");
- Assert.AreEqual ("select foo from bar where baz = NULL", GetGeneratedSql (cmd.ApplyValues (null)));
- Assert.AreEqual ("select foo from bar where baz = 'It''s complicated, \"but\" ''''why not''''?'", GetGeneratedSql (cmd.ApplyValues ("It's complicated, \"but\" ''why not''?")));
- Assert.AreEqual ("select foo from bar where baz = 0", GetGeneratedSql (cmd.ApplyValues (new DateTime (1970, 1, 1).ToLocalTime ())));
- Assert.AreEqual ("select foo from bar where baz = 931309200", GetGeneratedSql (cmd.ApplyValues (new DateTime (1999, 7, 7).ToLocalTime ())));
- Assert.AreEqual ("select foo from bar where baz = 555.55", GetGeneratedSql (cmd.ApplyValues (555.55f)));
- Assert.AreEqual ("select foo from bar where baz = 555.55", GetGeneratedSql (cmd.ApplyValues (555.55)));
- Assert.AreEqual ("select foo from bar where baz = 555", GetGeneratedSql (cmd.ApplyValues (555)));
- Assert.AreEqual ("select foo from bar where baz = 1", GetGeneratedSql (cmd.ApplyValues (true)));
- Assert.AreEqual ("select foo from bar where baz = 0", GetGeneratedSql (cmd.ApplyValues (false)));
+ Assert.AreEqual ("select foo from bar where baz = NULL", GetGeneratedSql (cmd, null));
+ Assert.AreEqual ("select foo from bar where baz = 'It''s complicated, \"but\" ''''why not''''?'", GetGeneratedSql (cmd, "It's complicated, \"but\" ''why not''?"));
+ Assert.AreEqual ("select foo from bar where baz = 0", GetGeneratedSql (cmd, new DateTime (1970, 1, 1).ToLocalTime ()));
+ Assert.AreEqual ("select foo from bar where baz = 931309200", GetGeneratedSql (cmd, new DateTime (1999, 7, 7).ToLocalTime ()));
+ Assert.AreEqual ("select foo from bar where baz = 555.55", GetGeneratedSql (cmd, 555.55f));
+ Assert.AreEqual ("select foo from bar where baz = 555.55", GetGeneratedSql (cmd, 555.55));
+ Assert.AreEqual ("select foo from bar where baz = 555", GetGeneratedSql (cmd, 555));
+ Assert.AreEqual ("select foo from bar where baz = 1", GetGeneratedSql (cmd, true));
+ Assert.AreEqual ("select foo from bar where baz = 0", GetGeneratedSql (cmd, false));
HyenaSqliteCommand cmd2 = new HyenaSqliteCommand ("select foo from bar where baz = ?, bar = ?, boo = ?");
- Assert.AreEqual ("select foo from bar where baz = NULL, bar = NULL, boo = 22", GetGeneratedSql (cmd2.ApplyValues (null, null, 22)));
+ Assert.AreEqual ("select foo from bar where baz = NULL, bar = NULL, boo = 22", GetGeneratedSql (cmd2, null, null, 22));
HyenaSqliteCommand cmd3 = new HyenaSqliteCommand ("select foo from bar where id in (?) and foo not in (?)");
Assert.AreEqual ("select foo from bar where id in (1,2,4) and foo not in ('foo','baz')",
- GetGeneratedSql (cmd3.ApplyValues (new int [] {1, 2, 4}, new string [] {"foo", "baz"})));
+ GetGeneratedSql (cmd3, new int [] {1, 2, 4}, new string [] {"foo", "baz"}));
}
static PropertyInfo tf = typeof(HyenaSqliteCommand).GetProperty ("CurrentSqlText", BindingFlags.Instance | BindingFlags.NonPublic);
+ private static string GetGeneratedSql (HyenaSqliteCommand cmd, params object [] p)
+ {
+ return tf.GetValue ((new HyenaSqliteCommand (cmd.Text, p)), null) as string;
+ }
+
private static string GetGeneratedSql (HyenaSqliteCommand cmd)
{
return tf.GetValue (cmd, null) as string;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]