Beispiel #1
0
        public void ValidateFixedBranches7()
        {
            Setup(TestUtil.GetTestFile("relay\\gaffle.ppen"));

            FixedBranchAssignments branchAssignments = new FixedBranchAssignments();

            branchAssignments.AddBranchAssignment('D', 0);
            branchAssignments.AddBranchAssignment('H', 1);
            branchAssignments.AddBranchAssignment('I', 0);
            branchAssignments.AddBranchAssignment('I', 2);

            List <string>          errors;
            RelayVariations        relayVariations = new RelayVariations(eventDB, CourseId(4), new RelaySettings(10, 3));
            FixedBranchAssignments result          = relayVariations.ValidateFixedBranches(branchAssignments, out errors);

            FixedBranchAssignments expected = new FixedBranchAssignments();

            branchAssignments.AddBranchAssignment('D', 0);
            branchAssignments.AddBranchAssignment('H', 1);
            branchAssignments.AddBranchAssignment('I', 2);

            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual("Leg 1 never reaches branch 'I': it was assigned to go a different way in a containing fork.", errors[0]);
            Assert.AreEqual(expected, result);
        }
Beispiel #2
0
        public void ValidateFixedBranches3()
        {
            Setup(TestUtil.GetTestFile("relay\\relay.ppen"));

            // No Assignments.
            FixedBranchAssignments branchAssignments = new FixedBranchAssignments();

            branchAssignments.AddBranchAssignment('D', 1);
            branchAssignments.AddBranchAssignment('D', 2);
            branchAssignments.AddBranchAssignment('E', 2);
            branchAssignments.AddBranchAssignment('E', 3);
            List <string>          errors;
            RelayVariations        relayVariations = new RelayVariations(eventDB, CourseId(4), new RelaySettings(1, 6));
            FixedBranchAssignments result          = relayVariations.ValidateFixedBranches(branchAssignments, out errors);

            FixedBranchAssignments expected = new FixedBranchAssignments();

            expected.AddBranchAssignment('D', 1);
            expected.AddBranchAssignment('D', 2);
            expected.AddBranchAssignment('E', 3);

            Assert.AreEqual(1, errors.Count);
            Assert.AreEqual("Leg 3 is assigned to both branch 'D' and branch 'E'", errors[0]);
            Assert.AreEqual(expected, result);
        }
Beispiel #3
0
        public void ValidateFixedBranches5()
        {
            Setup(TestUtil.GetTestFile("relay\\gaffle.ppen"));

            // No Assignments.
            FixedBranchAssignments branchAssignments = new FixedBranchAssignments();
            List <string>          errors;
            RelayVariations        relayVariations = new RelayVariations(eventDB, CourseId(4), new RelaySettings(10, 3));
            FixedBranchAssignments result          = relayVariations.ValidateFixedBranches(branchAssignments, out errors);

            Assert.AreEqual(0, errors.Count);
            Assert.AreEqual(branchAssignments, result);
        }
Beispiel #4
0
        public void ValidateFixedBranches2()
        {
            Setup(TestUtil.GetTestFile("relay\\relay.ppen"));

            // No Assignments.
            FixedBranchAssignments branchAssignments = new FixedBranchAssignments();

            branchAssignments.AddBranchAssignment('A', -1);
            branchAssignments.AddBranchAssignment('A', 4);
            List <string>          errors;
            RelayVariations        relayVariations = new RelayVariations(eventDB, CourseId(7), new RelaySettings(1, 4));
            FixedBranchAssignments result          = relayVariations.ValidateFixedBranches(branchAssignments, out errors);

            Assert.AreEqual(2, errors.Count);
            Assert.AreEqual("'0' is not a valid leg number for branch 'A'", errors[0]);
            Assert.AreEqual("'5' is not a valid leg number for branch 'A'", errors[1]);
            Assert.AreEqual(result, new FixedBranchAssignments());
        }