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_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 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); } }
public void Attach_IDataObject_Existing_Twice_But_Different() { using (IZetboxContext ctx = GetContext()) { TestObjClass obj1 = new TestObjClassEfImpl(null) { ID = 3, ClientObjectState = DataObjectState.Unmodified }; Assert.That(((TestObjClassEfImpl)obj1).EntityState, Is.EqualTo(EntityState.Detached)); ctx.Attach(obj1); Assert.That(((TestObjClassEfImpl)obj1).EntityState, Is.EqualTo(EntityState.Unchanged)); TestObjClass obj2 = new TestObjClassEfImpl(null) { ID = 3, ClientObjectState = DataObjectState.Unmodified }; Assert.That(((TestObjClassEfImpl)obj2).EntityState, Is.EqualTo(EntityState.Detached)); ctx.Attach(obj2); Assert.That(((TestObjClassEfImpl)obj2).EntityState, Is.EqualTo(EntityState.Unchanged)); } }