public void CanRetrySaveOfAnAggregateUsingAnotherSession() { //setup - trigger an exception when updating... Customer c = Om.CreateCustomer(); Address a = Om.CreateAddress(); c.AddAddress(a); Nh.CurrentSession.SaveOrUpdate(c); c.ShortCode = "12345678"; //update will fail when saved to the db CommitSessionExpectingException(); //run test... c.ShortCode = "ABCDE"; //correct problem that was causing save to fail ResetVersionPropertyTo(c, -1); ResetVersionPropertyTo(a, -1); PersistUsingNewSession(c); Assert.That(c.ConcurrencyId, Is.EqualTo(1), "customer has been saved"); Assert.That(a.ConcurrencyId, Is.EqualTo(1), "address has been saved"); }
public void FlushWillReachNewObjectsAttachedToAPersistenceInstanceAfterSave() { Customer c = Om.CreateCustomer(); Nh.CurrentSession.SaveOrUpdate(c); //note that customer already associated with session Address a = Om.CreateAddress(); c.AddAddress(a); Nh.FlushSessionToDbAndClear(); var loadedCustomer = Nh.CurrentSession.Get <Customer>(c.Id); Assert.That(loadedCustomer.Addresses.Count, Is.EqualTo(1)); }
public void NHibernateCriteriaSpikesSetup() { Customer c1 = Om.CreateCustomerWithOneAddress(); Customer c2 = Om.CreateCustomerWithOneAddress(); c2.AddAddress(Om.CreateAddress("ME5 8HU")); Customer c3 = Om.CreateCustomer(); c3.Name = "Mervyn Ramos"; Customer c4 = Om.CreateCustomer(); c4.ShortCode = "009"; _customersInDb = new List <Customer>(); _customersInDb.AddRange(new[] { c1, c2, c3, c4 }); Nh.InsertIntoDb(_customersInDb); }