public void InsertAllFailureInsideTransaction() { List <UniqueObj> testObjects = Enumerable.Range(1, 20).Select(i => new UniqueObj { Id = i }).ToList(); testObjects[testObjects.Count - 1].Id = 1; // causes the insert to fail because of duplicate key ExceptionAssert.Throws <SQLiteException>(() => _db.RunInTransaction(() => { _db.InsertAll(testObjects); })); Assert.AreEqual(0, _db.Table <UniqueObj>().Count()); }
public void FailNestedSavepointTransaction() { try { db.RunInTransaction(() => { db.Delete(testObjects[0]); db.RunInTransaction(() => { db.Delete(testObjects[1]); throw new TransactionTestException(); }); }); } catch (TransactionTestException) { // ignore } Assert.AreEqual(testObjects.Count, db.Table <TestObj>().Count()); }