Beispiel #1
0
        public void RelationsOneToOne()
        {
            ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Employee), typeof(Award));
            Recreate();

            Award.DeleteAll();
            Employee.DeleteAll();

            Employee emp = new Employee();

            emp.FirstName = "john";
            emp.LastName  = "doe";
            emp.Save();

            Assert.AreEqual(1, Employee.FindAll().Length);

            Award award = new Award(emp);

            award.Description = "Invisible employee";
            award.Save();

            Assert.AreEqual(1, Award.FindAll().Length);

            Employee emp2 = Employee.Find(emp.ID);

            Assert.IsNotNull(emp2);
            Assert.IsNotNull(emp2.Award);
            Assert.AreEqual(emp.FirstName, emp2.FirstName);
            Assert.AreEqual(emp.LastName, emp2.LastName);
            Assert.AreEqual(award.Description, emp2.Award.Description);
        }
        public void Setup()
        {
            ActiveRecordStarter.Initialize(GetConfigSource(),
                                           typeof(Blog),
                                           typeof(Post),
                                           typeof(Company),
                                           typeof(Award),
                                           typeof(Employee),
                                           typeof(Person));
            Recreate();

            Post.DeleteAll();
            Blog.DeleteAll();
            Company.DeleteAll();
            Award.DeleteAll();
            Employee.DeleteAll();
        }