Inheritance: Zetbox.DalProvider.Ef.BaseServerDataObject_EntityFramework, TestObjClass
Exemplo n.º 1
0
        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));
            }
        }
Exemplo n.º 2
0
 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));
     }
 }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        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));
            }
        }