예제 #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
파일: CouchTest.cs 프로젝트: kolosy/Divan
        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);
            }
        }