System.Data.SQLite

Check-in [a30dcc34b3]
Login

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

Overview
Comment:Added a new test
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | sourceforge
Files: files | file ages | folders
SHA1: a30dcc34b396b31414dac32000d553349424b54a
User & Date: rmsimpson 2005-08-04 22:53:38.000
Context
2005-08-05
05:55
1.0.12 final check-in: d684aaadfe user: rmsimpson tags: sourceforge
2005-08-04
22:53
Added a new test check-in: a30dcc34b3 user: rmsimpson tags: sourceforge
22:51
More 1.0.12 updates check-in: 22eb57fb2c user: rmsimpson tags: sourceforge
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/TestCases.cs.
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

      try { CoersionTest(cnn); Console.WriteLine("FAIL - CoersionTest"); }
      catch (Exception) { Console.WriteLine("SUCCESS - CoersionTest"); }

      try { ParameterizedInsert(cnn); Console.WriteLine("SUCCESS - ParameterizedInsert"); }
      catch (Exception) { Console.WriteLine("FAIL - ParameterizedInsert"); }

      try { BinaryInsert(cnn); Console.WriteLine("SUCCESS - BinaryInsert"); }
      catch (Exception) { Console.WriteLine("FAIL - BinaryInsert"); }

      try { VerifyBinaryData(cnn); Console.WriteLine("SUCCESS - VerifyBinaryData"); }
      catch (Exception) { Console.WriteLine("FAIL - VerifyBinaryData"); }

      try { ParameterizedInsertMissingParams(cnn); Console.WriteLine("FAIL - ParameterizedInsertMissingParams"); }
      catch (Exception) { Console.WriteLine("SUCCESS - ParameterizedInsertMissingParams"); }

      try { TimeoutTest(cnn); Console.WriteLine("SUCCESS - TimeoutTest"); }
      catch (Exception) { Console.WriteLine("FAIL - TimeoutTest"); }

      try { InsertMany(fact, cnn, false); Console.WriteLine("SUCCESS - InsertMany"); }
      catch (Exception) { Console.WriteLine("FAIL - InsertMany"); }

      try { InsertMany(fact, cnn, true); Console.WriteLine("SUCCESS - InsertManyWithIdentityFetch"); }
      catch (Exception) { Console.WriteLine("FAIL - InsertManyWithIdentityFetch"); }




      try { IterationTest(cnn); Console.WriteLine("SUCCESS - Iteration Test"); }
      catch (Exception) { Console.WriteLine("FAIL - Iteration Test"); }

      try { UserFunction(cnn); Console.WriteLine("SUCCESS - UserFunction"); }
      catch (Exception) { Console.WriteLine("FAIL - UserFunction"); }








|
















>
>
>







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

      try { CoersionTest(cnn); Console.WriteLine("FAIL - CoersionTest"); }
      catch (Exception) { Console.WriteLine("SUCCESS - CoersionTest"); }

      try { ParameterizedInsert(cnn); Console.WriteLine("SUCCESS - ParameterizedInsert"); }
      catch (Exception) { Console.WriteLine("FAIL - ParameterizedInsert"); }

      try { BinaryInsert(cnn); Console.WriteLine("SUCCESS - BinaryInsert (using named parameter)"); }
      catch (Exception) { Console.WriteLine("FAIL - BinaryInsert"); }

      try { VerifyBinaryData(cnn); Console.WriteLine("SUCCESS - VerifyBinaryData"); }
      catch (Exception) { Console.WriteLine("FAIL - VerifyBinaryData"); }

      try { ParameterizedInsertMissingParams(cnn); Console.WriteLine("FAIL - ParameterizedInsertMissingParams"); }
      catch (Exception) { Console.WriteLine("SUCCESS - ParameterizedInsertMissingParams"); }

      try { TimeoutTest(cnn); Console.WriteLine("SUCCESS - TimeoutTest"); }
      catch (Exception) { Console.WriteLine("FAIL - TimeoutTest"); }

      try { InsertMany(fact, cnn, false); Console.WriteLine("SUCCESS - InsertMany"); }
      catch (Exception) { Console.WriteLine("FAIL - InsertMany"); }

      try { InsertMany(fact, cnn, true); Console.WriteLine("SUCCESS - InsertManyWithIdentityFetch"); }
      catch (Exception) { Console.WriteLine("FAIL - InsertManyWithIdentityFetch"); }

      try { SimpleInsertMany(cnn); Console.WriteLine("SUCCESS - SimpleInsertMany"); }
      catch (Exception) { Console.WriteLine("FAIL - SimpleInsertMany"); }

      try { IterationTest(cnn); Console.WriteLine("SUCCESS - Iteration Test"); }
      catch (Exception) { Console.WriteLine("FAIL - Iteration Test"); }

      try { UserFunction(cnn); Console.WriteLine("SUCCESS - UserFunction"); }
      catch (Exception) { Console.WriteLine("FAIL - UserFunction"); }

239
240
241
242
243
244
245
246
247


248
249
250
251
252
253
254
255

256
257
258
259
260
261
262
263
264
265
266
      }
    }

    internal static void BinaryInsert(DbConnection cnn)
    {
      using (DbCommand cmd = cnn.CreateCommand())
      {
        cmd.CommandText = "INSERT INTO TestCase(Field6) VALUES(?)";
        DbParameter Field6 = cmd.CreateParameter();



        byte[] b = new byte[4000];
        b[0] = 1;
        b[100] = 2;
        b[1000] = 3;
        b[2000] = 4;
        b[3000] = 5;


        Field6.Value = b;

        cmd.Parameters.Add(Field6);

        cmd.ExecuteNonQuery();
      }
    }

    internal static void VerifyBinaryData(DbConnection cnn)
    {
      using (DbCommand cmd = cnn.CreateCommand())







|

>
>








>


<
<







242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263


264
265
266
267
268
269
270
      }
    }

    internal static void BinaryInsert(DbConnection cnn)
    {
      using (DbCommand cmd = cnn.CreateCommand())
      {
        cmd.CommandText = "INSERT INTO TestCase(Field6) VALUES($bin)";
        DbParameter Field6 = cmd.CreateParameter();

        cmd.Parameters.Add(Field6);

        byte[] b = new byte[4000];
        b[0] = 1;
        b[100] = 2;
        b[1000] = 3;
        b[2000] = 4;
        b[3000] = 5;

        Field6.ParameterName = "$bin";
        Field6.Value = b;



        cmd.ExecuteNonQuery();
      }
    }

    internal static void VerifyBinaryData(DbConnection cnn)
    {
      using (DbCommand cmd = cnn.CreateCommand())
360
361
362
363
364
365
366



































367
368
369
370
371
372
373
                Console.WriteLine(String.Format("Commits in {0} ms", (dtEnd / 10000)));
              }
            }
          }
        }
      }
    }




































    // Causes the user-defined function to be called
    internal static void UserFunction(DbConnection cnn)
    {
      using (DbCommand cmd = cnn.CreateCommand())
      {
        int nTimes;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
                Console.WriteLine(String.Format("Commits in {0} ms", (dtEnd / 10000)));
              }
            }
          }
        }
      }
    }

    internal static void SimpleInsertMany(DbConnection cnn)
    {
      using (DbTransaction dbTrans = cnn.BeginTransaction())
      {
        long dtStart;
        long dtEnd;

        using (DbCommand cmd = cnn.CreateCommand())
        {
          cmd.CommandText = "INSERT INTO TestCase(Field1) VALUES(?)";
          DbParameter Field1 = cmd.CreateParameter();

          cmd.Parameters.Add(Field1);

          Console.Write(String.Format("          SimpleInsertMany (100000 rows) Begins ... "));
          dtStart = DateTime.Now.Ticks;
          for (int n = 0; n < 100000; n++)
          {
            Field1.Value = n + 100000;
            cmd.ExecuteNonQuery();
          }

          dtEnd = DateTime.Now.Ticks;
          dtEnd -= dtStart;
          Console.Write(String.Format("Ends in {0} ms ... ", (dtEnd / 10000)));
        }

        dtStart = DateTime.Now.Ticks;
        dbTrans.Rollback();
        dtEnd = DateTime.Now.Ticks;
        dtEnd -= dtStart;
        Console.WriteLine(String.Format("rolled back in {0} ms", (dtEnd / 10000)));
      }
    }

    // Causes the user-defined function to be called
    internal static void UserFunction(DbConnection cnn)
    {
      using (DbCommand cmd = cnn.CreateCommand())
      {
        int nTimes;
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
      {
        cmdRead.CommandText = "SELECT ID FROM TestCase";
        using (DbDataReader rd = cmdRead.ExecuteReader())
        {
          using (DbCommand cmdwrite = cnn.CreateCommand())
          {
            cmdwrite.CommandText = "UPDATE [TestCase] SET [ID] = [ID]";
            cmdwrite.CommandTimeout = 10;

            long dwtick = DateTime.Now.Ticks;
            try
            {
              cmdwrite.ExecuteNonQuery();
            }
            catch (SQLiteException)
            {
              dwtick = (DateTime.Now.Ticks - dwtick) / TimeSpan.TicksPerSecond;
              if (dwtick < 10 || dwtick > 11)
                throw new ArgumentOutOfRangeException();
            }
          }
        }
      }
    }








|









|







529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
      {
        cmdRead.CommandText = "SELECT ID FROM TestCase";
        using (DbDataReader rd = cmdRead.ExecuteReader())
        {
          using (DbCommand cmdwrite = cnn.CreateCommand())
          {
            cmdwrite.CommandText = "UPDATE [TestCase] SET [ID] = [ID]";
            cmdwrite.CommandTimeout = 5;

            long dwtick = DateTime.Now.Ticks;
            try
            {
              cmdwrite.ExecuteNonQuery();
            }
            catch (SQLiteException)
            {
              dwtick = (DateTime.Now.Ticks - dwtick) / TimeSpan.TicksPerSecond;
              if (dwtick < 5 || dwtick > 6)
                throw new ArgumentOutOfRangeException();
            }
          }
        }
      }
    }