Пример #1
0
        public void Run(string[] commandArguments)
        {
            if (!ValidateArguments(commandArguments))
            {
                return;
            }

            var algorithmType = GetAlgorithmType(commandArguments[1]);

            using (StreamReader reader = new StreamReader(commandArguments[0]))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    ticketList.AddRange(luckyTicketParser.CheckTicketsInLine(line));
                }
            }
            switch (algorithmType)
            {
            case AlgorithmType.MoskowAlgirithm:
                luckyTicketAlgorithm = new MoskowAlgorithm();
                logger.Info(StringConstants.MOSKOW_ALGORITHM_USED);
                break;

            case AlgorithmType.PiterAlgirithm:
                luckyTicketAlgorithm = new PiterAlgorithm();
                logger.Info(StringConstants.PITER_ALGORITHM_USED);
                break;
            }
            UI.ConsoleOutPut(string.Format(StringConstants.OUTPUT_RESULT,
                                           luckyTicketAlgorithm.Algorithm(ticketList)));
        }
Пример #2
0
        public void CheckTicketsInLine_WithTicketsString_ShouldReturnsTrue(string ticketsString, string[] expected)
        {
            List <Ticket> ticketList = parser.CheckTicketsInLine(ticketsString);

            string[] ticketArray = new string[ticketList.Count];
            for (int i = 0; i < ticketArray.Length; i++)
            {
                ticketArray[i] = ticketList[i].ToString();
            }

            Assert.Equal(expected, ticketArray);
        }