예제 #1
0
        public void TestChangeTrackerWithDocsIds()
        {
            var testURL       = GetReplicationURL();
            var changeTracker = new ChangeTracker(testURL, ChangeTrackerMode
                                                  .LongPoll, 0, false, null);

            var docIds = new List <string>();

            docIds.AddItem("doc1");
            docIds.AddItem("doc2");
            changeTracker.SetDocIDs(docIds);

            var docIdsJson       = "[\"doc1\",\"doc2\"]";
            var docIdsEncoded    = Uri.EscapeUriString(docIdsJson);
            var expectedFeedPath = string.Format("_changes?feed=longpoll&limit=500&heartbeat=300000&since=0&filter=_doc_ids&doc_ids={0}",
                                                 docIdsEncoded);
            string changesFeedPath = changeTracker.GetChangesFeedPath();

            Assert.AreEqual(expectedFeedPath, changesFeedPath);

            changeTracker.UsePost = true;
            var parameters = changeTracker.GetChangesFeedParams();

            Assert.AreEqual("_doc_ids", parameters["filter"]);
            AssertEnumerablesAreEqual(docIds, (IEnumerable)parameters["doc_ids"]);

            var body = changeTracker.GetChangesFeedPostBody();

            Assert.IsTrue(body.Contains(docIdsJson));
        }
예제 #2
0
        public void TestChangeTrackerWithFilterURL()
        {
            var testUrl       = GetReplicationURL();
            var changeTracker = new ChangeTracker(testUrl, ChangeTrackerMode.LongPoll, 0, false, null);

            // set filter
            changeTracker.SetFilterName("filter");

            // build filter map
            var filterMap = new Dictionary <string, object>();

            filterMap["param"] = "value";

            // set filter map
            changeTracker.SetFilterParams(filterMap);
            Assert.AreEqual("_changes?feed=longpoll&limit=500&heartbeat=300000&since=0&filter=filter&param=value",
                            changeTracker.GetChangesFeedPath());
        }
예제 #3
0
        public void TestChangeTrackerWithConflictsIncluded()
        {
            Uri testUrl       = GetReplicationURL();
            var changeTracker = new ChangeTracker(testUrl, ChangeTrackerMode.LongPoll, 0, true, null);

            Assert.AreEqual("_changes?feed=longpoll&limit=500&heartbeat=300000&style=all_docs&since=0", changeTracker.GetChangesFeedPath());
        }