public HomeControllerTest() { // Initialize DbContext in memory var optionsBuilder = new DbContextOptionsBuilder(); optionsBuilder.UseInMemoryDatabase(); _context = new MyDbContext(optionsBuilder.Options); // Seed data _context.People.Add(new Person() { FirstName = "John", LastName = "Doe" }); _context.People.Add(new Person() { FirstName = "Sally", LastName = "Doe" }); _context.SaveChanges(); // Create test subject _controller = new HomeController(_context); }
public HomeController(MyDbContext context) { _context = context; }