Example #1
0
    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);
 }
Example #3
0
 private void EnsureCreation(DbContextOptions <CatalogContext> contextOptions)
 {
     using var context = new TestCatalogContext(contextOptions);
     context.Database.EnsureCreated();
 }