public async Task AddAsyncShouldThrowArgumentNullForInvalidName(string name) { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "AddAsyncShouldThrowArgumentNullForInvalidName").Options; var dbContext = new ApplicationDbContext(options); var repository = new EfDeletableEntityRepository <VehicleCategory>(dbContext); var service = new VehicleCategoriesService(repository); await Assert.ThrowsAsync <ArgumentNullException>(() => service.AddAsync(name)); }
public async Task GetByNameShouldWork() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "GetByNameShouldWork").Options; var dbContext = new ApplicationDbContext(options); var repository = new EfDeletableEntityRepository <VehicleCategory>(dbContext); var service = new VehicleCategoriesService(repository); await service.AddAsync("Sedan"); Assert.Equal("Sedan", service.GetVehicleCategoryByName("Sedan").Name); }