Ejemplo n.º 1
0
 public TicketNote(string content, Ticket ticket)
 {
     Content = content;
     Created = DateTime.Now;
     Ticket = ticket;
     TicketId = ticket.TicketId;
 }
Ejemplo n.º 2
0
        public void CreateTicketNotesTest()
        {
            var context = new TicketsContext();

            var ticket = new Ticket();
            ticket.Title = "title";
            ticket.AddNewNote("t1");
            ticket.AddNewNote("t2");

            context.Tickets.Add(ticket);

            context.SaveChanges();
            int id = ticket.TicketId;

            context = new TicketsContext();
            context.Database.Log = Console.Write; // lazy loading. Remove "virtual" from _notes prop and test will fail.

            Ticket newticket = context.Tickets.Find(id);

            Assert.AreEqual(2, newticket.Notes.Count());
        }