public async Task DeleteCollectionAsync_ShouldSucceed()
        {
            string clx = "DeleteCollectionAsync_ShouldSucceed";

            // create a collection so we can delete it
            var createResponse = await _collectionApi.PostCollectionAsync(
                new PostCollectionBody
            {
                Name = clx
            });

            string clxId = createResponse.Id;

            Assert.False(createResponse.ResponseDetails.Error);
            Assert.NotNull(clxId);

            var deleteResponse = await _collectionApi.DeleteCollectionAsync(clx);

            Assert.False(deleteResponse.ResponseDetails.Error);
            Assert.Equal(clxId, deleteResponse.Id);
        }
Exemplo n.º 2
0
        public async Task PostCollectionAsync_ShouldUseQueryParameter()
        {
            var mockTransport = new Mock <IApiClientTransport>();

            var mockResponse = new Mock <IApiClientResponse>();

            var mockResponseContent = new Mock <IApiClientResponseContent>();

            mockResponse.Setup(x => x.Content)
            .Returns(mockResponseContent.Object);

            mockResponse.Setup(x => x.IsSuccessStatusCode)
            .Returns(true);

            string requestUri = null;

            mockTransport.Setup(x => x.PostAsync(
                                    It.IsAny <string>(),
                                    It.IsAny <byte[]>(),
                                    It.IsAny <WebHeaderCollection>()))
            .Returns((string uri, byte[] content, WebHeaderCollection webHeaderCollection) =>
            {
                requestUri = uri;
                return(Task.FromResult(mockResponse.Object));
            });

            var apiClient = new CollectionApiClient(mockTransport.Object);

            var response = await apiClient.PostCollectionAsync(
                new PostCollectionBody
            {
                Name = "MyCollection"
            },
                new PostCollectionQuery()
            {
                EnforceReplicationFactor = true,
                WaitForSyncReplication   = true
            });

            Assert.NotNull(requestUri);
            Assert.Contains("enforceReplicationFactor=1", requestUri);
            Assert.Contains("waitForSyncReplication=1", requestUri);
        }