Exemple #1
0
        private static void Main(string[] args)
        {
            var alphaNumbericCollector = new AlphaNumbericCollector();
            var stringCollector        = new StringCollector();

            AlphaNumericProcessor += alphaNumbericCollector.ProccessString;
            StringProcessor       += stringCollector.AddString;
            var    rgx = new Regex(@"\d+");
            string line;

            while (true)
            {
                line = Console.ReadLine();
                if (string.IsNullOrWhiteSpace(line))
                {
                    break;
                }
                if (rgx.IsMatch(line))
                {
                    AlphaNumericProcessor?.Invoke(line);
                }
                else
                {
                    StringProcessor?.Invoke(line);
                }
            }

            AlphaNumericProcessor -= alphaNumbericCollector.ProccessString;
            StringProcessor       -= stringCollector.AddString;

            alphaNumbericCollector.PrintAll();
            stringCollector.PrintAll();

            Console.ReadKey();
        }
Exemple #2
0
        public void Test_Good_Strings()
        {
            AlphaNumericProcessor proc = new AlphaNumericProcessor();

            foreach (string str in _good)
            {
                Assert.IsNotNull(proc.Process(str));
            }
        }