System.Data.SQLite
Check-in [3c8aa6ed17]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Enhancements to the 'testce' project that allow it to be automated.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3c8aa6ed1738b6ddb354f2fb1b06ab9289a4634c
User & Date: mistachkin 2012-10-09 03:26:22
Context
2012-10-09
08:45
Add automation capable of deploying and running the .NET Compact Framework test application. check-in: e791e34148 user: mistachkin tags: trunk
03:26
Enhancements to the 'testce' project that allow it to be automated. check-in: 3c8aa6ed17 user: mistachkin tags: trunk
2012-10-08
13:48
Enhancements to test suite infrastructure and comments. check-in: 34eb58d008 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to testce/Program.cs.

    16     16   {
    17     17     class Program
    18     18     {
    19     19       private static readonly string DefaultConnectionString =
    20     20           "Data Source={DataDirectory}\\test.db;Password=yVXL39etehPX;";
    21     21   
    22     22       [MTAThread]
    23         -    static void Main()
           23  +    static int Main(string[] args)
    24     24       {
           25  +      bool autoClose = false;
           26  +      int exitCode = 2; /* INCOMPLETE */
    25     27         Assembly assembly = Assembly.GetExecutingAssembly();
    26     28         AssemblyName assemblyName = assembly.GetName();
    27     29         string directory = Path.GetDirectoryName(assemblyName.CodeBase);
    28     30   
           31  +      if (args.Length > 0)
           32  +          autoClose = bool.Parse(args[0]);
           33  +
    29     34         try { File.Delete(directory + "\\test.db"); } catch { }
    30     35   
    31     36         SQLiteFunction.RegisterFunction(typeof(TestFunc));
    32     37         SQLiteFunction.RegisterFunction(typeof(MyCount));
    33     38         SQLiteFunction.RegisterFunction(typeof(MySequence));
    34     39   
    35     40         using (DbConnection cnn = new SQLiteConnection())
................................................................................
    68     73             //
    69     74             connectionString = connectionString.Replace(
    70     75               "{DataDirectory}", directory);
    71     76   
    72     77             cnn.ConnectionString = connectionString;
    73     78             cnn.Open();
    74     79   
    75         -          TestCases tests = new TestCases();
           80  +          TestCases tests = new TestCases(autoClose);
    76     81   
    77     82             tests.Run(cnn);
    78     83   
    79     84             Application.Run(tests.frm);
           85  +
           86  +          if (tests.Succeeded())
           87  +              exitCode = 0; /* SUCCESS */
           88  +          else
           89  +              exitCode = 1; /* FAILURE */
    80     90           }
    81     91         }
           92  +
           93  +      return exitCode;
    82     94       }
    83     95     }
    84     96   }

Changes to testce/TestCases.cs.

    67     67         if (param2 == "Field3") return -1;
    68     68         return String.Compare(param1, param2, true);
    69     69       }
    70     70     }
    71     71   
    72     72     internal class TestCases
    73     73     {
           74  +    private bool autoClose;
    74     75       internal Form1 frm;
           76  +    internal int total;
           77  +    internal int passed;
           78  +    internal int failed;
           79  +
           80  +    internal TestCases(bool autoExit)
           81  +    {
           82  +        this.autoClose = autoExit;
           83  +    }
           84  +
           85  +    internal bool Succeeded()
           86  +    {
           87  +        return (failed == 0) && (passed == total);
           88  +    }
    75     89   
    76     90       internal void Run(DbConnection cnn)
    77     91       {
    78     92         frm = new Form1();
    79     93   
    80     94         frm.Show();
    81     95   
................................................................................
    86    100         if (cnn2 != null)
    87    101         {
    88    102             cnn2 = null;
    89    103             frm.WriteLine("SQLite v" + SQLiteConnection.SQLiteVersion +
    90    104                 " [" + SQLiteConnection.SQLiteSourceId + "]");
    91    105         }
    92    106   
    93         -      try { CreateTable(cnn); frm.WriteLine("SUCCESS - CreateTable"); }
    94         -      catch (Exception) { frm.WriteLine("FAIL - CreateTable"); }
    95         -
    96         -      try { DataTypeTest(cnn); frm.WriteLine("SUCCESS - DataType Test"); }
    97         -      catch (Exception) { frm.WriteLine("FAIL - DataType Test"); }
    98         -
    99         -      try { FullTextTest(cnn); frm.WriteLine("SUCCESS - Full Text Search"); }
   100         -      catch (Exception) { frm.WriteLine("FAIL - Full Text Search"); }
   101         -
   102         -      try { KeyInfoTest(cnn); frm.WriteLine("SUCCESS - KeyInfo Fetch"); }
   103         -      catch (Exception) { frm.WriteLine("FAIL - KeyInfo Fetch"); }
   104         -
   105         -      try { InsertTable(cnn); frm.WriteLine("SUCCESS - InsertTable"); }
   106         -      catch (Exception) { frm.WriteLine("FAIL - InsertTable"); }
   107         -
   108         -      try { VerifyInsert(cnn); frm.WriteLine("SUCCESS - VerifyInsert"); }
   109         -      catch (Exception) { frm.WriteLine("FAIL - VerifyInsert"); }
   110         -
   111         -      try { CoersionTest(cnn); frm.WriteLine("FAIL - CoersionTest"); }
   112         -      catch (Exception) { frm.WriteLine("SUCCESS - CoersionTest"); }
   113         -
   114         -      try { ParameterizedInsert(cnn); frm.WriteLine("SUCCESS - ParameterizedInsert"); }
   115         -      catch (Exception) { frm.WriteLine("FAIL - ParameterizedInsert"); }
   116         -
   117         -      try { BinaryInsert(cnn); frm.WriteLine("SUCCESS - BinaryInsert"); }
   118         -      catch (Exception) { frm.WriteLine("FAIL - BinaryInsert"); }
   119         -
   120         -      try { VerifyBinaryData(cnn); frm.WriteLine("SUCCESS - VerifyBinaryData"); }
   121         -      catch (Exception) { frm.WriteLine("FAIL - VerifyBinaryData"); }
   122         -
   123         -      try { LockTest(cnn); frm.WriteLine("SUCCESS - LockTest"); }
   124         -      catch (Exception) { frm.WriteLine("FAIL - LockTest"); }
   125         -
   126         -      try { ParameterizedInsertMissingParams(cnn); frm.WriteLine("FAIL - ParameterizedInsertMissingParams"); }
   127         -      catch (Exception) { frm.WriteLine("SUCCESS - ParameterizedInsertMissingParams"); }
   128         -
   129         -      try { InsertMany(cnn, false); frm.WriteLine("SUCCESS - InsertMany"); }
   130         -      catch (Exception) { frm.WriteLine("FAIL - InsertMany"); }
   131         -
   132         -      try { InsertMany(cnn, true); frm.WriteLine("SUCCESS - InsertManyWithIdentityFetch"); }
   133         -      catch (Exception) { frm.WriteLine("FAIL - InsertManyWithIdentityFetch"); }
   134         -
   135         -      try { FastInsertMany(cnn); frm.WriteLine("SUCCESS - FastInsertMany"); }
   136         -      catch (Exception) { frm.WriteLine("FAIL - FastInsertMany"); }
   137         -
   138         -      try { IterationTest(cnn); frm.WriteLine("SUCCESS - Iteration Test"); }
   139         -      catch (Exception) { frm.WriteLine("FAIL - Iteration Test"); }
   140         -
   141         -      try { UserFunction(cnn); frm.WriteLine("SUCCESS - UserFunction"); }
   142         -      catch (Exception) { frm.WriteLine("FAIL - UserFunction"); }
   143         -
   144         -      try { UserAggregate(cnn); frm.WriteLine("SUCCESS - UserAggregate"); }
   145         -      catch (Exception) { frm.WriteLine("FAIL - UserAggregate"); }
   146         -
   147         -      try { UserCollation(cnn); frm.WriteLine("SUCCESS - UserCollation"); }
   148         -      catch (Exception) { frm.WriteLine("FAIL - UserCollation"); }
   149         -
   150         -      try { DropTable(cnn); frm.WriteLine("SUCCESS - DropTable"); }
   151         -      catch (Exception) { frm.WriteLine("FAIL - DropTable"); }
          107  +      total++;
          108  +      try { CreateTable(cnn); frm.WriteLine("SUCCESS - CreateTable"); passed++; }
          109  +      catch (Exception) { frm.WriteLine("FAIL - CreateTable"); failed++; }
          110  +
          111  +      total++;
          112  +      try { DataTypeTest(cnn); frm.WriteLine("SUCCESS - DataType Test"); passed++; }
          113  +      catch (Exception) { frm.WriteLine("FAIL - DataType Test"); failed++; }
          114  +
          115  +      total++;
          116  +      try { FullTextTest(cnn); frm.WriteLine("SUCCESS - Full Text Search"); passed++; }
          117  +      catch (Exception) { frm.WriteLine("FAIL - Full Text Search"); failed++; }
          118  +
          119  +      total++;
          120  +      try { KeyInfoTest(cnn); frm.WriteLine("SUCCESS - KeyInfo Fetch"); passed++; }
          121  +      catch (Exception) { frm.WriteLine("FAIL - KeyInfo Fetch"); failed++; }
          122  +
          123  +      total++;
          124  +      try { InsertTable(cnn); frm.WriteLine("SUCCESS - InsertTable"); passed++; }
          125  +      catch (Exception) { frm.WriteLine("FAIL - InsertTable"); failed++; }
          126  +
          127  +      total++;
          128  +      try { VerifyInsert(cnn); frm.WriteLine("SUCCESS - VerifyInsert"); passed++; }
          129  +      catch (Exception) { frm.WriteLine("FAIL - VerifyInsert"); failed++; }
          130  +
          131  +      total++;
          132  +      try { CoersionTest(cnn); frm.WriteLine("FAIL - CoersionTest"); failed++; }
          133  +      catch (Exception) { frm.WriteLine("SUCCESS - CoersionTest"); passed++; }
          134  +
          135  +      total++;
          136  +      try { ParameterizedInsert(cnn); frm.WriteLine("SUCCESS - ParameterizedInsert"); passed++; }
          137  +      catch (Exception) { frm.WriteLine("FAIL - ParameterizedInsert"); failed++; }
          138  +
          139  +      total++;
          140  +      try { BinaryInsert(cnn); frm.WriteLine("SUCCESS - BinaryInsert"); passed++; }
          141  +      catch (Exception) { frm.WriteLine("FAIL - BinaryInsert"); failed++; }
          142  +
          143  +      total++;
          144  +      try { VerifyBinaryData(cnn); frm.WriteLine("SUCCESS - VerifyBinaryData"); passed++; }
          145  +      catch (Exception) { frm.WriteLine("FAIL - VerifyBinaryData"); failed++; }
          146  +
          147  +      total++;
          148  +      try { LockTest(cnn); frm.WriteLine("SUCCESS - LockTest"); passed++; }
          149  +      catch (Exception) { frm.WriteLine("FAIL - LockTest"); failed++; }
          150  +
          151  +      total++;
          152  +      try { ParameterizedInsertMissingParams(cnn); frm.WriteLine("FAIL - ParameterizedInsertMissingParams"); failed++; }
          153  +      catch (Exception) { frm.WriteLine("SUCCESS - ParameterizedInsertMissingParams"); passed++; }
          154  +
          155  +      total++;
          156  +      try { InsertMany(cnn, false); frm.WriteLine("SUCCESS - InsertMany"); passed++; }
          157  +      catch (Exception) { frm.WriteLine("FAIL - InsertMany"); failed++; }
          158  +
          159  +      total++;
          160  +      try { InsertMany(cnn, true); frm.WriteLine("SUCCESS - InsertManyWithIdentityFetch"); passed++; }
          161  +      catch (Exception) { frm.WriteLine("FAIL - InsertManyWithIdentityFetch"); failed++; }
          162  +
          163  +      total++;
          164  +      try { FastInsertMany(cnn); frm.WriteLine("SUCCESS - FastInsertMany"); passed++; }
          165  +      catch (Exception) { frm.WriteLine("FAIL - FastInsertMany"); failed++; }
          166  +
          167  +      total++;
          168  +      try { IterationTest(cnn); frm.WriteLine("SUCCESS - Iteration Test"); passed++; }
          169  +      catch (Exception) { frm.WriteLine("FAIL - Iteration Test"); failed++; }
          170  +
          171  +      total++;
          172  +      try { UserFunction(cnn); frm.WriteLine("SUCCESS - UserFunction"); passed++; }
          173  +      catch (Exception) { frm.WriteLine("FAIL - UserFunction"); failed++; }
          174  +
          175  +      total++;
          176  +      try { UserAggregate(cnn); frm.WriteLine("SUCCESS - UserAggregate"); passed++; }
          177  +      catch (Exception) { frm.WriteLine("FAIL - UserAggregate"); failed++; }
          178  +
          179  +      total++;
          180  +      try { UserCollation(cnn); frm.WriteLine("SUCCESS - UserCollation"); passed++; }
          181  +      catch (Exception) { frm.WriteLine("FAIL - UserCollation"); failed++; }
          182  +
          183  +      total++;
          184  +      try { DropTable(cnn); frm.WriteLine("SUCCESS - DropTable"); passed++; }
          185  +      catch (Exception) { frm.WriteLine("FAIL - DropTable"); failed++; }
   152    186   
   153    187         frm.WriteLine("\r\nTests Finished.");
          188  +      frm.WriteLine(String.Format("\r\nCounts: {0} total, {1} passed, {2} failed", total, passed, failed));
          189  +      frm.WriteLine(String.Format("Result: {0}", Succeeded() ? "SUCCESS" : "FAILURE"));
          190  +
          191  +      if (autoClose)
          192  +          frm.Close();
   154    193       }
   155    194   
   156    195       internal static void KeyInfoTest(DbConnection cnn)
   157    196       {
   158    197         using (DbCommand cmd = cnn.CreateCommand())
   159    198         {
   160    199           // First test against integer primary key (optimized) keyinfo fetch