public void MatchDurationIsNotNull() { var duration = new TimeSpan(60 * 6000000000 / 10); var macthDuration = new MatchDuration(duration); Assert.IsNotNull(macthDuration); }
public void MatchDurationTryParseCanOutValidResult() { MatchDuration result; MatchDuration.TryParse("60", out result); Assert.IsTrue(result.Value.TotalMinutes == 60.0); }
public bool Equals(Match other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(GameMode == other.GameMode && IsMatchComplete == other.IsMatchComplete && string.Equals(MapId, other.MapId) && MatchDuration.Equals(other.MatchDuration) && MatchEndReason == other.MatchEndReason && MatchId.Equals(other.MatchId) && Equals(MatchStartDate, other.MatchStartDate) && MatchType == other.MatchType && Players.OrderBy(p => p.Key).SequenceEqual(other.Players.OrderBy(p => p.Key)) && PlaylistId.Equals(other.PlaylistId) && SeasonId.Equals(other.SeasonId) && Teams.OrderBy(t => t.Key).SequenceEqual(other.Teams.OrderBy(t => t.Key)) && VictoryCondition == other.VictoryCondition); }
public bool Equals(Result other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(GameBaseVariantId.Equals(other.GameBaseVariantId) && Equals(GameVariant, other.GameVariant) && HopperId.Equals(other.HopperId) && Equals(Id, other.Id) && IsTeamGame == other.IsTeamGame && Links.OrderBy(l => l.Key).SequenceEqual(other.Links.OrderBy(l => l.Key)) && MapId.Equals(other.MapId) && Equals(MapVariant, other.MapVariant) && Equals(MatchCompletedDate, other.MatchCompletedDate) && MatchDuration.Equals(other.MatchDuration) && Players.OrderBy(p => p.Identity.Gamertag).SequenceEqual(other.Players.OrderBy(p => p.Identity.Gamertag)) && SeasonId.Equals(other.SeasonId) && MatchCompletedDateFidelity == other.MatchCompletedDateFidelity && Teams.OrderBy(t => t.Id).SequenceEqual(other.Teams.OrderBy(t => t.Id))); }
public void MatchDurationIsEqualToEntry() { var duration = new TimeSpan(60 * 6000000000 / 10); var macthDuration = new MatchDuration(duration); Assert.IsTrue(macthDuration.Value.TotalMinutes == 60.0); }
public List <TopTenMatch> GetTopTenMatches(MatchDuration duration) { var filter = Builders <Player> .Filter .Where(x => x.matches.All(m => m.date >= duration.FromDate & m.date <= duration.ToDate)); var filterBson = Builders <BsonDocument> .Filter .Where(x => x["matches"]["date"] >= duration.FromDate& x["matches"]["date"] <= duration.ToDate); var documents = playerList .Aggregate() .Unwind(x => x.matches) .Match(filterBson) .SortByDescending(x => x["matches"]["score"]) .Limit(10) .ToList(); List <TopTenMatch> topTenMatches = new List <TopTenMatch>(); foreach (var item in documents) { TopTenMatch match = new TopTenMatch(); match.score = item["matches"]["score"].ToDouble(); match.level_number = item["matches"]["level_number"].ToInt32(); match.date = item["matches"]["date"].ToUniversalTime(); match.player_nickname = item["nickname"].ToString(); topTenMatches.Add(match); } return(topTenMatches); }
public void MatchDurationTryParseCanOutNull() { MatchDuration result; MatchDuration.TryParse("5", out result); Assert.IsNull(result); }
public Series(MatchDuration matchDuration, NumberOfTeams numberOfTeams, SeriesName name) { this.Id = Guid.NewGuid(); this.SeriesName = name; this.NumberOfTeams = numberOfTeams; this.MatchDuration = matchDuration; this.TeamIds = new HashSet <Guid>(); this.Schedule = new List <Match>(); }
public async Task <ActionResult <IEnumerable <Match> > > GetTopTenMatches(MatchDuration duration) { _context.HowManyGamesPlayed(); _context.AverageScore(); // var myMatch = await _context.match.FromSqlRaw( // "SELECT * FROM `match`WHERE `match`.`date`>= CAST({0} AS DATE) AND `match`.`date` <= CAST({1} AS DATE) " + // "ORDER BY `match`.`score` DESC LIMIT 10;", duration.FromDate, duration.ToDate).ToListAsync(); var myMatch = await _context.match.Where(x => x.date >= duration.FromDate& x.date <= duration.ToDate) .OrderByDescending(x => x.score).Take(10).ToListAsync(); if (myMatch == null) { return(NotFound()); } return(myMatch); }
public override int GetHashCode() { unchecked { var hashCode = (int)GameMode; hashCode = (hashCode * 397) ^ IsMatchComplete.GetHashCode(); hashCode = (hashCode * 397) ^ (MapId?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ MatchDuration.GetHashCode(); hashCode = (hashCode * 397) ^ MatchEndReason.GetHashCode(); hashCode = (hashCode * 397) ^ MatchId.GetHashCode(); hashCode = (hashCode * 397) ^ (MatchStartDate != null ? MatchStartDate.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (int)MatchType; hashCode = (hashCode * 397) ^ (Players?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ PlaylistId.GetHashCode(); hashCode = (hashCode * 397) ^ SeasonId.GetHashCode(); hashCode = (hashCode * 397) ^ (Teams?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ VictoryCondition.GetHashCode(); return(hashCode); } }
public override int GetHashCode() { unchecked { var hashCode = GameBaseVariantId.GetHashCode(); hashCode = (hashCode * 397) ^ (GameVariant?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ HopperId.GetHashCode(); hashCode = (hashCode * 397) ^ (Id?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ IsTeamGame.GetHashCode(); hashCode = (hashCode * 397) ^ (Links?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ MapId.GetHashCode(); hashCode = (hashCode * 397) ^ (MapVariant?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (MatchCompletedDate?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ MatchDuration.GetHashCode(); hashCode = (hashCode * 397) ^ (Players?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ SeasonId.GetHashCode(); hashCode = (hashCode * 397) ^ MatchCompletedDateFidelity; hashCode = (hashCode * 397) ^ (Teams?.GetHashCode() ?? 0); return(hashCode); } }
private void AddSeriesTeam(object obj) { var timeSpanMatchDuration = new TimeSpan(0, Convert.ToInt32(matchDuration), 0); var seriesSeriesName = new SeriesName(this.seriesName); var seriesNumberOfTeams = new NumberOfTeams(this.selectedNumberOfTeams); var seriesMatchDuration = new MatchDuration(timeSpanMatchDuration); Series seriesToAdd = new Series(seriesMatchDuration, seriesNumberOfTeams, seriesSeriesName); foreach (var team in teamsToAddToSeries) { this.seriesService.AddTeamToSeries(seriesToAdd, team.Id); team.UpdatePlayerIds(); } this.seriesService.Add(seriesToAdd); Messenger.Default.Send <Series>(seriesToAdd); ResetData(); this.SeriesAddedConfirmText = "Series Added!"; }
public ActionResult <List <TopTenMatch> > GetTopTenMatches(MatchDuration duration) { _matchService.HowManyGamesPlayed(); _matchService.AverageScore(); return(_matchService.GetTopTenMatches(duration)); }
public void MatchDurationInputAboveMaximummValueThrowsArgumentExeption() { var duration = new TimeSpan(95 * 6000000000 / 10); var matchDuartion = new MatchDuration(duration); }
public ActionResult <List <TopTenMatch> > Put_GetTopTenMatches(string id, MatchDuration duration) { return(_matchService.GetTopTenMatches(duration)); }
public void MatchDurationInputBelowMinimumValueThrowsArgumentExeption() { var duration = new TimeSpan(5 * 6000000000 / 10); var matchDuartion = new MatchDuration(duration); }
public async Task <ActionResult <IEnumerable <TopTenMatch> > > Put_GetTopTenMatches(int id, MatchDuration duration) { var myMatches = await _context.match.Where(x => x.date >= duration.FromDate& x.date <= duration.ToDate) .OrderByDescending(x => x.score).Take(10).ToListAsync(); if (myMatches == null) { return(NotFound()); } // Create new list with player nick names List <TopTenMatch> returnMatches = new List <TopTenMatch>(); foreach (var match in myMatches) { TopTenMatch newMatch = new TopTenMatch(); var player = await _playerContext.player.FindAsync(match.player_id); newMatch.level_number = match.level_number; newMatch.score = match.score; newMatch.date = match.date; newMatch.player_nickname = player.nickname; returnMatches.Add(newMatch); } return(returnMatches); }
public void MatchDurationTryParseCanReturnTrue() { MatchDuration result; Assert.IsTrue(MatchDuration.TryParse("60", out result)); }
public void MatchDurationTryParseCanReturnFalse() { MatchDuration result; Assert.IsFalse(MatchDuration.TryParse("5", out result)); }