public ContactRepositoryTests(ITestOutputHelper output)
        {
            _output = output;
            var dbOptions = new DbContextOptionsBuilder <EvoContactsDbContext>()
                            .UseInMemoryDatabase(databaseName: "EvoContacts-Tests")
                            .Options;

            _dbContext = new EvoContactsDbContext(dbOptions);

            var seedContacts = SeedData.Contacts.Where(x => !_dbContext.Contacts.Where(c => !c.IsDeleted).Any(c => c.Email == x.Email));

            //Seed missing Contacts
            if (seedContacts.Any())
            {
                _dbContext.Contacts.AddRange(seedContacts);
                _dbContext.SaveChanges();
            }

            _contactRepository = new ContactRepository(_dbContext);
        }
示例#2
0
 public EfRepository(EvoContactsDbContext context)
 {
     _dbContext = context;
     _dbSet     = _dbContext.Set <T>();
 }
示例#3
0
 public ContactRepository(EvoContactsDbContext dbContext) : base(dbContext)
 {
 }