public static void PrepareDatabaseForTest(LadderDBContext db) { db.Ladders.AddRange( new LadderEntry() { LadderId = "existingLadder", Platform = "Nintendo360", Username = "******", Score = 666 }, new LadderEntry() { LadderId = "existingLadder", Platform = "Super Famicom", Username = "******", Score = 6666 }, new LadderEntry() { LadderId = "existingLadder", Platform = "Nintendo360", Username = "******", Score = 999999 } ); db.SaveChanges(); }
public void GetTopEntries_ReturnsTopNEntriesForSpecifiedLadder() { var TopN = 1; var ladderId = "myLadder"; var platform = "PC"; //Here we add entries to db using context directly to test repository var secondPlayer = new LadderEntry { LadderId = ladderId, Platform = platform, Username = "******", Score = 1000 }; var firstPlayer = new LadderEntry { LadderId = ladderId, Platform = platform, Username = "******", Score = 999 }; var anotherPlatformPlayer = new LadderEntry { LadderId = ladderId, Platform = "AnotherPlatform", Username = "******", Score = 1 }; var anotherLadderPlayer = new LadderEntry { LadderId = "AnotherLadder", Platform = platform, Username = "******", Score = 1 }; _dbContext.Ladders.Add(secondPlayer); _dbContext.Ladders.Add(firstPlayer); _dbContext.Ladders.Add(anotherPlatformPlayer); _dbContext.Ladders.Add(anotherLadderPlayer); _dbContext.SaveChanges(); var repository = CreateInMemoryRepository(TopN); repository .GetTopEntries(ladderId) .Should() .HaveCount(1) .And.ContainEquivalentOf(anotherPlatformPlayer); _logger.Verify(l => l.LogInformation(It.IsAny <string>()), Times.Once()); }