Пример #1
0
        public async Task DeleteDocument_ShouldSucceed()
        {
            Dictionary <string, object> document = new Dictionary <string, object> {
                ["key"] = "value"
            };
            var response = await _docClient.PostDocumentAsync("TestCollection", document);

            Assert.NotNull(response._id);

            var deleteResponse = await _docClient.DeleteDocumentAsync(response._id);

            Assert.Null(deleteResponse.Old); // we didn't request `Old` so it should be null
            Assert.Equal(response._id, deleteResponse._id);
            Assert.Equal(response._key, deleteResponse._key);
            Assert.Equal(response._rev, deleteResponse._rev);

            var ex = await Assert.ThrowsAsync <ApiErrorException>(async() =>
                                                                  await _docClient.GetDocumentAsync <object>(response._id));

            Assert.Equal(NOT_FOUND_NUM, ex.ApiError.ErrorNum); // document not found
        }
Пример #2
0
        public async Task DeleteDocument_ShouldSucceed()
        {
            Dictionary <string, object> document = new Dictionary <string, object> {
                ["key"] = "value"
            };
            var response = await _docClient.PostDocumentAsync(_testCollection, document);

            Assert.NotNull(response._id);

            var deleteResponse = await _docClient.DeleteDocumentAsync(response._id);

            Assert.Null(deleteResponse.Old); // we didn't request `Old` so it should be null
            Assert.Equal(response._id, deleteResponse._id);
            Assert.Equal(response._key, deleteResponse._key);
            Assert.Equal(response._rev, deleteResponse._rev);

            var getDocumentResponse = await _docClient.GetDocumentAsync <object>(response._id);

            Assert.False(getDocumentResponse.IsSuccess);
            Assert.Equal(NOT_FOUND_NUM, getDocumentResponse.ResponseDetails.ErrorNum);
            Assert.Equal(HttpStatusCode.NotFound, getDocumentResponse.ResponseDetails.Code);

            _docClient.ThrowErrorsAsExceptions = true;
            var ex = await Assert.ThrowsAsync <ApiErrorException>(async() =>
                                                                  await _docClient.GetDocumentAsync <object>(response._id));

            Assert.Equal(NOT_FOUND_NUM, ex.ResponseDetails.ErrorNum); // document not found
        }