Ejemplo n.º 1
0
        public void CanInsertTicket()
        {
            var session = NHibernateHelper.GetCurrentSession();

            var project = new Project { Title = "Test", Description = "test" };
            session.Save(project);
            var ticket = new Ticket { Project = project, Title = "Test Ticket", Description = "Test test" };
            session.Save(ticket);

            NHibernateHelper.CloseSession();
        }
Ejemplo n.º 2
0
        public void CanInsertComment()
        {
            var session = NHibernateHelper.GetCurrentSession();

            var project = new Project { Title = "Test", Description = "test" };
            session.Save(project);
            var ticket = new Ticket { Project = project, Title = "Test Ticket", Description = "Test test" };
            session.Save(ticket);
            var user = new User { Name = "Neo", Email = "*****@*****.**", Password = "******" };
            session.Save(user);
            var comment = new Comment { Body = "This is a comment", CreatedAt = DateTime.Now, Ticket = ticket, User = user };
            session.Save(comment);

            NHibernateHelper.CloseSession();
        }
Ejemplo n.º 3
0
        public void GettingProjectAlsoGetsTickets()
        {
            var session = NHibernateHelper.GetCurrentSession();

            var project = new Project { Title = "Test", Description = "test" };
            session.Save(project);
            var ticket = new Ticket { Project = project, Title = "Test Ticket", Description = "Test test" };
            session.Save(ticket);

            NHibernateHelper.CloseSession();

            session = NHibernateHelper.GetCurrentSession();

            var result = session.Get<Project>(project.Id);

            Assert.IsType<Project>(result);
            Assert.Equal("Test Ticket", result.Tickets.First().Title);

            NHibernateHelper.CloseSession();
        }