private static void CreateAndCountTicket() { using (var context = new SqLiteTicketsDbContext()) { var ticket = new Ticket { Title = "Title", Details = "Details", CreatedAt = DateTime.Now }; ticket.AddComment("Some Comment", -1); ticket.AddComment("Some Other Comment", -1); context.Tickets.Add(ticket); context.SaveChanges(); } using (var context = new SqLiteTicketsDbContext()) { var ticket = context.Tickets .Include(t => t.Comments) .FirstOrDefault(); Assert.That(ticket, Is.Not.Null); Assert.That(ticket.Comments.Count, Is.EqualTo(2)); var ticketCount = context.Tickets.Count(); Assert.That(ticketCount, Is.EqualTo(1)); } }
public void SetUp() { using (var context = new SqLiteTicketsDbContext()) { context.Database.ExecuteSqlCommand("DELETE FROM Comments"); context.Database.ExecuteSqlCommand("DELETE FROM Tickets"); context.Database.ExecuteSqlCommand("DELETE FROM AppUsers"); } }