[TestMethod]public void TestUnresolvedParentMap()
{
var em = new EntityManager();
//Make a new Employee
var e = em.CreateEntity<Employee>();
e.EntityAspect.AddToManager();
e.EmployeeID = 10; //Giving it an ID isn't necessary for the bug
//Immediately remove it from the entity manager - in this case, we'd assume it
// disappears forever...
e.EntityAspect.RemoveFromManager();
//Sanity check - it became detached and the entity manager no longer thinks it is loaded
Assert.AreEqual(EntityState.Detached, e.EntityAspect.EntityState);
Assert.IsFalse(em.IsEntityLoaded(e.EntityAspect.EntityKey));
//If we break into the debugger at this point, we can see that em.UnresolvedParentMap is still
// holding on to our employee even though it is detached.
//To double check, we'll use a weak reference to hold on to the employee
var wr = new WeakReference(e);
//Clear out of 'strong' reference and force garbage collection to happen
e = null;
GC.Collect();
//At this point, we'd expect the employee to be gone. But it's not!
Assert.IsFalse(wr.IsAlive);
}