public void DeleteShouldDeleteModAndReduceModCount() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "DeleteShouldDeleteModAndReduceModCount_DB") .Options; var dbContext = new ApplicationDbContext(options); var modService = new ModService(dbContext); var game = new Game { ModCount = 10, }; var user = new ApplicationUser { ModCount = 6, }; dbContext.Users.Add(user); dbContext.Games.Add(game); dbContext.SaveChanges(); var mod = new Mod { Game = game, User = user, }; dbContext.Mods.Add(mod); dbContext.SaveChanges(); modService.Delete(mod.Id); Assert.Equal(9, game.ModCount); Assert.Equal(5, user.ModCount); }