Skip to content

Commit 3826756

Browse files
committed
Adding a regression test for #761
1 parent 52eb23c commit 3826756

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

tests/ConcurrencyTest.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,28 @@ public void TestLoad()
187187
}
188188
}
189189

190-
190+
/// <summary>
191+
/// Test for issue #761. Because the nature of this test is a race condition,
192+
/// it is not guaranteed to fail if the issue is present. It does appear to
193+
/// fail most of the time, though.
194+
/// </summary>
195+
[Test]
196+
public void TestInsertCommandCreation ()
197+
{
198+
using (var dbConnection =
199+
new DbConnection (SQLiteOpenFlags.FullMutex | SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create)) {
200+
var obj1 = new TestObj ();
201+
var obj2 = new TestObj ();
202+
var taskA = Task.Run (() => {
203+
dbConnection.Insert (obj1);
204+
});
205+
var taskB = Task.Run (() => {
206+
dbConnection.Insert (obj2);
207+
});
208+
209+
Task.WhenAll (taskA, taskB).Wait ();
210+
}
211+
}
191212
}
192213
}
193214

0 commit comments

Comments
 (0)