コード例 #1
0
        public void T120_DisallowPersistChildWithoutMandatoryParent()
        {
            Session.BeginUpdate();
            var motherlessDaughter = new Daughter(QueryHelper)
            {
                Name = "Carol"
            };

            Assert.Throws <PropertyConstraintException>(() =>
                                                        Session.Persist(motherlessDaughter));
            Session.Commit();
        }
コード例 #2
0
 public override void Setup()
 {
     base.Setup();
     Mother1 = new Mother(QueryHelper);
     Mother2 = new Mother(QueryHelper)
     {
         Name = Mother2Name
     };
     Daughter1 = new Daughter(QueryHelper);
     Daughter2 = new Daughter(QueryHelper);
     Father1   = new Father(QueryHelper);
     Father2   = new Father(QueryHelper)
     {
         Name = Father2Name
     };
     Son1 = new Son(QueryHelper);
     Son2 = new Son(QueryHelper);
     Session.BeginUpdate();
     Mother1.Name = Mother1Name;
     Session.Persist(Mother1);
     Session.Persist(Mother2);
     Father1.Name = Father1Name;
     Session.Persist(Father1);
     Session.Persist(Father2);
     Daughter1.Name   = Daughter1Name;
     Daughter1.Mother = Mother1;
     Session.Persist(Daughter1);
     Daughter2.Name   = Daughter2Name;
     Daughter2.Mother = Mother2;
     Session.Persist(Daughter2);
     Son1.Name = Son1Name;
     Session.Persist(Son1);
     Son2.Name = Son2Name;
     Session.Persist(Son2);
     Son1.Father      = Father1;
     Son1.Mother      = Mother1;
     Son2.Mother      = Mother1;
     Daughter1.Father = Father1;
     Daughter2.Father = Father1;
     Session.Commit();
 }