Example #1
0
        public void Entities()
        {
            Assert.IsTrue(NHibernate.Cfg.Environment.UseReflectionOptimizer);
            ActiveRecordStarter.Initialize(GetConfigSource(),
                                           typeof(Model.GenericModel.Entity <>),
                                           typeof(CompanyEntity),
                                           typeof(PersonEntity));
            Assert.IsFalse(NHibernate.Cfg.Environment.UseReflectionOptimizer);
            Recreate();

            CompanyEntity.DeleteAll();
            PersonEntity.DeleteAll();

            CompanyEntity ce = new CompanyEntity();

            ce.Name        = "Keldor";
            ce.CompanyType = 1;
            ce.Save();

            CompanyEntity[] ces = CompanyEntity.FindAll();
            Assert.AreEqual(1, ces.Length);

            PersonEntity[] pes = PersonEntity.FindAll();
            Assert.AreEqual(0, pes.Length);

            Assert.AreEqual(ce.CompId, ces[0].CompId);
            Assert.AreEqual(ce.Name, ces[0].Name);
            Assert.AreEqual(ce.Id, ces[0].Id);
        }
        public void Entities()
        {
            Assert.IsTrue(NHibernate.Cfg.Environment.UseReflectionOptimizer);
            ActiveRecordStarter.Initialize(GetConfigSource(),
                typeof(Model.GenericModel.Entity<>),
                typeof(CompanyEntity),
                typeof(PersonEntity));
            Assert.IsFalse(NHibernate.Cfg.Environment.UseReflectionOptimizer);
            Recreate();

            CompanyEntity.DeleteAll();
            PersonEntity.DeleteAll();

            CompanyEntity ce = new CompanyEntity();
            ce.Name = "Keldor";
            ce.CompanyType = 1;
            ce.Save();

            CompanyEntity[] ces = CompanyEntity.FindAll();
            Assert.AreEqual( 1, ces.Length );

            PersonEntity[] pes = PersonEntity.FindAll();
            Assert.AreEqual( 0, pes.Length );

            Assert.AreEqual( ce.CompId, ces[0].CompId );
            Assert.AreEqual( ce.Name, ces[0].Name );
            Assert.AreEqual( ce.Id, ces[0].Id );
        }