Ejemplo n.º 1
0
        public static async Task <TestDocument> CreateTestDocument(string Database)
        {
            var testDoc = TestDocument.GenerateTestObject();
            var client  = CouchSettings.GetTestClient(Database);
            var result  = await client.CreateANewDocumentAsync(testDoc, DatabaseToCreateDocumentIn : Database);

            //Ensure all needed parts are set by the client
            Assert.True(result.Ok, "Error during document creation");
            Assert.False(string.IsNullOrEmpty(testDoc.ID), "ID was not set for new document");
            Assert.False(string.IsNullOrEmpty(testDoc.Rev), "Rev was not set for new document");
            return(testDoc);
        }
Ejemplo n.º 2
0
        public void PurgeDocuments()
        {
            var testDocTask = CreateTestDocument(this.TestDB);

            testDocTask.Wait();
            var testDoc = testDocTask.Result;
            var client  = CouchSettings.GetTestClient(this.TestDB);
            var result  = client.PurgeDocumentsInDatabase(new PurgeRequest()
            {
                DocumentsToPurge = new List <PurgeRequestDocument> {
                    new PurgeRequestDocument(testDoc.ID, new List <string> {
                        testDoc.Rev
                    })
                }
            });

            Assert.NotNull(result);
            Assert.True(result.Purged.ContainsKey(testDoc.ID));
            //Get document from db -> must fail
            var allDocs = client.GetAllDocuments();

            Assert.Empty(allDocs.Rows);
            //Purge multi revsions
            testDocTask        = CreateTestDocument(this.TestDB);
            testDoc            = testDocTask.Result;
            testDoc.StringProp = "Cat's everywhere";
            var firstRev = testDoc.Rev;

            client.UpdateDocument(testDoc);
            result = client.PurgeDocumentsInDatabase(new PurgeRequest()
            {
                DocumentsToPurge = new List <PurgeRequestDocument> {
                    new PurgeRequestDocument(testDoc.ID, new List <string> {
                        testDoc.Rev, firstRev
                    })
                }
            });
            Assert.NotNull(result);
            Assert.True(result.Purged.ContainsKey(testDoc.ID));
            allDocs = client.GetAllDocuments();
            Assert.Empty(allDocs.Rows);
        }
Ejemplo n.º 3
0
 public PillowClient GetTestClient(ELoginTypes LoginType = ELoginTypes.BasicAuth)
 {
     return(CouchSettings.GetTestClient(TestDB, LoginType));
 }