var em = new DomainModelEntityManager();
var aCustomer = CreateNewCustomer(em);
DoAsyncAction(() => {
em.SaveChangesAsync(op => {
Assert.IsTrue(op.CompletedSuccessfully);
//var savedCustomer = em.FindEntities<Customer>(EntityState.AllButDetached).First();
//var savedOrder = em.FindEntities<Order>(EntityState.AllButDetached).First();
var savedCustomer = op.Entities.OfType<Customer>().First();
var savedOrder = op.Entities.OfType<Order>().First();
Assert.IsTrue(savedCustomer.Orders.First().OrderID == savedOrder.OrderID);
Assert.IsTrue(savedOrder.CustomerID == savedCustomer.CustomerID);
var oldShipName = savedOrder.ShipName;
savedOrder.ShipName += DateTime.Now.Millisecond.ToString();
savedOrder.EntityAspect.RejectChanges();
Assert.IsTrue(savedOrder.ShipName == oldShipName);
var newShipName = savedOrder.ShipName + DateTime.Now.Millisecond.ToString();
savedOrder.ShipName = newShipName;
em.SaveChangesAsync(op2 => {
Assert.IsTrue(op2.CompletedSuccessfully);
var theSavedOrder = (Order)op2.Entities.First();
Assert.IsTrue(theSavedOrder.ShipName == newShipName);
Exit();
});
});
});