public void TestPullerWithLiveQuery() { // Even though this test is passed, there is a runtime exception // thrown regarding the replication's number of changes count versus // number of completed changes count. Investigation is required. Log.D(Database.Tag, "testPullerWithLiveQuery"); string docIdTimestamp = System.Convert.ToString(Runtime.CurrentTimeMillis()); string doc1Id = string.Format("doc1-{0}", docIdTimestamp); string doc2Id = string.Format("doc2-{0}", docIdTimestamp); AddDocWithId(doc1Id, "attachment2.png"); AddDocWithId(doc2Id, "attachment2.png"); int numDocsBeforePull = database.DocumentCount; View view = database.GetView("testPullerWithLiveQueryView"); view.SetMapReduce((document, emitter) => { if (document.Get("_id") != null) { emitter(document.Get("_id"), null); } }, null, "1"); LiveQuery allDocsLiveQuery = view.CreateQuery().ToLiveQuery(); allDocsLiveQuery.Changed += (sender, e) => { int numTimesCalled = 0; if (e.Error != null) { throw new RuntimeException(e.Error); } if (numTimesCalled++ > 0) { NUnit.Framework.Assert.IsTrue(e.Rows.Count > numDocsBeforePull); } Log.D(Database.Tag, "rows " + e.Rows); }; // the first time this is called back, the rows will be empty. // but on subsequent times we should expect to get a non empty // row set. allDocsLiveQuery.Start(); DoPullReplication(); allDocsLiveQuery.Stop(); }
/// <summary> /// Stops the live query. /// </summary> public void Stop() { liveQuery.Stop(); }