System.Data.SQLite
Check-in [f4e1038098]
Not logged in

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

Overview
Comment:Add unit testing support for the fix to ticket [ccfa69fc32].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-ccfa69fc32
Files: files | file ages | folders
SHA1: f4e10380987de81096f0a5952930bfdbe3befece
User & Date: mistachkin 2011-09-11 15:33:10
References
2011-09-12
20:41 Ticket [ccfa69fc32] Transaction on conflict behave status still Closed with 1 other change artifact: 99569dc0ad user: mistachkin
20:24 Ticket [ccfa69fc32]: 1 change artifact: 3e7fe221da user: mistachkin
2011-09-11
15:37 Ticket [ccfa69fc32]: 2 changes artifact: 5683d82b91 user: mistachkin
15:36 Ticket [ccfa69fc32]: 1 change artifact: 17072e76a4 user: mistachkin
Context
2011-09-11
15:45
Fix test cleanup to remove the 'add' variable. check-in: 538c5ca711 user: mistachkin tags: bug-ccfa69fc32
15:33
Add unit testing support for the fix to ticket [ccfa69fc32]. check-in: f4e1038098 user: mistachkin tags: bug-ccfa69fc32
14:33
Experimental fix for ticket [ccfa69fc32]. check-in: 42af4d17a5 user: mistachkin tags: bug-ccfa69fc32
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Added Tests/tkt-ccfa69fc32.eagle.

            1  +###############################################################################
            2  +#
            3  +# tkt-ccfa69fc32.eagle --
            4  +#
            5  +# Written by Joe Mistachkin.
            6  +# Released to the public domain, use at your own risk!
            7  +#
            8  +###############################################################################
            9  +
           10  +package require Eagle
           11  +package require EagleLibrary
           12  +package require EagleTest
           13  +
           14  +runTestPrologue
           15  +
           16  +###############################################################################
           17  +
           18  +source [file join $path common.eagle]
           19  +runSQLiteTestPrologue
           20  +
           21  +###############################################################################
           22  +
           23  +#
           24  +# NOTE: Setup the variables that refer to the various files required by the
           25  +#       tests in this file.
           26  +#
           27  +set testLinqExeFile [getBuildFileName testlinq.exe]
           28  +set northwindEfDbFile [file nativename [file join [file dirname $path] \
           29  +    testlinq northwindEF.db]]
           30  +
           31  +#
           32  +# NOTE: Setup the test constraints specific to the tests in this file.
           33  +#
           34  +if {![haveConstraint file_[file tail $testLinqExeFile]]} then {
           35  +  checkForFile $test_channel $testLinqExeFile
           36  +}
           37  +
           38  +if {![haveConstraint file_[file tail $northwindEfDbFile]]} then {
           39  +  checkForFile $test_channel $northwindEfDbFile
           40  +}
           41  +
           42  +###############################################################################
           43  +
           44  +runTest {test tkt-ccfa69fc32-1.1 {Entity Framework / Transaction Scope} -body {
           45  +  set result [list]
           46  +
           47  +  foreach add [list false true false] {
           48  +    set code [catch {
           49  +      testExec $testLinqExeFile [list -eventflags Wait -directory \
           50  +      [file dirname $testLinqExeFile] -nocarriagereturns -stdout output \
           51  +      -success 0] -efTransaction $add
           52  +    } error]
           53  +
           54  +    tlog "---- BEGIN STDOUT OUTPUT\n"
           55  +    tlog $output
           56  +    tlog "\n---- END STDOUT OUTPUT\n"
           57  +
           58  +    lappend result $code
           59  +
           60  +    if {$code == 0} then {
           61  +      lappend result [string trim $output]
           62  +    } else {
           63  +      lappend result [string trim $error]
           64  +    }
           65  +  }
           66  +
           67  +  set result
           68  +} -cleanup {
           69  +  unset -nocomplain code output error result pageSize
           70  +} -constraints {eagle file_testlinq.exe file_northwindEF.db} -match glob \
           71  +-result {0 {} 0 {System.Data.UpdateException: * --->\
           72  +System.Data.SQLite.SQLiteException: Abort due to constraint violation
           73  +PRIMARY KEY must be unique
           74  +*} 0 {1 2 3 4 5 6 7 8 9 10}}}
           75  +
           76  +###############################################################################
           77  +
           78  +unset -nocomplain testLinqExeFile northwindEfDbFile
           79  +
           80  +###############################################################################
           81  +
           82  +runSQLiteTestEpilogue
           83  +runTestEpilogue

Changes to testlinq/Program.cs.

   210    210             {
   211    211                 using (northwindEFEntities db = new northwindEFEntities())
   212    212                 {
   213    213                     using (TransactionScope scope = new TransactionScope())
   214    214                     {
   215    215                         //
   216    216                         // NOTE: *REQUIRED* This is required so that the
   217         -                      //       framework is prevented from using multiple
   218         -                      //       connections to the underlying SQLite database
   219         -                      //       (i.e. which would result in multiple IMMEDIATE
   220         -                      //       transactions, thereby failing [later on] with
   221         -                      //       locking errors).
          217  +                      //       Entity Framework is prevented from opening
          218  +                      //       multiple connections to the underlying SQLite
          219  +                      //       database (i.e. which would result in multiple
          220  +                      //       IMMEDIATE transactions, thereby failing [later
          221  +                      //       on] with locking errors).
   222    222                         //
   223    223                         db.Connection.Open();
   224    224   
   225    225                         for (int index = 0; index < 5; index++)
   226    226                         {
   227    227                             int id = (index % 10) + 1;
   228    228   
................................................................................
   283    283                         {
   284    284                             scope.Complete();
   285    285                             db.AcceptAllChanges();
   286    286                         }
   287    287                     }
   288    288                 }
   289    289             }
   290         -
   291         -          using (northwindEFEntities db = new northwindEFEntities())
          290  +          else
   292    291             {
   293         -              bool once = false;
   294         -              var query = from t in db.Territories
   295         -                          where t.TerritoryID.CompareTo(11) < 0
   296         -                          orderby t.TerritoryID
   297         -                          select t;
   298         -
   299         -              foreach (Territories territories in query)
          292  +              using (northwindEFEntities db = new northwindEFEntities())
   300    293                 {
   301         -                  if (once)
   302         -                      Console.Write(' ');
          294  +                  bool once = false;
          295  +                  var query = from t in db.Territories
          296  +                              where t.TerritoryID.CompareTo(11) < 0
          297  +                              orderby t.TerritoryID
          298  +                              select t;
   303    299   
   304         -                  Console.Write(territories.TerritoryID);
          300  +                  foreach (Territories territories in query)
          301  +                  {
          302  +                      if (once)
          303  +                          Console.Write(' ');
   305    304   
   306         -                  once = true;
          305  +                      Console.Write(territories.TerritoryID);
          306  +
          307  +                      once = true;
          308  +                  }
   307    309                 }
   308    310             }
   309    311   
   310    312             return 0;
   311    313         }
   312    314   
   313    315       private static int OldTests()