public async Task AddAsyncShouldThrowArgumentNullForInvalidUrl(string url) { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "AddAsyncShouldThrowArgumentNullForInvalidUrl").Options; var dbContext = new ApplicationDbContext(options); var repository = new EfDeletableEntityRepository <Image>(dbContext); var service = new ImagesService(repository); await Assert.ThrowsAsync <ArgumentNullException>(() => service.AddAsync(url)); }
public async Task GetImageByUrlShouldWork() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "GetImageByUrlShouldWork").Options; var dbContext = new ApplicationDbContext(options); var repository = new EfDeletableEntityRepository <Image>(dbContext); var service = new ImagesService(repository); await service.AddAsync("random string"); Assert.Equal("random string", service.GetImageByUrl("random string").Url); }