public void CanDeleteExistingDocumentByObject() { var person = new Person { FirstName = "Michael", LastName = "Carter", Age = 43, Home = new Address { City = "Chesapeake", State = "VA" } }; using (var session = _store.OpenSession()) { session.Store(person); session.SaveChanges(); } using (var session = _store.OpenSession()) { var existing = session.Load<Person>(person.Id); session.Delete(existing); session.SaveChanges(); } using (var session = _store.OpenSession()) { var deleted = session.Load<Person>(person.Id); Assert.IsNull(deleted); } }
public void CanLoadExistingDocument() { var person = new Person { FirstName = "Michael", LastName = "Carter", Age = 43, Home = new Address { City = "Chesapeake", State = "VA" } }; using (var session = _store.OpenSession()) { session.Store(person); session.SaveChanges(); } using (var session = _store.OpenSession()) { var existing = session.Load<Person>(person.Id); Assert.IsTrue(person.Id == existing.Id); Assert.IsTrue(person.FirstName == existing.FirstName); Assert.IsTrue(person.LastName == existing.LastName); Assert.IsTrue(person.Age == existing.Age); } }
public void LoadingSameDocumentWillReturnSameObject() { var person = new Person { FirstName = "Michael", LastName = "Carter", Age = 43, Home = new Address { City = "Chesapeake", State = "VA" } }; using (var session = _store.OpenSession()) { session.Store(person); session.SaveChanges(); } using (var session = _store.OpenSession()) { var existing = session.Load<Person>(person.Id); var existing2 = session.Load<Person>(person.Id); Assert.IsTrue(existing == existing2); } }
public void ModifyingDocumentAndNotCallingSaveChangesWillNotPersistChanges() { var person = new Person { FirstName = "Michael", LastName = "Carter", Age = 43, Home = new Address { City = "Chesapeake", State = "VA" } }; using (var session = _store.OpenSession()) { session.Store(person); session.SaveChanges(); } using (var session = _store.OpenSession()) { var existing = session.Load<Person>(person.Id); existing.FirstName = "Mike"; } using (var session = _store.OpenSession()) { var existing = session.Load<Person>(person.Id); Assert.IsTrue(existing.FirstName == "Michael"); } }
public void CanSaveDocument() { var person = new Person { FirstName = "Michael", LastName = "Carter", Age = 43, Home = new Address { City = "Chesapeake", State = "VA" } }; using (var session = _store.OpenSession()) { session.Store(person); session.SaveChanges(); } }