public void WordPointsCalculatorNullValueScore() { string word = null; int score = WordPointsCalculator.GetPoints(word); Assert.Equal(0, score); }
public void WordPointsCalculatorSevenLettersScore() { string word = "abcdefg"; int score = WordPointsCalculator.GetPoints(word); Assert.Equal(5, score); }
public void WordPointsCalculatorNineLettersScore() { string word = "abcdefghi"; int score = WordPointsCalculator.GetPoints(word); Assert.Equal(11, score); }
public void WordPointsCalculatorFiveLettersScore() { string word = "abcde"; int score = WordPointsCalculator.GetPoints(word); Assert.Equal(2, score); }
public void WordPointsCalculatorThreeLettersScore() { string word = "abc"; int score = WordPointsCalculator.GetPoints(word); Assert.Equal(1, score); }
public void WordPointsCalculatorOneLetterScore() { string word = "a"; int score = WordPointsCalculator.GetPoints(word); Assert.Equal(0, score); }
public void WordPointsCalculatorEmptyValueScore() { string word = string.Empty; int score = WordPointsCalculator.GetPoints(word); Assert.Equal(0, score); }
/// <summary> /// Method calculates score for list of words based on words length. /// </summary> /// <param name="words"></param> /// <returns>Score represented in integer.</returns> public async Task <int> CalculateSingleScoreAsync(List <string> words) { if (words == null || words.Count == 0) { return(0); } // Remove duplicate words in list if any List <string> uniqueWords = words.Where(w => !string.IsNullOrWhiteSpace(w)) .Select(w => w.Trim().ToLower()) .Distinct() .ToList(); int score = 0; uniqueWords.ForEach(word => score += WordPointsCalculator.GetPoints(word)); return(score); }