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(); }
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; }