示例#1
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);
        }
示例#2
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);
        }
示例#3
0
        public void TestSingleDigitsImpossible()
        {
            var lp  = new LotteryParser();
            var res = lp.GetLotteryTicket("1234561"); // unique numbers, not possible

            CheckParseResult(res, null);
        }
示例#4
0
        public void TestRepeatsFailure()
        {
            var lp  = new LotteryParser();
            var res = lp.GetLotteryTicket("53535857565554");

            CheckParseResult(res, null);
        }
示例#5
0
        public void TestDoubleDigitsImpossible()
        {
            var lp  = new LotteryParser();
            var res = lp.GetLotteryTicket("4938532894749");

            CheckParseResult(res, null);
        }
示例#6
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);
        }
示例#7
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);
        }
示例#8
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);
        }
示例#9
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);
        }
示例#10
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);
        }
示例#11
0
        public void TestNegative()
        {
            var lp = new LotteryParser();

            try
            {
                var res = lp.GetLotteryTicket("-10123456");
                Assert.Fail();
            }
            catch (ArgumentException)
            {
            }
        }
示例#12
0
        public void TestInvalidChars()
        {
            var lp = new LotteryParser();

            try
            {
                lp.GetLotteryTicket("abcdefgh");
                Assert.Fail();
            }
            catch (ArgumentException)
            {
            }
        }
示例#13
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);
            }
        }