public void ClearTextAndSymbols()
        {
            UndoMgr      undomgr = new UndoMgr(5);
            EventDB      eventDB = new EventDB(undomgr);
            SymbolDB     symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml"));
            StringWriter writer = new StringWriter();
            string       actual, expected;

            eventDB.Load(TestUtil.GetTestFile("descformatter\\sampleevent1.coursescribe"));
            eventDB.Validate();

            CourseView           courseView    = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(CourseId(4)));
            DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting);

            DescriptionLine[] description = descFormatter.CreateDescription(false);
            DescriptionFormatter.ClearTextAndSymbols(description);

            DescriptionFormatter.DumpDescription(symbolDB, description, writer);
            actual   = writer.ToString();
            expected =
                @"      |                                               |
      |                 |                 |           |
(  1) |     |     |     |     |     |     |     |     |
( 11) |     |     |     |     |     |     |     |     |
( 22) |                     :                         |
(  4) |     |     |     |     |     |     |     |     |
( 15) |                     :                         |
(  5) |     |     |     |     |     |     |     |     |
( 18) |     |     |     |     |     |     |     |     |
(  6) |                     :                         |
";
            Assert.AreEqual(expected, actual);
        }
        // Test the course description formatter with a given file and course
        private void TestCourseFormatter(string testFileName, CourseDesignator courseDesignator, bool createKey, string expected)
        {
            UndoMgr      undomgr  = new UndoMgr(5);
            EventDB      eventDB  = new EventDB(undomgr);
            SymbolDB     symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml"));
            StringWriter writer   = new StringWriter();
            string       actual;

            eventDB.Load(TestUtil.GetTestFile(testFileName));
            eventDB.Validate();

            CourseView courseView;

            courseView = CourseView.CreateViewingCourseView(eventDB, courseDesignator);
            DescriptionFormatter descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting);

            DescriptionLine[] description = descFormatter.CreateDescription(createKey);

            DescriptionFormatter.DumpDescription(symbolDB, description, writer);
            actual = writer.ToString();

            Assert.AreEqual(expected, actual);
        }
        public void DisplayAllCourses()
        {
            UndoMgr              undomgr  = new UndoMgr(5);
            EventDB              eventDB  = new EventDB(undomgr);
            SymbolDB             symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml"));
            CourseView           courseView;
            DescriptionFormatter descFormatter;

            DescriptionLine[] description;

            eventDB.Load(TestUtil.GetTestFile("descformatter\\sampleevent1.coursescribe"));
            eventDB.Validate();

            foreach (Id <Course> courseId in QueryEvent.SortedCourseIds(eventDB))
            {
                CourseDesignator designator;
                if (QueryEvent.HasVariations(eventDB, courseId))
                {
                    var variationInfo = QueryEvent.GetAllVariations(eventDB, courseId).First();
                    designator = new CourseDesignator(courseId, variationInfo);
                }
                else
                {
                    designator = new CourseDesignator(courseId);
                }
                courseView    = CourseView.CreateViewingCourseView(eventDB, designator);
                descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting);
                description   = descFormatter.CreateDescription(false);
                DescriptionFormatter.DumpDescription(symbolDB, description, Console.Out);
                Console.WriteLine();
            }

            courseView    = CourseView.CreateViewingCourseView(eventDB, CourseDesignator.AllControls);
            descFormatter = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting);
            description   = descFormatter.CreateDescription(false);
            DescriptionFormatter.DumpDescription(symbolDB, description, Console.Out);
        }
        public void ScoreCourseFormatterNoScore()
        {
            UndoMgr      undomgr = new UndoMgr(5);
            EventDB      eventDB = new EventDB(undomgr);
            SymbolDB     symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml"));
            StringWriter writer = new StringWriter();
            string       actual, expected;

            eventDB.Load(TestUtil.GetTestFile("descformatter\\sampleevent5.coursescribe"));
            eventDB.Validate();

            CourseView courseView = CourseView.CreateViewingCourseView(eventDB, Designator(5));

            DescriptionLine[] description = new DescriptionFormatter(courseView, symbolDB, DescriptionFormatter.Purpose.ForPrinting).CreateDescription(false);

            DescriptionFormatter.DumpDescription(symbolDB, description, writer);
            actual   = writer.ToString();
            expected =
                @"      | Sample Event 1                                |   [Sample Event 1]
      | Score more!                                   |   [Score more!]
      |Score 4          |155 points                   |   [155 points]
(  1) |start|     |     |  2.8|  8.5|     |     |     |   [Start: open bare rock]
( 17) |    1|  302|     | 1.14|     |     |11.1S|     |   [S side of pit]
(  2) |    2|   31|  0.3|  2.4|     |   2m|     |     |   [Upper boulder, 2m high]
(  7) |    3|  189|     |  1.8|  1.8| 10.2|     |     |   [Small gully junction]
( 11) |    4|  191|     |  5.2|  5.2| 10.1|11.15|     |   [Between path crossings]
(  8) |    5|  210|     | 5.11| 5.20|     |11.15|     |   [Between building and statue]
( 20) |    6|  305|     |  2.7|     |  6x7|     | 12.4|   [Stony ground, 6m by 7m (manned)]
(  5) |    7|   GO| 0.1N|  5.5|  5.2| 10.1|11.1N| 12.3|   [N side of N power line and path crossing (radio)]
(  4) |    8|   32|     |  3.7|     |     |     | 12.1|   [very marshy spot]
( 16) |    9|  301|     | 1.14|  8.4|  3.0|     |     |   [Overgrown pit, 3m deep]
( 18) |   10|  303|     |  1.3|     |    4|     |     |   [Reentrant, 4m deep]
( 19) |   11|  304| 0.1S|     |  8.5|     |     |     |   [S ]
";
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 5
0
        public void ActiveDescription()
        {
            bool success = controller.LoadInitialFile(TestUtil.GetTestFile("selectionmgr\\sampleevent1.coursescribe"), true);

            Assert.IsTrue(success);

            selectionMgr.ActiveTab = 3;

            Assert.AreEqual("SampleCourse4", selectionMgr.ActiveCourseView.CourseName);

            StringWriter writer = new StringWriter();
            string       actual, expected;

            DescriptionFormatter.DumpDescription(ui.symbolDB, selectionMgr.ActiveDescription, writer);
            actual   = writer.ToString();
            expected =
                @"      | Sample Event 1                                |   [Sample Event 1]
      |SampleCourse4    |4.7 km           |175 m      |   [Length 4.7 km, climb 175 m]
(  1) |start|     |     |  2.8|  8.5|     |     |     |   [Start: open bare rock]
( 11) |    1|  191|     |  5.2|  5.2| 10.1|11.15|     |   [Between path crossings]
( 22) |                 13.4:                         |   [Mandatory passage]
(  4) |    2|   32|     |  3.7|     |     |     | 12.1|   [very marshy spot]
( 15) |                 13.3:                         |   [Mandatory crossing point]
(  5) |    3|   GO| 0.1N|  5.5|  5.2| 10.1|11.1N| 12.3|   [N side of N power line and path crossing (radio)]
( 18) |    4|  303|     |  1.3|     |    4|     |     |   [Reentrant, 4m deep]
(  6) |                 14.2: 1420 m                  |   [Navigate 1420 m to finish funnel]
";
            Assert.AreEqual(expected, actual);

            selectionMgr.ActiveTab = 0;

            Assert.AreEqual("All controls", selectionMgr.ActiveCourseView.CourseName);

            writer = new StringWriter();
            DescriptionFormatter.DumpDescription(ui.symbolDB, selectionMgr.ActiveDescription, writer);
            actual   = writer.ToString();
            expected =
                @"      | Sample Event 1                                |   [Sample Event 1]
      |All controls     |17 controls                  |   [17 controls]
(  1) |start|     |     |  2.8|  8.5|     |     |     |   [Start: open bare rock]
( 23) |start|     |0.2NW|  1.7|     |  2.5|     |     |   [Start: NW gully, 2.5m deep]
(  2) |     |   31|  0.3|  2.4|     |   2m|     |     |   [Upper boulder, 2m high]
(  4) |     |   32|     |  3.7|     |     |     | 12.1|   [very marshy spot]
( 12) |     |   74|     |  2.4|     |0.5/2.5|11.15|     |   [Between boulders, 0.5m to 2.5m high]
(  7) |     |  189|     |  1.8|  1.8| 10.2|     |     |   [Small gully junction]
( 10) |     |  190|     |  5.1|  5.5| 10.1|11.1N|     |   [N side of road and power line crossing]
( 11) |     |  191|     |  5.2|  5.2| 10.1|11.15|     |   [Between path crossings]
(  8) |     |  210|     | 5.11| 5.20|     |11.15|     |   [Between building and statue]
(  9) |     |  211|     |  3.7|  3.7|4x4|5x6|11.15|     |   [Between marshes, 4m by 4m and 5m by 6m]
( 13) |     |  290| 0.1N|  5.2|     | 10.2|     |     |   [N path junction]
( 14) |     |  291|     | 1.10|  2.4|     |     |     |   [Knoll and boulder]
( 16) |     |  301|     | 1.14|  8.4|  3.0|     |     |   [Overgrown pit, 3m deep]
( 17) |     |  302|     | 1.14|     |     |11.1S|     |   [S side of pit]
( 18) |     |  303|     |  1.3|     |    4|     |     |   [Reentrant, 4m deep]
( 19) |     |  304| 0.1S|     |  8.5|     |     |     |   [S ]
( 20) |     |  305|     |  2.7|     |  6x7|     | 12.4|   [Stony ground, 6m by 7m (manned)]
( 21) |     |  306|     |     |     |     |     |     |   []
(  5) |     |   GO| 0.1N|  5.5|  5.2| 10.1|11.1N| 12.3|   [N side of N power line and path crossing (radio)]
(  6) |                 14.2:                         |   [Navigate to finish funnel]
( 24) |                 14.1:                         |   [Follow tapes to finish]
(  3) |                 13.3:                         |   [Mandatory crossing point]
( 15) |                 13.3:                         |   [Mandatory crossing point]
( 22) |                 13.4:                         |   [Mandatory passage]
";
            Assert.AreEqual(expected, actual);

            writer = new StringWriter();
        }