public void TestRule(string rule, int pos, bool result)
        {
            var ticketValidator = new TicketValidator();

            ticketValidator.AddRule("class", 0, 1, 4, 19);
            ticketValidator.AddRule("row", 0, 5, 8, 19);
            ticketValidator.AddRule("seat", 0, 13, 16, 19);
            ticketValidator.IsTicketValid(new int[] { 3, 9, 18 });
            ticketValidator.IsTicketValid(new int[] { 15, 1, 5 });
            ticketValidator.IsTicketValid(new int[] { 5, 14, 9 });
            ticketValidator.TestRule(rule, pos).ShouldBe(result, $"{rule} {pos}");
        }
        public void TestTicketScanningErrorRate()
        {
            var ticketValidator = new TicketValidator();

            ticketValidator.AddRule("class", 1, 3, 5, 7);
            ticketValidator.AddRule("row", 6, 11, 33, 44);
            ticketValidator.AddRule("seat", 13, 40, 45, 50);
            ticketValidator.IsTicketValid(new int[] { 7, 3, 47 });
            ticketValidator.IsTicketValid(new int[] { 40, 4, 50 });
            ticketValidator.IsTicketValid(new int[] { 55, 2, 20 });
            ticketValidator.IsTicketValid(new int[] { 38, 6, 12 });
            ticketValidator.TicketScanningErrorRate.ShouldBe(71);
        }
        public void TestMatrix()
        {
            var ticketValidator = new TicketValidator();

            ticketValidator.AddRule("class", 0, 1, 4, 19);
            ticketValidator.AddRule("row", 0, 5, 8, 19);
            ticketValidator.AddRule("seat", 0, 13, 16, 19);
            ticketValidator.IsTicketValid(new int[] { 3, 9, 18 });
            ticketValidator.IsTicketValid(new int[] { 15, 1, 5 });
            ticketValidator.IsTicketValid(new int[] { 5, 14, 9 });
            var fieldMatrix = ticketValidator.GetFieldMatrix();

            // Tests stopped working?
            //fieldMatrix.ShouldContainKeyAndValue<string, int[]>("class", new int[] { 0, 1, 1 });
            //fieldMatrix.ShouldContainKeyAndValue<string, int[]>("row", new int[] { 1, 1, 1 });
            //fieldMatrix.ShouldContainKeyAndValue<string, int[]>("seat", new int[] { 0, 0, 1 });
        }
        public void TestTicketValidation(bool result, params int[] ticketInfo)
        {
            var ticketValidator = new TicketValidator();

            ticketValidator.AddRule("class", 1, 3, 5, 7);
            ticketValidator.AddRule("row", 6, 11, 33, 44);
            ticketValidator.AddRule("seat", 13, 40, 45, 50);
            ticketValidator.IsTicketValid(ticketInfo).ShouldBe(result, string.Join(',', ticketInfo));
        }
        public void TestResolvedFields()
        {
            var ticketValidator = new TicketValidator();

            ticketValidator.AddRule("class", 0, 1, 4, 19);
            ticketValidator.AddRule("row", 0, 5, 8, 19);
            ticketValidator.AddRule("seat", 0, 13, 16, 19);
            ticketValidator.IsTicketValid(new int[] { 3, 9, 18 });
            ticketValidator.IsTicketValid(new int[] { 15, 1, 5 });
            ticketValidator.IsTicketValid(new int[] { 5, 14, 9 });
            ticketValidator.GetResolvedFields().OrderBy(d => d.Key).ShouldBe(
                new Dictionary <string, int> {
                { "class", 1 },
                { "row", 0 },
                { "seat", 2 },
            }
                );
        }