Exemple #1
0
        public async Task GetAllShouldReturnCorrectNumberUsingDbContext()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext = new ApplicationDbContext(options);

            dbContext.Companies.Add(new Company());
            dbContext.Companies.Add(new Company());
            dbContext.Companies.Add(new Company());
            await dbContext.SaveChangesAsync();

            var repository = new EfDeletableEntityRepository <Company>(dbContext);
            var service    = new CompaniesService(repository);

            Assert.Equal(3, await service.GetCountAsync());
        }