diff options
author | Daniel Morgan <monodanmorg@yahoo.com> | 2002-10-13 14:53:43 +0400 |
---|---|---|
committer | Daniel Morgan <monodanmorg@yahoo.com> | 2002-10-13 14:53:43 +0400 |
commit | 05d8ceb4d58168dea09da9513f952eae84a16163 (patch) | |
tree | f05d1f0ee2973400b349f043d6dfce2b37f86b80 /mcs/class | |
parent | 4c4c4cfa95fb902547a7449f0ea588a92b621479 (diff) |
2002-10-13 Daniel Morgan <danmorg@sc.rr.com>
* Test: added new directory to hold
tests for Mono.Data.SqliteClient
* Test/SqliteTest.cs: added file
to test Mono.Data.SqliteClient.
svn path=/trunk/mcs/; revision=8213
Diffstat (limited to 'mcs/class')
-rw-r--r-- | mcs/class/Mono.Data.SqliteClient/ChangeLog | 8 | ||||
-rw-r--r-- | mcs/class/Mono.Data.SqliteClient/Test/SqliteTest.cs | 90 |
2 files changed, 98 insertions, 0 deletions
diff --git a/mcs/class/Mono.Data.SqliteClient/ChangeLog b/mcs/class/Mono.Data.SqliteClient/ChangeLog index 348d9b782b6..91200b37b39 100644 --- a/mcs/class/Mono.Data.SqliteClient/ChangeLog +++ b/mcs/class/Mono.Data.SqliteClient/ChangeLog @@ -1,5 +1,13 @@ 2002-10-13 Daniel Morgan <danmorg@sc.rr.com> + * Test: added new directory to hold + tests for Mono.Data.SqliteClient + + * Test/SqliteTest.cs: added file + to test Mono.Data.SqliteClient. + +2002-10-13 Daniel Morgan <danmorg@sc.rr.com> + * Mono.Data.SqliteClient: add file to build on Windows diff --git a/mcs/class/Mono.Data.SqliteClient/Test/SqliteTest.cs b/mcs/class/Mono.Data.SqliteClient/Test/SqliteTest.cs new file mode 100644 index 00000000000..142da93ac93 --- /dev/null +++ b/mcs/class/Mono.Data.SqliteClient/Test/SqliteTest.cs @@ -0,0 +1,90 @@ +//
+// SqliteTest.cs - Test for the Sqlite ADO.NET Provider in Mono.Data.SqliteClient
+// This provider works on Linux and Windows and uses the native
+// sqlite.dll or sqlite.so library.
+//
+// Modify or add to this test as needed...
+//
+// SQL Lite can be downloaded from
+// http://www.hwaci.com/sw/sqlite/download.html
+//
+// There are binaries for Windows and Linux.
+//
+// To compile:
+// mcs SqliteTest.cs -r System.Data.dll -r Mono.Data.SqliteClient.dll
+//
+// Author:
+// Daniel Morgan <danmorg@sc.rr.com>
+//
+
+using System;
+using System.Data;
+using Mono.Data.SqliteClient;
+
+namespace Test.Mono.Data.SqliteClient
+{
+ class SqliteTest
+ {
+ [STAThread]
+ static void Main(string[] args)
+ {
+ Console.WriteLine("If this test works, you should get:");
+ Console.WriteLine("Data 1: 5");
+ Console.WriteLine("Data 2: Mono");
+
+ Console.WriteLine("create SqliteConnection...");
+ SqliteConnection dbcon = new SqliteConnection();
+
+ // the connection string is a URL that points
+ // to a file. If the file does not exist, a
+ // file is created.
+
+ // "URI=file:some/path"
+ string connectionString =
+ "URI=file:SqliteTest.db";
+ Console.WriteLine("setting ConnectionString using: " +
+ connectionString);
+ dbcon.ConnectionString = connectionString;
+
+ Console.WriteLine("open the connection...");
+ dbcon.Open();
+
+ Console.WriteLine("create SqliteCommand to CREATE TABLE MONO_TEST");
+ SqliteCommand dbcmd = new SqliteCommand();
+ dbcmd.Connection = dbcon;
+
+ dbcmd.CommandText =
+ "CREATE TABLE MONO_TEST ( " +
+ "NID INT, " +
+ "NDESC TEXT )";
+ Console.WriteLine("execute command...");
+ dbcmd.ExecuteNonQuery();
+
+ Console.WriteLine("set and execute command to INSERT INTO MONO_TEST");
+ dbcmd.CommandText =
+ "INSERT INTO MONO_TEST " +
+ "(NID, NDESC )"+
+ "VALUES(5,'Mono')";
+ dbcmd.ExecuteNonQuery();
+
+ Console.WriteLine("set command to SELECT FROM MONO_TEST");
+ dbcmd.CommandText =
+ "SELECT * FROM MONO_TEST";
+ SqliteDataReader reader;
+ Console.WriteLine("execute reader...");
+ reader = dbcmd.ExecuteReader();
+
+ Console.WriteLine("read and display data...");
+ while(reader.Read()) {
+ Console.WriteLine("Data 1: " + reader[0].ToString());
+ Console.WriteLine("Data 2: " + reader[1].ToString());
+ }
+ Console.WriteLine("clean up...");
+ reader.Close();
+ dbcmd.Dispose();
+ dbcon.Close();
+
+ Console.WriteLine("Done.");
+ }
+ }
+}
|