public static CBVinilContext Create(ITestSeed seed)
        {
            var dbName = Guid.NewGuid().ToString() + DateTime.Now.ToLongTimeString();

            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkInMemoryDatabase()
                                  .AddEntityFrameworkProxies()
                                  .BuildServiceProvider();

            var options = new DbContextOptionsBuilder <CBVinilContext>()
                          .UseInMemoryDatabase(dbName)
                          .UseInternalServiceProvider(serviceProvider)
                          .UseLazyLoadingProxies()
                          .Options;

            var context = new CBVinilContext(options);

            context.Database.EnsureDeleted();

            context.Database.EnsureCreated();

            if (seed != null)
            {
                seed.Seed(context);
            }

            context.SaveChanges();

            return(context);
        }
示例#2
0
 public void Seed(CBVinilContext context)
 {
     context.GeneroMusical.AddRange(GeneroMusicalSeed.Seeds);
     context.DiaSemana.AddRange(DiaSemanaSeed.Seeds);
     context.Disco.AddRange(DiscoTestSeed.Seeds);
     context.Venda.AddRange(VendaTestSeed.Seeds);
 }
示例#3
0
 public void Seed(CBVinilContext context)
 {
     context.GeneroMusical.AddRange(GeneroMusicalSeed.Seeds);
     context.DiaSemana.AddRange(DiaSemanaSeed.Seeds);
     context.CashbackParametro.AddRange(CashbackParametroSeed.Seeds);
     context.Disco.AddRange(DiscoTestSeed.Seeds);
     context.Venda.AddRange(Seeds);
 }
 public GetVendasQueryHandler(CBVinilContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
示例#5
0
 public SpotifyService(CBVinilContext context, IOptions <SpotifySettings> options)
 {
     _context         = context;
     _spotifySettings = options.Value;
 }
 public VenderDiscosCommandHandler(CBVinilContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
 public GetGenerosMusicaisQueryHandler(CBVinilContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
示例#8
0
 public void Seed(CBVinilContext context)
 {
     context.GeneroMusical.AddRange(GeneroMusicalSeed.Seeds);
     context.Disco.AddRange(Seeds);
 }
        public static void Destroy(CBVinilContext context)
        {
            context.Database.EnsureDeleted();

            context.Dispose();
        }
示例#10
0
 public TestBase(ITestSeed seed)
 {
     _context = CBVinilContextFactoryTests.Create(seed);
     _mapper  = AutoMapperFactory.Create();
 }