public void EmptyWritingTransaction() { using (IKeyValueDB db = new InMemoryKeyValueDB()) { using (var tr = db.StartWritingTransaction().Result) { tr.Commit(); } } }
public void TwoEmptyWriteTransactionsWithNestedWaiting() { using (IKeyValueDB db = new InMemoryKeyValueDB()) { Task<IKeyValueDBTransaction> trOuter; using (var tr = db.StartWritingTransaction().Result) { trOuter = db.StartWritingTransaction(); tr.Commit(); } using (var tr = trOuter.Result) { tr.Commit(); } } }
public void StartWritingTransactionWorks() { using (IKeyValueDB db = new InMemoryKeyValueDB()) { var tr1 = db.StartWritingTransaction().Result; var tr2Task = db.StartWritingTransaction(); var task = Task.Factory.StartNew(() => { var tr2 = tr2Task.Result; Assert.True(tr2.FindExactKey(_key1)); tr2.CreateKey(_key2); tr2.Commit(); tr2.Dispose(); }); tr1.CreateKey(_key1); tr1.Commit(); tr1.Dispose(); task.Wait(1000); using (var tr = db.StartTransaction()) { Assert.True(tr.FindExactKey(_key1)); Assert.True(tr.FindExactKey(_key2)); } } }