public void ShouldReturnNullAll() { // Arrange var db = GetDatebase(); var league = new League { Id = 1, Country = "Uk", Name = "Premier league", Year = "2018", Stage = "" }; var team = new Team { Id = 1, Name = "Man Utd", UniqueName = "Manchester United" }; var firstGame = new FootballGame { Id = 1, MatchDate = DateTime.UtcNow, League = league, HomeTeam = team, AwayTeam = team }; db.AddRange(firstGame); db.SaveChanges(); var gameService = new GameService(db); // Act var result = gameService.All(); // Assert result .Should() .BeNullOrEmpty(); }
public void ShouldReturnAllGamesAndOrder() { // Arrange var db = GetDatebase(); var league = new League { Id = 1, Country = "Uk", Name = "Premier league", Year = "2018", Stage = "" }; var team = new Team { Id = 1, Name = "Man Utd", UniqueName = "Manchester United" }; var firstGame = new FootballGame { Id = 1, MatchDate = DateTime.UtcNow, League = league, HomeTeam = team, AwayTeam = team }; var secondGame = new FootballGame { Id = 2, MatchDate = DateTime.UtcNow, League = league, HomeTeam = team, AwayTeam = team, FullTimeResult = new GameResult { Id = 2, Result = ResultEnum.H, HomeTeamGoals = 3, AwayTeamGoals = 1 } }; var thirdGame = new FootballGame { Id = 3, MatchDate = DateTime.UtcNow, League = league, HomeTeam = team, AwayTeam = team }; var fourthGame = new FootballGame { Id = 4, MatchDate = DateTime.UtcNow.AddDays(-1), League = league, HomeTeam = team, AwayTeam = team, FullTimeResult = new GameResult { Id = 1, Result = ResultEnum.H, HomeTeamGoals = 3, AwayTeamGoals = 1 } }; db.AddRange(firstGame, secondGame, thirdGame, fourthGame); db.SaveChanges(); var gameService = new GameService(db); // Act var result = gameService.All(); // Assert result .Should() .Match(r => r.ElementAt(0).Id == 2 && r.ElementAt(1).Id == 4) .And .HaveCount(2); }