public void FindMostOccuringCharacterTest_EmptyString()
        {
            string value = "";
            CharacterCounter characterCounter = new CharacterCounter();
            var result = characterCounter.FindMostOccuringCharacter(value);

            Assert.AreEqual(0, result.Count());
        }
        public void FindMostOccuringCharacterTest_OneResult()
        {
            string value = "aabaabbacdcd";
            CharacterCounter characterCounter = new CharacterCounter();
            var result = characterCounter.FindMostOccuringCharacter(value);

            Assert.AreEqual(1, result.Count());
            Assert.IsTrue(result.Contains('a'));
        }
        public void FindMostOccuringCharacterTest_AllResults()
        {
            string value = "aabaabbacdcddddbbccc";
            CharacterCounter characterCounter = new CharacterCounter();
            var result = characterCounter.FindMostOccuringCharacter(value);

            Assert.AreEqual(4, result.Count());
            Assert.IsTrue(result.Contains('a'));
            Assert.IsTrue(result.Contains('b'));
            Assert.IsTrue(result.Contains('c'));
            Assert.IsTrue(result.Contains('d'));
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            CharacterCounter characterCounter = new CharacterCounter();

            Console.WriteLine("Type in a string, the characters that occur the most will be returned.");
            string value = Console.ReadLine();
            IEnumerable<char> mostOccuringCharacters = characterCounter.FindMostOccuringCharacter(value);
            Console.WriteLine("The most occuring characters are:");
            foreach (var character in mostOccuringCharacters)
            {
                Console.WriteLine(character);
            }
            Console.ReadLine();
        }