public void FindScoreById_Should_Return_Correct_Score() { var id = Guid.NewGuid(); UserScores.AddRange(new [] { new UserScore { Id = 1, Score = 10, Timestamp = SystemTime.Now().AddDays(-3), ActionType = UserAction.AccountActivated, UserId = id }, new UserScore { Id = 2, Score = 20, Timestamp = SystemTime.Now().AddDays(-2), ActionType = UserAction.StorySubmitted, UserId = id } } ); var score = _userRepository.FindScoreById(id, SystemTime.Now().AddMonths(-1), SystemTime.Now()); Assert.Equal(30, score); }
public void FindTop_Should_Return_Top_Users() { UserScores.AddRange( new[] { new UserScore { Id = 1, Score = 10, Timestamp = SystemTime.Now().AddDays(-1), ActionType = UserAction.AccountActivated, User = new User { Id = Guid.NewGuid(), Role = Roles.User } }, new UserScore { Id = 1, Score = 10, Timestamp = SystemTime.Now().AddHours(-12), ActionType = UserAction.AccountActivated, User = new User { Id = Guid.NewGuid(), Role = Roles.User } }, } ); Users.AddRange(UserScores.Select(us => us.User)); var pagedResult = _userRepository.FindTop(SystemTime.Now().AddMonths(-1), SystemTime.Now(), 0, 10); Assert.Equal(2, pagedResult.Result.Count); Assert.Equal(2, pagedResult.Total); }
private void LoadSetting() { using (var sr = new StreamReader(K_SCORES_CONF)) { var scoresJson = sr.ReadToEnd(); _UserScores = JsonConvert.DeserializeObject <UserScores>(scoresJson); } }
public void RemoveClock(int userId) { if (!UserScores.TryGetValue(userId, out var data)) { return; } ((SpectatingTrackedUserData)data).Clock = null; }
public void AddClock(int userId, IClock clock) { if (!UserScores.TryGetValue(userId, out var data)) { return; } ((SpectatingTrackedUserData)data).Clock = clock; }
public void RemoveClock(int userId) { if (!UserScores.TryGetValue(userId, out var data)) { throw new ArgumentException(@"Provided user is not tracked by this leaderboard", nameof(userId)); } ((SpectatingTrackedUserData)data).Clock = null; }
public void AddClock(int userId, IClock clock) { if (!UserScores.TryGetValue(userId, out var data)) { throw new ArgumentException(@"Provided user is not tracked by this leaderboard", nameof(userId)); } data.ScoreProcessor.ReferenceClock = clock; }
private void AddScore(decimal score, UserAction reason) { var userScore = new UserScore { Timestamp = SystemTime.Now(), Score = score, ActionType = reason, }; UserScores.Add(userScore); }
public void SetScoreBar(string number, UserScores userScores, Color thisColor) { this.serialNo.text = number; this.win.text = userScores.win; this.lost.text = userScores.lost; this.draw.text = userScores.draw; this.forfeit.text = userScores.forfeit; this.playerName.text = userScores.name; this.rank.text = userScores.rank; Image[] allImages = GetComponentsInChildren <Image>(); for (int i = 0; i < allImages.Length; i++) { allImages[i].color = thisColor; } gameObject.SetActive(true); }