public AuthorRepositoryTests() { _options = new DbContextOptionsBuilder <TecH3DemoContext>() .UseInMemoryDatabase(databaseName: "AuthorsDataBase") .Options; _context = new TecH3DemoContext(_options); _authorRepository = new AuthorRepository(_context); _context.Database.EnsureDeleted(); // makes sure data is fresh and new every time _context.Author.Add(new Author { Id = 1, FirstName = "Albert", LastName = "Andersen" }); _context.Author.Add(new Author { Id = 2, FirstName = "Benny", LastName = "Bomstærk" }); _context.Author.Add(new Author { Id = 3, FirstName = "Carlo", LastName = "Cool" }); _context.SaveChanges(); }
public AuthorRepository(TecH3DemoContext context) { _context = context; }