System.Data.SQLite

Check-in [e30a873204]
Login

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

Overview
Comment:Add initial tests for ticket [5cee5409f8].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | tkt-5cee5409f8
Files: files | file ages | folders
SHA1: e30a8732040eed0cfee585e35882398074083b77
User & Date: mistachkin 2018-01-27 21:13:43.463
Context
2018-01-27
22:24
Refinements to the test for ticket [5cee5409f8], with a special focus on the new WaitForEnlistmentReset method. check-in: 2cb2ae35a3 user: mistachkin tags: tkt-5cee5409f8
21:13
Add initial tests for ticket [5cee5409f8]. check-in: e30a873204 user: mistachkin tags: tkt-5cee5409f8
20:04
Add missing disposal check. check-in: e499efc92e user: mistachkin tags: tkt-5cee5409f8
Changes
Unified Diff Ignore Whitespace Patch
Changes to Setup/data/verify.lst.
861
862
863
864
865
866
867

868
869
870
871
872
873
874
  Tests/tkt-5251bd0878.eagle
  Tests/tkt-53633bbe39.eagle
  Tests/tkt-544dba0a2f.eagle
  Tests/tkt-5535448538.eagle
  Tests/tkt-56b42d99c1.eagle
  Tests/tkt-58ed318f2f.eagle
  Tests/tkt-59edc1018b.eagle

  Tests/tkt-6434e23a0f.eagle
  Tests/tkt-647d282d11.eagle
  Tests/tkt-69cf6e5dc8.eagle
  Tests/tkt-6c6ecccc5f.eagle
  Tests/tkt-71bedaca19.eagle
  Tests/tkt-72905c9a77.eagle
  Tests/tkt-74542e702e.eagle







>







861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
  Tests/tkt-5251bd0878.eagle
  Tests/tkt-53633bbe39.eagle
  Tests/tkt-544dba0a2f.eagle
  Tests/tkt-5535448538.eagle
  Tests/tkt-56b42d99c1.eagle
  Tests/tkt-58ed318f2f.eagle
  Tests/tkt-59edc1018b.eagle
  Tests/tkt-5cee5409f8.eagle
  Tests/tkt-6434e23a0f.eagle
  Tests/tkt-647d282d11.eagle
  Tests/tkt-69cf6e5dc8.eagle
  Tests/tkt-6c6ecccc5f.eagle
  Tests/tkt-71bedaca19.eagle
  Tests/tkt-72905c9a77.eagle
  Tests/tkt-74542e702e.eagle
Added Tests/tkt-5cee5409f8.eagle.














































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
###############################################################################
#
# tkt-5cee5409f8.eagle --
#
# Written by Joe Mistachkin.
# Released to the public domain, use at your own risk!
#
###############################################################################

package require Eagle
package require Eagle.Library
package require Eagle.Test

runTestPrologue

###############################################################################

package require System.Data.SQLite.Test
runSQLiteTestPrologue

###############################################################################

runTest {test tkt-5cee5409f8-1.1 {asynchronous transaction handling} -setup {
  setupDb [set fileName tkt-5cee5409f8-1.1.db]
} -body {
  sql execute $db "CREATE TABLE t1(x INTEGER);"

  set id [object invoke Interpreter.GetActive NextId]
  set dataSource [file join [getDatabaseDirectory] $fileName]

  unset -nocomplain results errors

  set code [compileCSharpWith [subst {
    using System;
    using System.Data.SQLite;
    using System.Transactions;

    namespace _Dynamic${id}
    {
      public static class Test${id}
      {
        private sealed class EnlistmentNotification : IEnlistmentNotification
        {
          #region Private Data
          private bool forceRollback;
          #endregion

          /////////////////////////////////////////////////////////////////////

          #region Private Constructors
          private EnlistmentNotification(bool forceRollback)
          {
            this.forceRollback = forceRollback;
          }
          #endregion

          /////////////////////////////////////////////////////////////////////

          #region IEnlistmentNotification Members
          public void Commit(Enlistment enlistment)
          {
            enlistment.Done();
          }

          /////////////////////////////////////////////////////////////////////

          public void InDoubt(Enlistment enlistment)
          {
            enlistment.Done();
          }

          /////////////////////////////////////////////////////////////////////

          public void Prepare(PreparingEnlistment preparingEnlistment)
          {
            if (forceRollback)
              preparingEnlistment.ForceRollback();
            else
              preparingEnlistment.Prepared();
          }

          /////////////////////////////////////////////////////////////////////

          public void Rollback(Enlistment enlistment)
          {
            enlistment.Done();
          }
          #endregion

          /////////////////////////////////////////////////////////////////////

          #region Public Static Methods
          public static void UseDistributedTransaction(bool forceRollback)
          {
            Transaction.Current.EnlistDurable(
                Guid.NewGuid(), new EnlistmentNotification(forceRollback),
                EnlistmentOptions.None);
          }
          #endregion
        }

        ///////////////////////////////////////////////////////////////////////

        public static void DoTransactions(SQLiteConnection connection)
        {
          for (int iteration = 0; iteration < 1000; iteration++)
          {
            using (TransactionScope transactionScope = new TransactionScope())
            {
              EnlistmentNotification.UseDistributedTransaction(false);

              TransactionInformation transactionInformation =
                  Transaction.Current.TransactionInformation;

              if (transactionInformation.DistributedIdentifier.Equals(
                  Guid.Empty))
              {
                throw new Exception("distributed identifier is empty");
              }

              connection.EnlistTransaction(Transaction.Current);

              using (SQLiteCommand command = connection.CreateCommand())
              {
                command.CommandText = "INSERT INTO t1(x) VALUES(?);";
                command.Parameters.Add(new SQLiteParameter("", iteration));
                command.ExecuteNonQuery();
              }

              transactionScope.Complete();
            }
          }
        }

        ///////////////////////////////////////////////////////////////////////

        public static void Main()
        {
          using (SQLiteConnection connection = new SQLiteConnection(
              "Data Source=${dataSource};[getTestProperties]"))
          {
            connection.Open();

            DoTransactions(connection);
          }
        }
      }
    }
  }] true true true results errors System.Data.SQLite.dll]

  list $code $results \
      [expr {[info exists errors] ? $errors : ""}] \
      [expr {$code eq "Ok" ? [catch {
        object invoke _Dynamic${id}.Test${id} Main
      } result] : [set result ""]}] $result
} -cleanup {
  cleanupDb $fileName

  unset -nocomplain result results errors code dataSource id db fileName
} -constraints {eagle command.object monoBug211 monoBug54 command.sql\
compile.DATA SQLite System.Data.SQLite compileCSharp} -match regexp -result \
{^Ok System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{\}$}}

###############################################################################

runSQLiteTestEpilogue
runTestEpilogue