Пример #1
0
        public void TestSingleDigitsImpossible()
        {
            var lp  = new LotteryParser();
            var res = lp.GetLotteryTicket("1234561"); // unique numbers, not possible

            CheckParseResult(res, null);
        }
Пример #2
0
        public void TestRepeatsFailure()
        {
            var lp  = new LotteryParser();
            var res = lp.GetLotteryTicket("53535857565554");

            CheckParseResult(res, null);
        }
Пример #3
0
        public void TestDoubleDigitsImpossible()
        {
            var lp  = new LotteryParser();
            var res = lp.GetLotteryTicket("4938532894749");

            CheckParseResult(res, null);
        }
Пример #4
0
        public static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Program.Usage();
                return;
            }

            var fileName = args[0];

            if (!File.Exists(fileName))
            {
                Console.WriteLine("Cannot locate file : {0}", fileName);
                return;
            }

            string[] allNumbers = File.ReadAllLines(fileName);
            var      lp         = new LotteryParser();
            var      allTickets = lp.GetLotteryTickets(allNumbers).
                                  Select(t => t != null? String.Join(" ", t.Select(n => n.ToString())): null
                                         );

            var results = allNumbers.Zip(allTickets, (n, t) => new Tuple <string, string>(n, t));

            foreach (var res in results.Where(t => t.Item2 != null))
            {
                Console.WriteLine("{0} -> {1}", res.Item1, res.Item2);
            }
        }
Пример #5
0
        public void TestDoubleDigitsLongest()
        {
            var lp       = new LotteryParser();
            var res      = lp.GetLotteryTicket("49385328194154");
            var expected = new string[] { "49", "38", "53", "28", "19", "41", "54" };

            CheckParseResult(res, expected);
        }
Пример #6
0
        public void TestDoubleDigitsComplex()
        {
            var lp       = new LotteryParser();
            var res      = lp.GetLotteryTicket("4938532894754");
            var expected = new string[] { "49", "38", "53", "28", "9", "47", "54" };

            CheckParseResult(res, expected);
        }
Пример #7
0
        public void TestDoubleDigits()
        {
            var lp       = new LotteryParser();
            var res      = lp.GetLotteryTicket("12345678");
            var expected = new string[] { "1", "2", "3", "4", "56", "7", "8" };

            CheckParseResult(res, expected);
        }
Пример #8
0
        public void TestSimple()
        {
            var lp       = new LotteryParser();
            var res      = lp.GetLotteryTicket("1234567");
            var expected = new string[] { "1", "2", "3", "4", "5", "6", "7" };

            CheckParseResult(res, expected);
        }
Пример #9
0
        public void TestDoubleDigitsWithZeroUnique()
        {
            var lp       = new LotteryParser();
            var res      = lp.GetLotteryTicket("10123456");
            var expected = new string[] { "10", "1", "2", "3", "4", "5", "6" };

            CheckParseResult(res, expected);
        }
Пример #10
0
        public void TestLength()
        {
            var lp  = new LotteryParser();
            var res = lp.GetLotteryTicket("01234");

            Assert.AreEqual(null, res);

            res = lp.GetLotteryTicket("0123456789012345");
            Assert.AreEqual(null, res);
        }
Пример #11
0
        public void TestDoubleDigitsUnique()
        {
            var lp  = new LotteryParser();
            var res = lp.GetLotteryTicket("1123456");

            string[] expected = null;
            CheckParseResult(res, null);

            res      = lp.GetLotteryTicket("11234567");
            expected = new string[] { "1", "12", "3", "4", "5", "6", "7" };
            CheckParseResult(res, expected);
        }
Пример #12
0
        public void TestNegative()
        {
            var lp = new LotteryParser();

            try
            {
                var res = lp.GetLotteryTicket("-10123456");
                Assert.Fail();
            }
            catch (ArgumentException)
            {
            }
        }
Пример #13
0
        public void TestInvalidChars()
        {
            var lp = new LotteryParser();

            try
            {
                lp.GetLotteryTicket("abcdefgh");
                Assert.Fail();
            }
            catch (ArgumentException)
            {
            }
        }
Пример #14
0
        public void TestSampleCases()
        {
            string[]   inputs    = { "1", "42", "100848", "4938532894754", "1234567", "472844278465445" };
            string[][] expecteds =
            {
                null,
                null,
                null,
                new string[] { "49","38",                 "53", "28", "9", "47", "54" },
                new string[] { "1","2",                  "3",  "4",  "5", "6",  "7"  },
                null
            };

            var zipped = inputs.Zip(expecteds, (x, y) => new Tuple <string, string[]>(x, y));
            var lp     = new LotteryParser();

            foreach (var inOuts in zipped)
            {
                var res      = lp.GetLotteryTicket(inOuts.Item1);
                var expected = inOuts.Item2;
                CheckParseResult(res, expected);
            }
        }