public void DeleteDocument() { var newDocument = new MyDocument { Content = "New Content" }; using (var session = _documentStore.OpenSession()) { session.Store(newDocument); session.SaveChanges(); } using (var anotherSession = _documentStore.OpenSession()) { var existingDocument = anotherSession.Load <MyDocument>(newDocument.Id); anotherSession.Delete(existingDocument); anotherSession.SaveChanges(); } MyDocument deletedDocument; using (var yetAnotherSession = _documentStore.OpenSession()) { deletedDocument = yetAnotherSession.Load <MyDocument>(newDocument.Id); } Assert.IsNull(deletedDocument); }
public void ModifyDocument() { const string modifiedContent = "Modified content"; var newDocument = new MyDocument { Content = "New Content" }; using (var session = _documentStore.OpenSession()) { session.Store(newDocument); session.SaveChanges(); } using (var anotherSession = _documentStore.OpenSession()) { var existingDocument = anotherSession.Load <MyDocument>(newDocument.Id); existingDocument.Content = modifiedContent; anotherSession.SaveChanges(); } MyDocument modifiedDocument; using (var yetAnotherSession = _documentStore.OpenSession()) { modifiedDocument = yetAnotherSession.Load <MyDocument>(newDocument.Id); } Assert.AreEqual(modifiedDocument.Content, modifiedContent); Assert.AreNotEqual(modifiedDocument.Content, newDocument.Content); Assert.AreNotSame(modifiedDocument, newDocument); }
public void SampleTest() { MyDocument document; using (var session = _embeddableDocumentStore.OpenSession()) { document = new MyDocument { Content = "Some Content", Integer = 1, Double = 1.0, Decimal = 2m, Date = DateTime.UtcNow, Array = new[] { "Item 1", "Item 2" }, ChildObject = new ChildObject { Hello = "World!" }, AnonymousObject = new { Thing = "Stuff" } }; session.Store(document); } Assert.IsNotEmpty(document.Id); }