Beispiel #1
0
        public void AddGalleryUrlsShouldAddMultipleImagesToMod()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "AddGalleryUrlsShouldAddMultipleImagesToMod_DB")
                          .Options;

            var dbContext  = new ApplicationDbContext(options);
            var modService = new ModService(dbContext);

            var urls = new List <string>();

            urls.Add("qqq");
            urls.Add("222");
            urls.Add("rrr");

            var mod = new Mod();

            dbContext.Mods.Add(mod);
            dbContext.SaveChanges();

            modService.AddGalleryUrls(mod.Id, urls);

            var gallery = mod.Pictures.ToList();

            Assert.Equal(3, gallery.Count);
        }
Beispiel #2
0
        public void DeleteImagesShouldRemoveTheImagesOfMod()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "RemoveImagesOnEditShouldRemoveTheImagesOfModOnEdit_DB")
                          .Options;

            var dbContext  = new ApplicationDbContext(options);
            var modService = new ModService(dbContext);

            var urls = new List <string>();

            urls.Add("qqq");
            urls.Add("222");
            urls.Add("rrr");

            var mod = new Mod();

            dbContext.Mods.Add(mod);
            dbContext.SaveChanges();

            modService.AddGalleryUrls(mod.Id, urls);

            modService.DeleteImages(mod.Id);

            Assert.Empty(mod.Pictures);
        }