示例#1
0
        public async Task GetDocumentsAsync_Request(
            bool?conflicts,
            bool?descending,
            string endKey,
            string endKey_DocId,
            bool?include_Docs,
            bool?inclusive_End,
            string key,
            IEnumerable <string> keys,
            int?limit,
            int?skip,
            ListQueryParams.StaleOption?stale,
            string startKey,
            string startKey_DocId,
            bool?update_Seq)
        {
            //arrange.
            var docIdList = new[] { "1", "2", "3" };

            var queryParams = new ListQueryParams
            {
                Conflicts      = conflicts,
                Descending     = descending,
                EndKey         = endKey,
                EndKey_DocId   = endKey_DocId,
                Include_Docs   = include_Docs,
                Inclusive_End  = inclusive_End,
                Key            = key,
                Keys           = keys,
                Limit          = limit,
                Skip           = skip,
                Stale          = stale,
                StartKey       = startKey,
                StartKey_DocId = startKey_DocId,
                Update_Seq     = update_Seq
            };

            //act.
            await _sut.GetStringDocumentsAsync(docIdList, queryParams);

            //assrert.
            var expectedUrl = QueryParams.AppendQueryParams("_all_docs", queryParams);

            _handler.Verify(h => h.SendRequestAsync(expectedUrl, RequestMethod.POST,
                                                    RequestIs.JsonObject(new { keys = docIdList })), Times.Once);
        }
示例#2
0
        public async Task SaveDocumentsAsync_Request(bool newEdits)
        {
            //arrange.
            var expectedObject = new
            {
                new_edits = newEdits,
                docs      = new []
                {
                    new { id = "1", name = 2 },
                    new { id = "2", name = 4 }
                }
            };

            //act.
            await _sut.SaveStringDocumentsAsync(expectedObject.docs.Select(d => JsonConvert.SerializeObject(d)).ToArray(), newEdits);

            //assert.
            _handler.Verify(h => h.SendRequestAsync("_bulk_docs", RequestMethod.POST, RequestIs.JsonObject(expectedObject)), Times.Once);
        }