public async Task AddAsyncShouldWork() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "AddAsyncShouldWork").Options; var dbContext = new ApplicationDbContext(options); var repository = new EfDeletableEntityRepository <VehicleCategory>(dbContext); var service = new VehicleCategoriesService(repository); Assert.Empty(service.GetAll <VehicleCategory>()); await service.AddAsync("Sedan"); Assert.Single(service.GetAll <VehicleCategory>()); }
public async Task GetAllGenericShouldWork() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "GetAllGenericShouldWork").Options; var dbContext = new ApplicationDbContext(options); dbContext.VehicleCategories.Add(new VehicleCategory()); dbContext.VehicleCategories.Add(new VehicleCategory()); dbContext.VehicleCategories.Add(new VehicleCategory()); await dbContext.SaveChangesAsync(); var repository = new EfDeletableEntityRepository <VehicleCategory>(dbContext); var service = new VehicleCategoriesService(repository); Assert.Equal(3, service.GetAll <VehicleCategory>().Count()); }