public void Save_updates_document_if_it_has_a_rev() { requester.ReturnThis(CouchDbTestServer.TestDb1 + "/" + CouchDbTestServer.DocumentId1, "{\"ok\":true,\"id\":\"" + CouchDbTestServer.DocumentId1 + "\",\"rev\":\"2-2739352689\"}"); TestDocument document = new TestDocument { Test = new Random().Next().ToString() }; TestDocument savedDocument = database.Save(document); savedDocument.Test = "abc"; TestDocument updatedDocument = database.Save(savedDocument); Assert.Equal("2-2739352689", updatedDocument.Rev); }
public void When_saving_if_document_already_has_id_then_that_is_used() { string documentId = "Document0"; requester.ReturnThis(CouchDbTestServer.TestDb1 + "/" + documentId, "{\"ok\":true,\"id\":\"" + documentId + "\",\"rev\":\"1-5d978e67df51d48cc5876a09053ee342\"}"); TestDocument document = new TestDocument { Id = documentId, Test = new Random().Next().ToString() }; TestDocument savedDocument = database.Save(document); Assert.Equal(documentId, savedDocument.Id); }
public void Save_stores_document_on_the_server() { requester.ReturnThis(CouchDbTestServer.TestDb1 + "/" + CouchDbTestServer.DocumentId1, "{\"ok\":true,\"id\":\"" + CouchDbTestServer.DocumentId1 + "\",\"rev\":\"1-5d978e67df51d48cc5876a09053ee342\"}"); TestDocument document = new TestDocument { Test = new Random().Next().ToString() }; TestDocument savedDocument = database.Save(document); Assert.True(savedDocument.Rev.StartsWith("1")); Assert.Equal(CouchDbTestServer.DocumentId1, savedDocument.Id); }