Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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);
        }