Пример #1
0
        public void ShouldHandleStreaming()
        {
            var design = new CouchDesignDocument("test", db);

            design.AddView("docs", "function (doc) { emit(null, null); } ");
            design.Synch();

            var doc = new CouchJsonDocument("{\"_id\":\"123\", \"CPU\": \"Intel\"}");

            db.SaveDocument(doc);

            var result = db.Query("test", "docs").StreamResult <CouchDocument>();

            Assert.That(result.FirstOrDefault() != null, "there should be one doc present");

            try
            {
                // this should throw an invalid operation exception
                result.FirstOrDefault();
            }
            finally
            {
                db.DeleteDocument(doc);
                db.DeleteDocument(design);
            }
        }
Пример #2
0
        private async Task _CreateDesign()
        {
            var client = GetTestClient();
            //Create document with two views
            var designDoc = new CouchDesignDocument();

            designDoc.ID = "testDesignDoc";
            designDoc.AddView("test", "function (doc) {emit(doc._id, 1);}");
            designDoc.AddView("testReduce", "function (doc) {emit(doc._id, 1);}", "_count");
            designDoc.AddUpdate("testupdate", "function(document,request){return [null, 'Edited World!'];}");
            var result = await client.UpsertDesignDocumentAsync(designDoc);

            Assert.True(result.Ok);
            Assert.True(!string.IsNullOrEmpty(designDoc.Rev), "Revision was not set during creation");
            Assert.True(designDoc.ID.StartsWith(CouchEntryPoints.DesignDoc), "New created design document doesnt start with _design");
            Assert.False(designDoc.Deleted, "Design document is marked as deleted!");
            LastDesignDoc = designDoc;
        }
Пример #3
0
        public void ShouldHandleStreaming()
        {
            var design = new CouchDesignDocument("test", db);
            design.AddView("docs", "function (doc) { emit(null, null); } ");
            design.Synch();

            var doc = new CouchJsonDocument("{\"_id\":\"123\", \"CPU\": \"Intel\"}");
            db.SaveDocument(doc);

            var result = db.Query("test", "docs").StreamResult<CouchDocument>();

            Assert.That(result.FirstOrDefault() != null, "there should be one doc present");

            try
            {
                // this should throw an invalid operation exception
                result.FirstOrDefault();
            }
            finally
            {
                db.DeleteDocument(doc);
                db.DeleteDocument(design);
            }
        }