Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Further modularization work on the .NET Compact Framework test app. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
2f2b6577814dd719bed3d5a80f68aebe |
User & Date: | mistachkin 2013-05-09 23:02:53.404 |
Context
2013-05-16
| ||
09:37 | Update SQLite core library to the latest trunk code. check-in: 4bfa39c32e user: mistachkin tags: trunk | |
2013-05-09
| ||
23:02 | Further modularization work on the .NET Compact Framework test app. check-in: 2f2b657781 user: mistachkin tags: trunk | |
21:54 | Fix minor typo in previous commit. check-in: ef6282a18c user: mistachkin tags: trunk | |
Changes
Changes to testce/Program.cs.
︙ | ︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | namespace test { class Program { private static readonly string DefaultConnectionString = "Data Source={DataDirectory}\\test.db;Password=yVXL39etehPX;"; internal static DbConnection NewConnection() { return new SQLiteConnection(); } [MTAThread] static int Main(string[] args) { bool autoClose = false; int exitCode = 2; /* INCOMPLETE */ Assembly assembly = Assembly.GetExecutingAssembly(); AssemblyName assemblyName = assembly.GetName(); string directory = Path.GetDirectoryName(assemblyName.CodeBase); if (args.Length > 0) { try { autoClose = bool.Parse(args[0]); } catch { } } try { File.Delete(directory + "\\test.db"); } catch { } SQLiteFunction.RegisterFunction(typeof(TestFunc)); SQLiteFunction.RegisterFunction(typeof(MyCount)); SQLiteFunction.RegisterFunction(typeof(MySequence)); using (DbConnection cnn = NewConnection()) { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < < < < < < < < < < < < < < < < < | | | | < < < < < < < < < < < < < < < < < < | < | < < < < < < < < < | > | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | namespace test { class Program { private static readonly string DefaultConnectionString = "Data Source={DataDirectory}\\test.db;Password=yVXL39etehPX;"; /////////////////////////////////////////////////////////////////////// private static string GetConnectionString( string directory ) { string connectionString = DefaultConnectionString; try { // // NOTE: Attempt to open the configuration file associated with // this test executable. It should contain *EXACTLY* one // line, which will be the connection string to use for // this test run. // using (StreamReader streamReader = File.OpenText(Path.Combine( directory, "test.cfg"))) { connectionString = streamReader.ReadToEnd().Trim(); } } catch { // do nothing. } return connectionString; } /////////////////////////////////////////////////////////////////////// private static string GetInitializationSQL( string directory ) { string sql = null; try { // // NOTE: Attempt to open the SQL file associated with this test // executable. If present, it can contain SQL statements // to be executed against the new connection prior to the // tests running. // using (StreamReader streamReader = File.OpenText(Path.Combine( directory, "test.sql"))) { sql = streamReader.ReadToEnd().Trim(); } } catch { // do nothing. } return sql; } /////////////////////////////////////////////////////////////////////// internal static void ExecuteInitializationSQL( DbConnection connection, string sql, bool isolated ) { if (!String.IsNullOrEmpty(sql)) { if (isolated) { using (DbConnection newConnection = NewConnection()) { using (DbCommand command = newConnection.CreateCommand()) { command.CommandText = sql; /* IGNORED */ command.ExecuteNonQuery(); /* throw */ } } } else { if (connection == null) return; using (DbCommand command = connection.CreateCommand()) { command.CommandText = sql; /* IGNORED */ command.ExecuteNonQuery(); /* throw */ } } } } /////////////////////////////////////////////////////////////////////// internal static DbConnection NewConnection() { return new SQLiteConnection(); } /////////////////////////////////////////////////////////////////////// [MTAThread] static int Main(string[] args) { bool autoClose = false; bool isolatedSql = false; int exitCode = 2; /* INCOMPLETE */ Assembly assembly = Assembly.GetExecutingAssembly(); AssemblyName assemblyName = assembly.GetName(); string directory = Path.GetDirectoryName(assemblyName.CodeBase); if (args.Length > 0) { try { autoClose = bool.Parse(args[0]); } catch { } } if (args.Length > 1) { try { isolatedSql = bool.Parse(args[1]); } catch { } } try { File.Delete(directory + "\\test.db"); } catch { } SQLiteFunction.RegisterFunction(typeof(TestFunc)); SQLiteFunction.RegisterFunction(typeof(MyCount)); SQLiteFunction.RegisterFunction(typeof(MySequence)); using (DbConnection cnn = NewConnection()) { string connectionString = GetConnectionString(directory); // // NOTE: If we are unable to obtain a valid connection string // bail out now. // if (connectionString != null) { // // NOTE: Replace the "{DataDirectory}" token, if any, in // the connection string with the actual directory // this test assembly is executing from. // connectionString = connectionString.Replace( "{DataDirectory}", directory); cnn.ConnectionString = connectionString; cnn.Open(); string sql = GetInitializationSQL(directory); ExecuteInitializationSQL(cnn, sql, isolatedSql); TestCases tests = new TestCases( connectionString, cnn, sql, autoClose, isolatedSql); tests.Run(); Application.Run(tests.frm); if (tests.Succeeded()) exitCode = 0; /* SUCCESS */ |
︙ | ︙ |
Changes to testce/TestCases.cs.
︙ | ︙ | |||
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | { internal Form1 frm; private string connectionString; private DbConnection cnn; private string sql; private bool autoClose; private int total; private int passed; private int failed; internal TestCases( string connectionString, DbConnection cnn, string sql, | > | > > | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | { internal Form1 frm; private string connectionString; private DbConnection cnn; private string sql; private bool autoClose; private bool isolatedSql; private int total; private int passed; private int failed; internal TestCases( string connectionString, DbConnection cnn, string sql, bool autoExit, bool isolatedSql ) { this.connectionString = connectionString; this.cnn = cnn; this.sql = sql; this.autoClose = autoExit; this.isolatedSql = isolatedSql; } internal bool Succeeded() { return (failed == 0) && (passed == total); } |
︙ | ︙ | |||
173 174 175 176 177 178 179 | catch (Exception) { frm.WriteLine("FAIL - BinaryInsert"); failed++; } total++; try { VerifyBinaryData(cnn); frm.WriteLine("SUCCESS - VerifyBinaryData"); passed++; } catch (Exception) { frm.WriteLine("FAIL - VerifyBinaryData"); failed++; } total++; | | | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | catch (Exception) { frm.WriteLine("FAIL - BinaryInsert"); failed++; } total++; try { VerifyBinaryData(cnn); frm.WriteLine("SUCCESS - VerifyBinaryData"); passed++; } catch (Exception) { frm.WriteLine("FAIL - VerifyBinaryData"); failed++; } total++; try { LockTest(cnn, sql, isolatedSql); frm.WriteLine("SUCCESS - LockTest"); passed++; } catch (Exception) { frm.WriteLine("FAIL - LockTest"); failed++; } total++; try { ParameterizedInsertMissingParams(cnn); frm.WriteLine("FAIL - ParameterizedInsertMissingParams"); failed++; } catch (Exception) { frm.WriteLine("SUCCESS - ParameterizedInsertMissingParams"); passed++; } total++; |
︙ | ︙ | |||
602 603 604 605 606 607 608 | if (b[1000] != 3) throw new ArgumentException(); if (b[2000] != 4) throw new ArgumentException(); if (b[3000] != 5) throw new ArgumentException(); } } } | | < < < < < | < < < < | 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | if (b[1000] != 3) throw new ArgumentException(); if (b[2000] != 4) throw new ArgumentException(); if (b[3000] != 5) throw new ArgumentException(); } } } internal static void LockTest(DbConnection cnn, string sql, bool isolatedSql) { using (DbCommand cmd = cnn.CreateCommand()) { cmd.CommandText = "SELECT Field6 FROM TestCase WHERE Field6 IS NOT NULL"; byte[] b = new byte[4000]; using (DbDataReader rd = cmd.ExecuteReader()) { if (rd.Read() == false) throw new ArgumentOutOfRangeException(); rd.GetBytes(0, 0, b, 0, 4000); if (b[0] != 1) throw new ArgumentException(); if (b[100] != 2) throw new ArgumentException(); if (b[1000] != 3) throw new ArgumentException(); if (b[2000] != 4) throw new ArgumentException(); if (b[3000] != 5) throw new ArgumentException(); using (DbConnection clone = (DbConnection)((ICloneable)cnn).Clone()) { Program.ExecuteInitializationSQL(clone, sql, isolatedSql); using (DbCommand newcmd = clone.CreateCommand()) { newcmd.CommandText = "DELETE FROM TestCase WHERE Field6 IS NULL"; newcmd.CommandTimeout = 2; int cmdStart = Environment.TickCount; int cmdEnd; |
︙ | ︙ |