public void TestDocumentChange() { var exp1 = new WaitAssert(); var exp2 = new WaitAssert(); Db.AddDocumentChangeListener("doc1", (sender, args) => { WriteLine("Reached document changed callback"); exp2.RunAssert(() => { WriteLine("Waiting for exp1 in document changed callback"); exp1.WaitForResult(TimeSpan.FromSeconds(20)); // Test deadlock }); }); WriteLine("Triggering async save"); var ignore = exp1.RunAssertAsync(() => { WriteLine("Running async save"); Db.Save(new MutableDocument("doc1")); WriteLine("Async save completed"); }); WriteLine("Waiting for exp1 in test method"); exp1.WaitForResult(TimeSpan.FromSeconds(10)); }
public void TestDatabaseChange() { var wa = new WaitAssert(); Db.AddChangeListener(null, (sender, args) => { var docIDs = args.DocumentIDs; wa.RunAssert(() => { args.Database.Should().Be(Db); docIDs.Should().HaveCount(10, "because that is the number of expected rows"); }); }); Db.InBatch(() => { for (uint i = 0; i < 10; i++) { var doc = new MutableDocument($"doc-{i}"); doc.SetString("type", "demo"); Db.Save(doc); } }); wa.WaitForResult(TimeSpan.FromSeconds(5)); }
public void TestDatabaseChange() { var exp1 = new WaitAssert(); var exp2 = new WaitAssert(); Db.AddChangeListener(null, (sender, args) => { exp2.RunAssert(() => { exp1.WaitForResult(TimeSpan.FromSeconds(20)); // Test deadlock }); }); var ignore = exp1.RunAssertAsync(() => { Db.Save(new MutableDocument("doc1")); }); exp1.WaitForResult(TimeSpan.FromSeconds(10)); }