public async Task GetUpcomingMatchday_ShouldBeDoneSuccessfully() { // Arrange var matchdayId = 1; var datePlaying = DateTime.Now; var matchday = new Matchday() { Id = matchdayId, DatePlaying = datePlaying }; var matchdayToReturnDto = new MatchdayToReturnDto() { Id = matchdayId, DatePlaying = datePlaying }; _unitOfWorkMock.Setup(x => x.Matchdays.GetMatchdayWithAdditionalInformation(It.IsAny <int>())) .ReturnsAsync(matchday); _mapperMock.Setup(x => x.Map <MatchdayToReturnDto>(matchday)) .Returns(matchdayToReturnDto); // Act var result = await _sut.GetUpcomingMatchday(It.IsAny <int>()); // Assert Assert.Equal(matchdayId, result.Id); Assert.Equal(datePlaying, result.DatePlaying); }
public void AddPlayerToMatchday(Matchday matchday, int playerId) { matchday.PlayerStats.Add(new PlayerRecord() { Player = Players.Find(playerId) }); }
private Matchday reverseMatchday(int matchdayNumber, Matchday matchday) { IList <Match> reverseMatches = new List <Match>(); foreach (Match firstLeg in matchday.Matches) { reverseMatches.Add(new Match(firstLeg.AwayTeam, firstLeg.HomeTeam, null, null)); } return(new Matchday(matchdayNumber, reverseMatches)); }
private void SeedMatchdays(FantasyLeagueDbContext context, string jsonString) { var deserializedMatchdays = JsonConvert.DeserializeObject <MatchdayDto[]>(jsonString); var matchdays = new List <Matchday>(); foreach (var md in deserializedMatchdays) { var matchday = new Matchday { Week = md.Week, StartDate = md.StartDate, EndDate = md.EndDate }; if (md.Week == 1) { matchday.MatchdayStatus = MatchdayStatus.Current; matchday.TransferWindowStatus = TransferWindowStatus.Opened; } foreach (var f in md.Fixtures) { var homeTeam = context.Teams.FirstOrDefault(x => x.Name == f.HomeTeam); var awayTeam = context.Teams.FirstOrDefault(x => x.Name == f.AwayTeam); var status = (FixtureStatus)Enum.Parse(typeof(FixtureStatus), f.Status); var isValid = Enum.TryParse(f.Winner, out MatchResult winner); if (!isValid) { winner = MatchResult.Unknown; } var fixture = new Fixture { HomeTeamId = homeTeam.Id, AwayTeamId = awayTeam.Id, AwayTeamGoals = f.AwayTeamGoals, HomeTeamGoals = f.HomeTeamGoals, Date = f.Date, Status = status, Winner = winner }; matchday.Fixtures.Add(fixture); } matchdays.Add(matchday); } context.Matchdays.AddRange(matchdays); }
private Roster CreateRoster(User user, Matchday matchday) { var rosterPlayers = CreateRosterPlayers(); var roster = new Roster { User = user, Matchday = matchday, Players = rosterPlayers, Budget = 0 }; return(roster); }
private Roster CopyOldRoster(Matchday matchday, User user, Roster lastRoster) { var roster = new Roster { Budget = GlobalConstants.Budget - lastRoster.Players.Sum(x => x.Player.Price), MatchdayId = matchday.Id, Formation = lastRoster.Formation, User = user }; foreach (var player in lastRoster.Players) { roster.Players.Add(new RosterPlayer { PlayerId = player.PlayerId, Selected = player.Selected }); } return(roster); }
public async Task GetUserStatusForMatchday_ShouldBeDoneSuccessfully() { // Arrange var datePlaying = DateTime.Now; var matchdayId = 1; var userId = 1; var matchday = new Matchday() { Id = matchdayId, DatePlaying = datePlaying }; var matchstatus = new MatchStatus() { UserId = userId, MatchdayId = matchdayId }; var matchStatusToReturnDto = new MatchStatusToReturnDto() { Checked = true }; _unitOfWorkMock.Setup(x => x.Matchdays.GetById(It.IsAny <int>())) .ReturnsAsync(matchday); _unitOfWorkMock.Setup(x => x.MatchStatuses.GetMatchStatusById(It.IsAny <int>(), It.IsAny <int>())) .ReturnsAsync(matchstatus); _mapperMock.Setup(x => x.Map <MatchStatusToReturnDto>(matchstatus)) .Returns(matchStatusToReturnDto); // Act var result = await _sut.GetUserStatusForMatchday(It.IsAny <int>(), It.IsAny <int>()); // Assert Assert.True(result.Checked); }
public object[] GetInsertableValues() { return(new string[] { Id.ToString(), Season is null ? null : Season.Id.ToString(), Competition is null ? null : Competition.Id.ToString(), UtcDate, Matchday is null ? null : Matchday.ToString(), Stage, Group, Attendance is null ? null : Attendance.ToString(), Score is null ? null : Score.Duration, Score is null ? null : Score.Winner, HomeTeam is null ? null : HomeTeam.Id.ToString(), AwayTeam is null ? null : AwayTeam.Id.ToString(), Score is null ? null : Score.HalfTime.HomeTeam.ToString(), Score is null ? null : Score.HalfTime.AwayTeam.ToString(), Score is null ? null : Score.FullTime.HomeTeam.ToString(), Score is null ? null : Score.FullTime.AwayTeam.ToString(), Score is null ? null : Score.ExtraTime.HomeTeam.ToString(), Score is null ? null : Score.ExtraTime.AwayTeam.ToString(), Score is null ? null : Score.Penalties.HomeTeam.ToString(), Score is null ? null : Score.Penalties.AwayTeam.ToString(), LastUpdated });
public MatchdayViewModel(Matchday matchday) { Date = matchday.Date; Number = matchday.Number; PlayerStats = matchday.PlayerStats.Select(x => new PlayerRankingStatsViewModel(x)); }
public void RemoveMatchday(Matchday matchday) { Matchdays.Remove(matchday); }
public void CreateMatchday(Matchday matchday) { Matchdays.Add(matchday); SaveChanges(); }