public void Should_delete_document() { var documentDb = new DocSharp(DbName); var document = documentDb.Store(new Company() { Name = "My Company" }); documentDb.Delete(document.Id); documentDb.Dispose(); using (var documentDb2 = new DocSharp(DbName)) { var foundDocument = documentDb2.Load<Company>(document.Id); Assert.IsNull(foundDocument); } }
public void Should_Create_document_db() { var documentDb = new DocSharp(DbName); Assert.IsTrue(File.Exists(DbName)); documentDb .Dispose(); }
public void Should_store_document() { var documentDb = new DocSharp(DbName); documentDb.Store(new Company() { Name = "My Company 221 " }); var document = documentDb.Store(new Company() { Name = "My Company"}); documentDb.Dispose(); var db2 = new DocSharp(DbName); var document2 = db2.Load<Company>(document.Id); db2.Dispose(); Assert.AreEqual(document2.Data.Name, document.Data.Name); }
public void Should_update_an_existing_document() { var documentDb = new DocSharp(DbName); var document = documentDb.Store(new Company { Name = "My Company" }); document.Data.Name = "Updated"; documentDb.Update(document); documentDb.Dispose(); using(var documentDb2 = new DocSharp(DbName)) { var foundDocument = documentDb2.Load<Company>(document.Id); Assert.AreEqual(foundDocument.Data.Name, "Updated"); } }
public void Should_store_and_retrieve_multiple_documents() { var documentDb = new DocSharp(DbName); var newDocument1 = documentDb.Store(new Company { Name = "My Company" }); var newDocument2 = documentDb.Store(new Company { Name = "My Company2" }); var newDocument3 = documentDb.Store(new Company { Name = "My Company3" }); documentDb.Dispose(); var db2 = new DocSharp(DbName); var storedDocument1 = db2.Load<Company>(newDocument1.Id); Assert.AreEqual(storedDocument1.Data.Name, newDocument1.Data.Name); var storedDocument2 = db2.Load<Company>(newDocument2.Id); Assert.AreEqual(storedDocument2.Data.Name, newDocument2.Data.Name); var storedDocument3 = db2.Load<Company>(newDocument3.Id); Assert.AreEqual(storedDocument3.Data.Name, newDocument3.Data.Name); db2.Dispose(); }