CampfireTests.ScoreBoard.AddScore C# (CSharp) Method

AddScore() public method

public AddScore ( string user, int score ) : void
user string
score int
return void
        public void AddScore(string user, int score)
        {
            if(_scores.ContainsKey(user))
            {
                var currentScore = GetUserScore(user);
                _scores[user] = score + currentScore;
            }
            else
            {
                _scores.Add(user, score);
            }
        }

Usage Example

Example #1
0
        public void GetUserScore_UserExistsWithScore1ThenScores1_Returns2()
        {
            ScoreBoard board = new ScoreBoard();
            board.AddScore("JamesW", 1);
            board.AddScore("JamesW", 1);

            int result = board.GetUserScore("JamesW");

            Assert.AreEqual(2, result);
        }
All Usage Examples Of CampfireTests.ScoreBoard::AddScore