Beispiel #1
0
        protected FitCardContext GetInMemoryDBContext()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkSqlServer()
                                  .BuildServiceProvider();

            var builder = new DbContextOptionsBuilder <FitCardContext>();
            var options = builder.UseSqlServer(connectionString)
                          .UseInternalServiceProvider(serviceProvider)
                          .Options;

            FitCardContext dbContext = new FitCardContext(options);

            dbContext.Database.EnsureDeleted();
            dbContext.Database.EnsureCreated();
            return(dbContext);
        }
        public void Seed(FitCardContext context)
        {
            context.Categoria.Add(new CategoriaEntity {
                CategoriaNome = "Supermercado"
            });
            context.Categoria.Add(new CategoriaEntity {
                CategoriaNome = "Restaurante"
            });
            context.Categoria.Add(new CategoriaEntity {
                CategoriaNome = "Borracharia"
            });
            context.Categoria.Add(new CategoriaEntity {
                CategoriaNome = "Posto"
            });
            context.Categoria.Add(new CategoriaEntity {
                CategoriaNome = "Oficina"
            });
            context.SaveChanges();

            context.User.Add(new UserEntity {
                Nome = "FitCard", Email = "*****@*****.**"
            });
            context.SaveChanges();
        }
Beispiel #3
0
 public BaseTest(FitCardContext ctx = null)
 {
     this.ctx = ctx ?? GetInMemoryDBContext();
 }
 public CategoriaImplementation(FitCardContext context) : base(context)
 {
     _dataset = context.Set <CategoriaEntity>();
 }
Beispiel #5
0
 public EmpresaImplementation(FitCardContext context) : base(context)
 {
     _dataset = context.Set <EmpresaEntity>();
 }
Beispiel #6
0
 public BaseRepository(FitCardContext context)
 {
     _context = context;
     _dataset = _context.Set <T>();
 }
 public UserImplementation(FitCardContext context) : base(context)
 {
     _dataset = context.Set <UserEntity>();
 }