protected Level GetTestLevel(int testWorld = 9999, int sequenceInWorld = 1, int startingFuel = 100, int startingTime = 500, bool active = true, bool isBlockingLevel = false) { Level level = _context.Levels.Add(new Level { World = testWorld, SequenceInWorld = sequenceInWorld, StartingFuel = startingFuel, StartingTime = startingTime, Active = active, IsBlockingLevel = isBlockingLevel }); _context.SaveChanges(); LevelIdsToCleanup.Add(level.Id); return(level); }
protected virtual void CleanTests() { var db = new AlienzApiContext(); if (PlayerPowerupUsagesIdsToCleanup.Any()) { var usages = db.PlayerPowerupUsages.Where(l => PlayerPowerupUsagesIdsToCleanup.Contains(l.Id)); foreach (var usage in usages) { db.PlayerPowerupUsages.Remove(usage); } db.SaveChanges(); } if (EnergyPurchaseIdsToCleanup.Any()) { var purchases = db.EnergyPurchases.Where(l => EnergyPurchaseIdsToCleanup.Contains(l.Id)); foreach (var purchase in purchases) { db.EnergyPurchases.Remove(purchase); } db.SaveChanges(); } if (PlayerDeathIdsToCleanup.Any()) { var playerDeaths = db.PlayerDeaths.Where(l => PlayerDeathIdsToCleanup.Contains(l.Id)); foreach (var death in playerDeaths) { db.PlayerDeaths.Remove(death); } db.SaveChanges(); } if (LevelAttemptIdsToCleanup.Any()) { var levelAttempts = db.LevelAttempts.Where(l => LevelAttemptIdsToCleanup.Contains(l.Id)); foreach (var attempt in levelAttempts) { db.LevelAttempts.Remove(attempt); } db.SaveChanges(); } if (TierScoreRewardIdsToCleanup.Any()) { var tierScoreRewards = db.TierScoreRewards.Where(l => TierScoreRewardIdsToCleanup.Contains(l.Id)); foreach (var tierScoreReward in tierScoreRewards) { db.TierScoreRewards.Remove(tierScoreReward); } db.SaveChanges(); } if (AwardReasonIdsToCleanup.Any()) { var awardReasons = db.AwardReasons.Where(l => AwardReasonIdsToCleanup.Contains(l.Id)); foreach (var awardReason in awardReasons) { db.AwardReasons.Remove(awardReason); } db.SaveChanges(); } if (LevelIdsToCleanup.Any()) { var levels = db.Levels.Where(l => LevelIdsToCleanup.Contains(l.Id)); foreach (var level in levels) { db.Levels.Remove(level); } db.SaveChanges(); } if (PlayerIdsToCleanup.Any()) { var players = db.Players.Where(l => PlayerIdsToCleanup.Contains(l.Id)); foreach (var player in players) { db.Players.Remove(player); } db.SaveChanges(); } ResetLists(); }