Beispiel #1
0
        public void AnalyzeTest_EmptyTestZero()
        {
            Dictionary <int, int> result = CharacterFrequencyAnalyzer.Analyze(new List <string> {
                ""
            });

            Assert.IsNotNull(result);
            Assert.IsFalse(result.Any(e => e.Value > 0));
        }
Beispiel #2
0
        public void AnalyzeTest_SingleSet_Digits()
        {
            Dictionary <int, int> result = CharacterFrequencyAnalyzer.Analyze(new List <string> {
                "123"
            });

            Assert.AreEqual(1, result['1']);
            Assert.AreEqual(1, result['2']);
            Assert.AreEqual(1, result['3']);

            // Select where element(s) e are NOT(a,b or c)
            IEnumerable <int> allOtherCharacters = result.Where(e => !(e.Key == '1' || e.Key == '2' || e.Key == '3')).Select(e => e.Value);

            Assert.IsTrue(allOtherCharacters.All(e => e == 0));
        }
Beispiel #3
0
        public void AnalyzeTest_SingleSet_UpperCase()
        {
            Dictionary <int, int> result = CharacterFrequencyAnalyzer.Analyze(new List <string> {
                "ABC"
            });

            Assert.AreEqual(1, result['A']);
            Assert.AreEqual(1, result['B']);
            Assert.AreEqual(1, result['C']);

            // Select where element(s) e are NOT(A,B or C)
            IEnumerable <int> allOtherCharacters = result.Where(e => !(e.Key == 'A' || e.Key == 'B' || e.Key == 'C')).Select(e => e.Value);

            Assert.IsTrue(allOtherCharacters.All(e => e == 0));
        }
Beispiel #4
0
        public void AnalyzeTest_SingleSet_Symbols()
        {
            List <string> input = new List <string> {
                ",./;'", "a!"
            };
            Dictionary <int, int> result = CharacterFrequencyAnalyzer.Analyze(input);

            Assert.AreEqual(1, result[',']);
            Assert.AreEqual(1, result['.']);
            Assert.AreEqual(1, result['/']);
            Assert.AreEqual(1, result[';']);
            Assert.AreEqual(1, result['\'']);


            // Select where element(s) e are NOT(a,b or c)
            IEnumerable <int> allOtherCharacters = result.Where(e => input.Any(s => s.Contains(e.Key.ToString())))
                                                   .Select(e => e.Value);

            Assert.IsTrue(allOtherCharacters.All(e => e == 0));
        }