public void Test_Count_InputCountArrayValuesWithOneLength_ExpectedTwo() { var words = new WordsCount(); var input = new[] { "A", "C", "CCC", "AB" }; var expected = 2; var actual = words.Count(input, 1); Assert.AreEqual(expected, actual); }
public void Test_Count_InputArrayValuesAreNullOrEmptySpace_ExpectedZero() { var words = new WordsCount(); var input = new[] { null, " " }; var expected = 0; var actual = words.Count(input, -2); Assert.AreEqual(expected, actual); }
public void Test_Count_InputGivenLenghtIsLessOne_ExpectedZero() { var words = new WordsCount(); var input = new[] { "Abb", "CCC" }; var expected = 0; var actual = words.Count(input, -2); Assert.AreEqual(expected, actual); }
public void Test_Count_InputArrayLengthZero_ExpectedZero() { var words = new WordsCount(); string[] input = new string[0]; var expected = 0; var actual = words.Count(input, 2); Assert.AreEqual(expected, actual); }
public void Test_Count_InputNullArray_ExpectedZero() { var words = new WordsCount(); string[] input = null; var expected = 0; var actual = words.Count(input, 1); Assert.AreEqual(expected, actual); }
private void OnEndProcessPage(object sender, string url) { m_rtf.StartNewParagraph(); m_rtf.AppendText("-- PAGE END. Total words: " + WordsCount.ToString()); string log_msg = String.Format("-- PAGE END. Total words: {0:0000} file: {1}", WordsCount, m_filename); log.Debug(log_msg); m_rtf.StartNewParagraph(); }
private void Run() { var result = new WordsCount(); using (var fs = new FileStream(_fileName, FileMode.Open, FileAccess.Read)) { using (var sr = new StreamReader(fs, Encoding.Default)) { var lineAnalizer = new LineAnalizer(); string line = null; while ((line = sr.ReadLine()) != null) { var words = lineAnalizer.Pars(line); foreach (var word in words) { result.AddWordFound(word.ToLower()); } } } } _queue.Add(result); }
public static string GetChars(string fullTestName, WordsCount place) { var arrAllWords = fullTestName.Split(' '); var newText = string.Empty; switch (place) { case WordsCount.FirstSix: var firstSix = Slice(arrAllWords, 0, 6).ToArray(); newText = string.Join(" ", firstSix); break; case WordsCount.LastThree: var lastThree = arrAllWords.Skip(arrAllWords.Length - 3).ToArray(); newText = string.Join(" ", lastThree); break; case WordsCount.SeventyFive: var seventyFiveChars = new StringBuilder(); for (var i = 0; i < arrAllWords.Length; i++) { var currentWord = string.Join(" ", Slice(arrAllWords, i, i + 1).ToArray()); if (!(seventyFiveChars.ToString().Length > 75)) { seventyFiveChars = seventyFiveChars.Append(currentWord).Append(" "); } } newText = seventyFiveChars.ToString().Trim(); break; default: throw new ArgumentOutOfRangeException("Given " + place + " not yet handled."); } return(newText); }