Beispiel #1
0
        public MyCouchStore(IMyCouchClient client)
        {
            Ensure.That(client, "client").IsNotNull();

            Client     = client;
            IsDisposed = false;
        }
Beispiel #2
0
        public MyCouchStore(IMyCouchClient client)
        {
            EnsureArg.IsNotNull(client, nameof(client));

            Client     = client;
            IsDisposed = false;
        }
Beispiel #3
0
        public MyCouchStore(IMyCouchClient client)
        {
            Ensure.That(client, "client").IsNotNull();

            Client     = client;
            IsDisposed = false;
            ObservableSubscribeOnScheduler = () => TaskPoolScheduler.Default;
        }
Beispiel #4
0
        protected IntegrationTestsOf()
        {
            Environment  = IntegrationTestsRuntime.Environment;
            ServerClient = IntegrationTestsRuntime.CreateServerClient();
            DbClient     = IntegrationTestsRuntime.CreateDbClient();

            EnsureCleanEnvironment();
        }
Beispiel #5
0
        public MyCouchUserStore(IMyCouchClient client)
        {
            Ensure.That(client, "client").IsNotNull();

            _usernamesView = new ViewIdentity("userstore", "usernames");
            _loginProviderProviderKeyView = new ViewIdentity("userstore", "loginprovider_providerkey");

            DisposeClient = false;
            Client        = client;
        }
Beispiel #6
0
        protected virtual void Dispose(bool disposing)
        {
            if (IsDisposed || !disposing)
            {
                return;
            }

            Client.Dispose();
            Client = null;
        }
Beispiel #7
0
        internal static void ClearAllDocuments(this IMyCouchClient client)
        {
            var query    = new QuerySystemViewRequest("_all_docs").Configure(q => q.Stale(Stale.UpdateAfter));
            var response = client.Views.QueryAsync <dynamic>(query).Result;

            BulkDelete(client, response);

            response = client.Views.QueryAsync <dynamic>(query).Result;

            BulkDelete(client, response);
        }
Beispiel #8
0
        private static void CreateIndex2(IMyCouchClient client)
        {
            var indexRequest = new PostIndexRequest();

            indexRequest.Configure(q => q.DesignDocument("TestDoc")
                                   .Name("TestIndex2")
                                   .Fields(new SortableField("author.age"), new SortableField("yearsActive"))
                                   );

            var response = client.Queries.PostAsync(indexRequest).Result;

            response.IsSuccess.Should().Be(true);
        }
Beispiel #9
0
        private static async void BulkDelete(IMyCouchClient client, ViewQueryResponse <dynamic> response)
        {
            if (response.IsEmpty)
            {
                return;
            }

            var bulkRequest = new BulkRequest();

            foreach (var row in response.Rows)
            {
                bulkRequest.Delete(row.Id, row.Value.rev.ToString());
            }

            await client.Documents.BulkAsync(bulkRequest).ForAwait();
        }
Beispiel #10
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposing)
            {
                return;
            }

            ServerClient.Dispose();
            ServerClient = null;

            DbClient.Dispose();
            DbClient = null;

            var disposableSut = SUT as IDisposable;

            disposableSut?.Dispose();
        }
Beispiel #11
0
        public static async Task EnsureDesignDocsExists(this IMyCouchClient client)
        {
            var getResponse = await client.Documents.GetAsync("_design/userstore");

            if (!getResponse.IsEmpty)
            {
                return;
            }

            var putResponse = await client.Documents.PostAsync(DesignDocs.UserStore);

            if (!putResponse.IsSuccess)
            {
                var msg = string.Format("{0}[Error]: {1}.{0}[Reason]: {2}.",
                                        Environment.NewLine,
                                        putResponse.Error ?? string.Empty,
                                        putResponse.Reason ?? string.Empty);

                throw new Exception("Could not create design document 'userstore' with required views." + msg);
            }
        }
        private static void BulkDelete(IMyCouchClient client, ViewQueryResponse <dynamic> response)
        {
            if (response.IsEmpty)
            {
                return;
            }

            var bulkRequest = new BulkRequest();

            foreach (var row in response.Rows)
            {
                if (row.Id.ToLower() == "_design/_replicator")
                {
                    continue;
                }

                bulkRequest.Delete(row.Id, row.Value.rev.ToString());
            }

            if (!bulkRequest.IsEmpty)
            {
                client.Documents.BulkAsync(bulkRequest).Wait();
            }
        }
Beispiel #13
0
 public void SetFixture(ClientTestsFixture data)
 {
     Client = data.Client;
     OnTestInit();
 }
Beispiel #14
0
 public static Task <BulkResponse> PerformAsync(this IMyCouchClient client, BulkRequest request)
 {
     return(client.Documents.BulkAsync(request));
 }
Beispiel #15
0
 public static Task <DocumentHeaderResponse> PerformAsync(this IMyCouchClient client, PutDocumentRequest request)
 {
     return(client.Documents.PutAsync(request));
 }
Beispiel #16
0
 public static Task <AttachmentResponse> PerformAsync(this IMyCouchClient client, GetAttachmentRequest request)
 {
     return(client.Attachments.GetAsync(request));
 }
Beispiel #17
0
 public static Task <DocumentHeaderResponse> PerformAsync(this IMyCouchClient client, DeleteAttachmentRequest request)
 {
     return(client.Attachments.DeleteAsync(request));
 }
Beispiel #18
0
 public static Task <EntityResponse <T> > PerformAsync <T>(this IMyCouchClient client, GetEntityRequest request) where T : class
 {
     return(client.Entities.GetAsync <T>(request));
 }
        private static void BulkDelete(IMyCouchClient client, ViewQueryResponse<dynamic> response)
        {
            if (response.IsEmpty)
                return;

            var bulkRequest = new BulkRequest();

            foreach (var row in response.Rows)
            {
                if (row.Id.ToLower() == "_design/_replicator")
                    continue;

                bulkRequest.Delete(row.Id, row.Value.rev.ToString());
            }

            if(!bulkRequest.IsEmpty)
                client.Documents.BulkAsync(bulkRequest).Wait();
        }
 public ClientTestsFixture()
 {
     Client = IntegrationTestsRuntime.CreateNormalClient();
 }
Beispiel #21
0
 public static Task <ContinuousChangesResponse> PerformAsync(this IMyCouchClient client, GetChangesRequest request, Action <string> onRead, CancellationToken cancellationToken)
 {
     return(client.Changes.GetAsync(request, onRead, cancellationToken));
 }
 public virtual void Dispose()
 {
     Client.Dispose();
     Client = null;
 }
Beispiel #23
0
 public static Task <ChangesResponse> PerformAsync(this IMyCouchClient client, GetChangesRequest request)
 {
     return(client.Changes.GetAsync(request));
 }