Пример #1
0
        public void AddFileUrlShouldAddFileToMod()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "AddFileUrlShouldAddFileToMod_DB")
                          .Options;

            var dbContext = new ApplicationDbContext(options);

            var modService = new ModService(dbContext);
            var file       = new Mock <IFormFile>();
            var mod        = new Mod();

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

            modService.AddFileUrl(mod.Id, null, null, null, 10000000);

            Assert.Single(mod.Files);
        }
Пример #2
0
        public void DeleteFilesShouldDeleteFilesFromMod()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "DeleteFilesShouldDeleteFilesFromMod_DB")
                          .Options;

            var dbContext = new ApplicationDbContext(options);

            var modService = new ModService(dbContext);

            var mod = new Mod();

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

            modService.AddFileUrl(mod.Id, null, null, null, 10000000);
            modService.DeleteFiles(mod.Id);

            Assert.Empty(mod.Files);
        }