Ejemplo n.º 1
0
        public void ComputeFlaggedLegLength()
        {
            UndoMgr undomgr = new UndoMgr(5);
            EventDB eventDB = new EventDB(undomgr);

            ControlPoint control1, control2;
            Leg leg1;
            Event ev = new Event();

            control1 = new ControlPoint(ControlPointKind.Normal, "31", new PointF(4F, -10F));
            control2 = new ControlPoint(ControlPointKind.Normal, "32", new PointF(-3F, 14F));
            undomgr.BeginCommand(123, "Add controls");
            Id<ControlPoint> id1 = eventDB.AddControlPoint(control1);
            Id<ControlPoint> id2 = eventDB.AddControlPoint(control2);

            leg1 = new Leg(id1, id2);
            leg1.bends = new PointF[] { new PointF(6, 3), new PointF(7, 8), new PointF(10, 14) };
            Id<Leg> legId = eventDB.AddLeg(leg1);

            // distances. 13.153, 5.099, 6.708, 13.00   * 15000

            ev.mapScale = 15000;
            eventDB.ChangeEvent(ev);
            undomgr.EndCommand(123);

            float length = QueryEvent.ComputeFlaggedLegLength(eventDB, id1, id2, legId);
            Assert.AreEqual(569.4, length, 0.01);

            undomgr.BeginCommand(123, "Change leg");
            leg1.flagging = FlaggingKind.All;
            eventDB.ReplaceLeg(legId, leg1);
            undomgr.EndCommand(123);
            length = QueryEvent.ComputeFlaggedLegLength(eventDB, id1, id2, legId);
            Assert.AreEqual(569.4, length, 0.01);

            undomgr.BeginCommand(123, "Change leg");
            leg1.flagging = FlaggingKind.Begin;
            leg1.flagStartStop = new PointF(7, 8);
            eventDB.ReplaceLeg(legId, leg1);
            undomgr.EndCommand(123);
            length = QueryEvent.ComputeFlaggedLegLength(eventDB, id1, id2, legId);
            Assert.AreEqual(273.78, length, 0.01);

            undomgr.BeginCommand(123, "Change leg");
            leg1.flagging = FlaggingKind.End;
            eventDB.ReplaceLeg(legId, leg1);
            undomgr.EndCommand(123);
            length = QueryEvent.ComputeFlaggedLegLength(eventDB, id1, id2, legId);
            Assert.AreEqual(295.62, length, 0.01);
        }