public async void GetInfoAsync_Request() { //arrange. //act. await _sut.GetInfoAsync(); //assert. _handler.Verify(h => h.SendRequestAsync(string.Empty, RequestMethod.GET, RequestIs.Empty()), Times.Once); }
public async Task GetAttachmentAsync_Request() { //arrange. string docId = "1", attName = "2"; //act. await _sut.GetAttachmentAsync(docId, attName); //assert. var expectedUrl = $"{docId}/{attName}"; _handler.Verify(h => h.SendRequestAsync(expectedUrl, RequestMethod.GET, RequestIs.Empty()), Times.Once); }
public async Task SaveDocumentAsync_Request(string documentJson, bool batch, bool newEdits) { //arrange. var docQueryParams = new DocUpdateParams { Batch = batch, New_Edits = newEdits }; //act. await _sut.SaveStringDocumentAsync(documentJson, docQueryParams); //assert. var expectedUrl = QueryParams.AppendQueryParams(string.Empty, docQueryParams); _handler.Verify(h => h.SendRequestAsync(expectedUrl, RequestMethod.POST, RequestIs.JsonString(documentJson))); }
public async Task SaveAttachmentAsync_Request() { //arrange. string docId = "123", attName = "234", revision = "345"; var attachment = new byte[] { 1, 3, 2 }; //act. await _sut.SaveAttachmentAsync(docId, attName, revision, attachment); //assert. var expectedUrl = QueryParams.AppendQueryParams($"{docId}/{attName}", new AttachmentQueryParams { Rev = revision }); _handler.Verify(h => h.SendRequestAsync(expectedUrl, RequestMethod.PUT, RequestIs.ByteArray(attachment)), Times.Once); }
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); }
public async Task GetAllDocumentsAsync_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 queryParams = new ListQueryParams { Conflicts = conflicts, Descending = descending, EndKey = endKey, EndKey_DocId = endKey_DocId, Include_Docs = include_Docs.HasValue ? include_Docs : true, 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.GetAllStringDocumentsAsync(queryParams); //assert. var expectedUrl = QueryParams.AppendQueryParams("_all_docs", queryParams); _handler.Verify(h => h.SendRequestAsync(expectedUrl, RequestMethod.GET, RequestIs.Empty()), Times.Once); }
public async Task GetDocumentAsync_Request( string docId, bool?attachments = null, System.Collections.Generic.IEnumerable <string> attr_since = null, bool?attr_encoding_info = null, bool?conflicts = null, bool?deleted_conflicts = null, bool?latest = null, bool?local_seq = null, bool?meta = null, string rev = null, bool?revs = null, bool?revs_info = null) { //arrange. var docQueryParams = new DocQueryParams { Attachments = attachments, Atts_Since = attr_since, Att_Encoding_Info = attr_encoding_info, Conflicts = conflicts, Deleted_Conflicts = deleted_conflicts, Latest = latest, Local_Seq = local_seq, Meta = meta, Rev = rev, Revs = revs, Revs_Info = revs_info }; //act. await _sut.GetStringDocumentAsync(docId, docQueryParams); //assert. var expectedUrl = QueryParams.AppendQueryParams(docId, docQueryParams); _handler.Verify(h => h.SendRequestAsync(expectedUrl, RequestMethod.GET, RequestIs.Empty()), Times.Once); }
public async Task DeleteAttachmentAsync_Request(bool batch) { //arrange. var docId = "docid-123"; var attName = "attName-234"; var revision = "rev-543"; //act. await _sut.DeleteAttachmentAsync(docId, attName, revision, batch); //assert. var expectedUrl = QueryParams.AppendQueryParams($"{docId}/{attName}", new DeleteDocParams { Revision = revision, Batch = batch }); _handler.Verify(h => h.SendRequestAsync(expectedUrl, RequestMethod.DELETE, RequestIs.Empty()), Times.Once); }
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); }
public async Task DeleteDocumentAsync_Request(bool batch) { //arrange. var docId = "some doc id 123"; var revision = "some revision 321"; //act. await _sut.DeleteDocumentAsync(docId, revision, batch); //assert. var expectedUrl = QueryParams.AppendQueryParams(docId, new DeleteDocParams { Batch = batch, Revision = revision }); _handler.Verify(h => h.SendRequestAsync(expectedUrl, RequestMethod.DELETE, RequestIs.Empty()), Times.Once); }
public async void DeleteDbAsync_Request() { //arrange. var expectedDbName = "some-db-name-here"; //act. await _sut.DeleteDbAsync(expectedDbName); //assert. _handler.Verify(h => h.SendRequestAsync(expectedDbName, RequestMethod.DELETE, RequestIs.Empty()), Times.Once); }