public void Add_ShouldGiveCharCountsOfCharacters()
        {
            var totaliser = new CharacterTotaliser();

            totaliser.Add("abca.");
            totaliser.Add("foo bar wibble!");
            var counts = totaliser.GetCharCounts();

            Assert.That(counts['a'], Is.EqualTo(3));
            Assert.That(counts['b'], Is.EqualTo(4));
        }
Beispiel #2
0
        private ICharacterCounter ComputeCharCounts(ITextFile textFile)
        {
            ++NumberOfCallsToComputeCharCounts;
            var counter = new CharacterTotaliser();

            foreach (string line in textFile.ReadLines())
            {
                counter.Add(line);
            }

            return(counter);
        }
Beispiel #3
0
        private IReadOnlyDictionary <char, int> ComputeCharCounts(IReadOnlyCollection <string> allLines)
        {
            using (SystemMode.Counter) // don't remove this - that's cheating!
            {
                var totaliser = new CharacterTotaliser();
                foreach (string line in allLines)
                {
                    totaliser.Add(line);
                }

                return(totaliser.GetCharCounts());
            }
        }