Example #1
0
 public void CreateMainEntityTest()
 {
     var session = NHibernateHelper.GetCurrentSession();
     var expected = TransInvoke.InvokTransFunction(() =>
     {
         var q = new Question();
         q.Name = "Q1";
         session.Save(q);
         session.Flush();
         return q;
     });
     var session2 = NHibernateHelper.GetCurrentSession();
     var result = session2.Get<Question>(expected.QuestionID);
     Assert.AreEqual(result, expected);
     NHibernateHelper.CloseSession();
 }
Example #2
0
        private static Question CreateQAndA(ISession session)
        {
            var q = new Question();
            q.Name = "Q1";
            q.Answers.Add(new Answer() { Name = "A1", Question = q });
            q.Answers.Add(new Answer() { Name = "A2", Question = q });

            session.Save(q);
            foreach (var answer in q.Answers)
            {
                session.Save(answer);
            }
            return q;
        }