From 3826756ffbb0185df8c38a45544b7a7066e6236f Mon Sep 17 00:00:00 2001 From: Elte Hupkes Date: Thu, 29 Aug 2019 14:40:57 +0200 Subject: [PATCH] Adding a regression test for #761 --- tests/ConcurrencyTest.cs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/ConcurrencyTest.cs b/tests/ConcurrencyTest.cs index 358a1133..ebf865bd 100644 --- a/tests/ConcurrencyTest.cs +++ b/tests/ConcurrencyTest.cs @@ -187,7 +187,28 @@ public void TestLoad() } } - + /// + /// Test for issue #761. Because the nature of this test is a race condition, + /// it is not guaranteed to fail if the issue is present. It does appear to + /// fail most of the time, though. + /// + [Test] + public void TestInsertCommandCreation () + { + using (var dbConnection = + new DbConnection (SQLiteOpenFlags.FullMutex | SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create)) { + var obj1 = new TestObj (); + var obj2 = new TestObj (); + var taskA = Task.Run (() => { + dbConnection.Insert (obj1); + }); + var taskB = Task.Run (() => { + dbConnection.Insert (obj2); + }); + + Task.WhenAll (taskA, taskB).Wait (); + } + } } }