System.Data.SQLite
Check-in [982395fc95]
Not logged in

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

Overview
Comment:More tests.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 982395fc95fbb967bde66f8032a4901aa1c10798
User & Date: mistachkin 2014-01-30 00:17:36
Context
2014-01-30
10:24
For the batch testing tool, make sure the Entity Framework assembly is copied to the mixed-mode binary directory. check-in: 426d89e91b user: mistachkin tags: trunk
00:17
More tests. check-in: 982395fc95 user: mistachkin tags: trunk
2014-01-29
23:30
Add another transaction enlistment test. check-in: dca5b4660b user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Tests/tkt-56b42d99c1.eagle.

   108    108   runTest {test tkt-56b42d99c1-1.2 {enlisted transaction isolation} -setup {
   109    109     setupDb [set fileName tkt-56b42d99c1-1.2.db]
   110    110   } -body {
   111    111     set id [object invoke Interpreter.GetActive NextId]
   112    112     set dataSource [file join [getDatabaseDirectory] $fileName]
   113    113   
   114    114     unset -nocomplain results errors
          115  +
          116  +  set sql(1) { \
          117  +    CREATE TABLE t1(x); \
          118  +    INSERT INTO t1 (x) VALUES(1); \
          119  +  }
          120  +
          121  +  set sql(2) { \
          122  +    SELECT COUNT(*) FROM sqlite_master WHERE type = 'table'; \
          123  +  }
          124  +
          125  +  set code [compileCSharpWith [subst {
          126  +    using System.Data.SQLite;
          127  +    using System.Transactions;
          128  +
          129  +    namespace _Dynamic${id}
          130  +    {
          131  +      public static class Test${id}
          132  +      {
          133  +        public static int Main()
          134  +        {
          135  +          TransactionOptions transactionOptions = new TransactionOptions();
          136  +          transactionOptions.IsolationLevel = IsolationLevel.ReadCommitted;
          137  +
          138  +          using (TransactionScope transactionScope = new TransactionScope(
          139  +              TransactionScopeOption.Required, transactionOptions))
          140  +          {
          141  +            using (SQLiteConnection connection1 = new SQLiteConnection(
          142  +                "Data Source=${dataSource};[getFlagsProperty]"))
          143  +            {
          144  +              connection1.Open();
          145  +
          146  +              using (SQLiteConnection connection2 = new SQLiteConnection(
          147  +                  "Data Source=${dataSource};[getFlagsProperty]"))
          148  +              {
          149  +                connection2.Open();
          150  +
          151  +                using (SQLiteCommand command1 = connection1.CreateCommand())
          152  +                {
          153  +                  command1.CommandText = "${sql(1)}";
          154  +                  command1.ExecuteNonQuery();
          155  +
          156  +                  using (SQLiteCommand command2 = connection2.CreateCommand())
          157  +                  {
          158  +                    command2.CommandText = "${sql(2)}";
          159  +                    return (int)(long)command2.ExecuteScalar();
          160  +                  }
          161  +                }
          162  +              }
          163  +            }
          164  +          }
          165  +        }
          166  +      }
          167  +    }
          168  +  }] true true true results errors System.Data.SQLite.dll]
          169  +
          170  +  list $code $results \
          171  +      [expr {[info exists errors] ? $errors : ""}] \
          172  +      [expr {$code eq "Ok" ? [catch {
          173  +        object invoke _Dynamic${id}.Test${id} Main
          174  +      } result] : [set result ""]}] $result
          175  +} -cleanup {
          176  +  cleanupDb $fileName
          177  +
          178  +  unset -nocomplain result results errors code dataSource id db fileName
          179  +} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
          180  +System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
          181  +System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 0$}}
          182  +
          183  +###############################################################################
          184  +
          185  +runTest {test tkt-56b42d99c1-1.3 {enlisted transaction isolation} -setup {
          186  +  setupDb [set fileName tkt-56b42d99c1-1.3.db]
          187  +} -body {
          188  +  set id [object invoke Interpreter.GetActive NextId]
          189  +  set dataSource [file join [getDatabaseDirectory] $fileName]
          190  +
          191  +  unset -nocomplain results errors
          192  +
          193  +  set sql(1) { \
          194  +    CREATE TABLE t1(x); \
          195  +    INSERT INTO t1 (x) VALUES(1); \
          196  +  }
          197  +
          198  +  set sql(2) { \
          199  +    SELECT COUNT(*) FROM sqlite_master WHERE type = 'table'; \
          200  +  }
          201  +
          202  +  set code [compileCSharpWith [subst {
          203  +    using System.Data.SQLite;
          204  +    using System.Transactions;
          205  +
          206  +    namespace _Dynamic${id}
          207  +    {
          208  +      public static class Test${id}
          209  +      {
          210  +        public static int Main()
          211  +        {
          212  +          TransactionOptions transactionOptions = new TransactionOptions();
          213  +          transactionOptions.IsolationLevel = IsolationLevel.ReadCommitted;
          214  +
          215  +          using (TransactionScope transactionScope = new TransactionScope(
          216  +              TransactionScopeOption.Required, transactionOptions))
          217  +          {
          218  +            using (SQLiteConnection connection1 = new SQLiteConnection(
          219  +                "Data Source=${dataSource};Enlist=False;[getFlagsProperty]"))
          220  +            {
          221  +              connection1.Open();
          222  +
          223  +              using (SQLiteConnection connection2 = new SQLiteConnection(
          224  +                  "Data Source=${dataSource};Enlist=False;[getFlagsProperty]"))
          225  +              {
          226  +                connection2.Open();
          227  +
          228  +                using (SQLiteCommand command1 = connection1.CreateCommand())
          229  +                {
          230  +                  command1.CommandText = "${sql(1)}";
          231  +                  command1.ExecuteNonQuery();
          232  +
          233  +                  using (SQLiteCommand command2 = connection2.CreateCommand())
          234  +                  {
          235  +                    command2.CommandText = "${sql(2)}";
          236  +                    return (int)(long)command2.ExecuteScalar();
          237  +                  }
          238  +                }
          239  +              }
          240  +            }
          241  +          }
          242  +        }
          243  +      }
          244  +    }
          245  +  }] true true true results errors System.Data.SQLite.dll]
          246  +
          247  +  list $code $results \
          248  +      [expr {[info exists errors] ? $errors : ""}] \
          249  +      [expr {$code eq "Ok" ? [catch {
          250  +        object invoke _Dynamic${id}.Test${id} Main
          251  +      } result] : [set result ""]}] $result
          252  +} -cleanup {
          253  +  cleanupDb $fileName
          254  +
          255  +  unset -nocomplain result results errors code dataSource id db fileName
          256  +} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
          257  +System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
          258  +System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 1$}}
          259  +
          260  +###############################################################################
          261  +
          262  +runTest {test tkt-56b42d99c1-1.4 {enlisted transaction isolation} -setup {
          263  +  setupDb [set fileName tkt-56b42d99c1-1.4.db]
          264  +} -body {
          265  +  set id [object invoke Interpreter.GetActive NextId]
          266  +  set dataSource [file join [getDatabaseDirectory] $fileName]
          267  +
          268  +  unset -nocomplain results errors
          269  +
          270  +  set sql(1) { \
          271  +    CREATE TABLE t1(x); \
          272  +    INSERT INTO t1 (x) VALUES(1); \
          273  +  }
          274  +
          275  +  set sql(2) { \
          276  +    SELECT COUNT(*) FROM sqlite_master WHERE type = 'table'; \
          277  +  }
          278  +
          279  +  set code [compileCSharpWith [subst {
          280  +    using System.Data.SQLite;
          281  +    using System.Transactions;
          282  +
          283  +    namespace _Dynamic${id}
          284  +    {
          285  +      public static class Test${id}
          286  +      {
          287  +        public static int Main()
          288  +        {
          289  +          TransactionOptions transactionOptions = new TransactionOptions();
          290  +          transactionOptions.IsolationLevel = IsolationLevel.ReadCommitted;
          291  +
          292  +          using (TransactionScope transactionScope = new TransactionScope(
          293  +              TransactionScopeOption.Required, transactionOptions))
          294  +          {
          295  +            using (SQLiteConnection connection1 = new SQLiteConnection(
          296  +                "Data Source=${dataSource};[getFlagsProperty]"))
          297  +            {
          298  +              connection1.Open();
          299  +
          300  +              using (SQLiteConnection connection2 = new SQLiteConnection(
          301  +                  "Data Source=${dataSource};Enlist=False;[getFlagsProperty]"))
          302  +              {
          303  +                connection2.Open();
          304  +
          305  +                using (SQLiteCommand command1 = connection1.CreateCommand())
          306  +                {
          307  +                  command1.CommandText = "${sql(1)}";
          308  +                  command1.ExecuteNonQuery();
          309  +
          310  +                  using (SQLiteCommand command2 = connection2.CreateCommand())
          311  +                  {
          312  +                    command2.CommandText = "${sql(2)}";
          313  +                    return (int)(long)command2.ExecuteScalar();
          314  +                  }
          315  +                }
          316  +              }
          317  +            }
          318  +          }
          319  +        }
          320  +      }
          321  +    }
          322  +  }] true true true results errors System.Data.SQLite.dll]
          323  +
          324  +  list $code $results \
          325  +      [expr {[info exists errors] ? $errors : ""}] \
          326  +      [expr {$code eq "Ok" ? [catch {
          327  +        object invoke _Dynamic${id}.Test${id} Main
          328  +      } result] : [set result ""]}] $result
          329  +} -cleanup {
          330  +  cleanupDb $fileName
          331  +
          332  +  unset -nocomplain result results errors code dataSource id db fileName
          333  +} -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
          334  +System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
          335  +System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 0$}}
          336  +
          337  +###############################################################################
          338  +
          339  +runTest {test tkt-56b42d99c1-1.5 {enlisted transaction isolation} -setup {
          340  +  setupDb [set fileName tkt-56b42d99c1-1.5.db]
          341  +} -body {
          342  +  set id [object invoke Interpreter.GetActive NextId]
          343  +  set dataSource [file join [getDatabaseDirectory] $fileName]
          344  +
          345  +  unset -nocomplain results errors
          346  +
          347  +  set sql(1) { \
          348  +    CREATE TABLE t1(x); \
          349  +    INSERT INTO t1 (x) VALUES(1); \
          350  +  }
          351  +
          352  +  set sql(2) { \
          353  +    SELECT COUNT(*) FROM sqlite_master WHERE type = 'table'; \
          354  +  }
   115    355   
   116    356     set code [compileCSharpWith [subst {
   117    357       using System.Data.SQLite;
   118    358       using System.Transactions;
   119    359   
   120    360       namespace _Dynamic${id}
   121    361       {
   122    362         public static class Test${id}
   123    363         {
   124         -        public static void Main()
          364  +        public static int Main()
   125    365           {
   126    366             TransactionOptions transactionOptions = new TransactionOptions();
   127    367             transactionOptions.IsolationLevel = IsolationLevel.ReadCommitted;
   128    368   
   129    369             using (TransactionScope transactionScope = new TransactionScope(
   130    370                 TransactionScopeOption.Required, transactionOptions))
   131    371             {
   132    372               using (SQLiteConnection connection1 = new SQLiteConnection(
   133         -                "Data Source=${dataSource};Enlist=True;[getFlagsProperty]"))
          373  +                "Data Source=${dataSource};Enlist=False;[getFlagsProperty]"))
   134    374               {
   135    375                 connection1.Open();
   136    376   
   137    377                 using (SQLiteConnection connection2 = new SQLiteConnection(
   138         -                  "Data Source=${dataSource};Enlist=True;[getFlagsProperty]"))
          378  +                  "Data Source=${dataSource};[getFlagsProperty]"))
   139    379                 {
   140    380                   connection2.Open();
          381  +
          382  +                using (SQLiteCommand command1 = connection1.CreateCommand())
          383  +                {
          384  +                  command1.CommandText = "${sql(1)}";
          385  +                  command1.ExecuteNonQuery();
          386  +
          387  +                  using (SQLiteCommand command2 = connection2.CreateCommand())
          388  +                  {
          389  +                    command2.CommandText = "${sql(2)}";
          390  +                    return (int)(long)command2.ExecuteScalar();
          391  +                  }
          392  +                }
   141    393                 }
   142    394               }
   143    395             }
   144    396           }
   145    397         }
   146    398       }
   147    399     }] true true true results errors System.Data.SQLite.dll]
................................................................................
   153    405         } result] : [set result ""]}] $result
   154    406   } -cleanup {
   155    407     cleanupDb $fileName
   156    408   
   157    409     unset -nocomplain result results errors code dataSource id db fileName
   158    410   } -constraints {eagle monoBug28 command.sql compile.DATA SQLite\
   159    411   System.Data.SQLite compileCSharp} -match regexp -result {^Ok\
   160         -System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}
          412  +System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 1$}}
   161    413   
   162    414   ###############################################################################
   163    415   
   164    416   runSQLiteTestEpilogue
   165    417   runTestEpilogue