Example #1
0
        public static InterviewTestDbContext Create()
        {
            var options = new DbContextOptionsBuilder <InterviewTestDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var context = new InterviewTestDbContext(options);

            context.Database.EnsureCreated();

            context.Groups.AddRange(new[]
            {
                new Domain.Entities.Group {
                    Name = "Foo"
                },
                new Domain.Entities.Group {
                    Name = "Bar"
                }
            });

            context.Persons.AddRange(new[] {
                new Domain.Entities.Person {
                    Fullname = "Adam Cogan", GroupId = 1, DateTimeAdded = DateTime.Now
                },
                new Domain.Entities.Person {
                    Fullname = "Jason Taylor", GroupId = 1, DateTimeAdded = DateTime.Now
                },
                new Domain.Entities.Person {
                    Fullname = "Brendan Richards", GroupId = 2, DateTimeAdded = DateTime.Now
                },
            });

            context.SaveChanges();

            return(context);
        }
Example #2
0
 public CommandTestBase()
 {
     _context = InterviewTestContextFactory.Create();
 }
Example #3
0
        public static void Destroy(InterviewTestDbContext context)
        {
            context.Database.EnsureDeleted();

            context.Dispose();
        }