public void Attach_IDataObject_New() { using (IZetboxContext ctx = GetContext()) { TestObjClass obj = new TestObjClassEfImpl(null); Assert.That(((TestObjClassEfImpl)obj).EntityState, Is.EqualTo(EntityState.Detached)); ctx.Internals().AttachAsNew(obj); Assert.That(((TestObjClassEfImpl)obj).EntityState, Is.EqualTo(EntityState.Added)); } }
public void AttachedObjects() { using (IZetboxContext ctx = GetContext()) { TestObjClass obj = new TestObjClassEfImpl(null); ctx.Attach(obj); ctx.Create <TestObjClass>(); Assert.That(ctx.AttachedObjects.Count(), Is.EqualTo(2)); } }
public void Attach_IDataObject_Existing() { using (IZetboxContext ctx = GetContext()) { TestObjClass obj = new TestObjClassEfImpl(null) { ID = 3, ClientObjectState = DataObjectState.Unmodified }; Assert.That(((TestObjClassEfImpl)obj).EntityState, Is.EqualTo(EntityState.Detached)); ctx.Attach(obj); Assert.That(((TestObjClassEfImpl)obj).EntityState, Is.EqualTo(EntityState.Unchanged)); } }
public void ContainsObject_Not() { using (IZetboxContext ctx = GetContext()) { TestObjClass obj = new TestObjClassEfImpl(null) { ID = 10 }; ctx.Create <TestObjClass>(); Assert.That(ctx.AttachedObjects.Count(), Is.EqualTo(1)); Assert.That(ctx.ContainsObject(ctx.GetInterfaceType(obj), obj.ID), Is.Null); } }