public CatalogContextFactory() { var contextOptions = new DbContextOptionsBuilder <CatalogContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .EnableSensitiveDataLogging() .Options; EnsureCreation(contextOptions); ContextInstance = new TestCatalogContext(contextOptions); GenreMapper = new GenreMapper(); ArtistMapper = new ArtistMapper(); ItemMapper = new ItemMapper(ArtistMapper, GenreMapper); }
public ItemRepositoryTests(CatalogContextFactory catalogContextFactory) { _context = catalogContextFactory.ContextInstance; _sut = new ItemRepository(_context); }
private void EnsureCreation(DbContextOptions <CatalogContext> contextOptions) { using var context = new TestCatalogContext(contextOptions); context.Database.EnsureCreated(); }