예제 #1
0
        public void TestAddDefaultPositions()
        {
            LMTimelineEvent evt = new LMTimelineEvent();

            evt.EventType = new EventType();
            evt.EventType.TagFieldPosition     = false;
            evt.EventType.TagHalfFieldPosition = false;
            evt.EventType.TagGoalPosition      = false;

            Assert.IsNull(evt.FieldPosition);
            Assert.IsNull(evt.HalfFieldPosition);
            Assert.IsNull(evt.GoalPosition);
            evt.AddDefaultPositions();
            Assert.IsNull(evt.FieldPosition);
            Assert.IsNull(evt.HalfFieldPosition);
            Assert.IsNull(evt.GoalPosition);

            evt.EventType.TagFieldPosition = true;
            evt.AddDefaultPositions();
            Assert.IsNotNull(evt.FieldPosition);
            Assert.IsNull(evt.HalfFieldPosition);
            Assert.IsNull(evt.GoalPosition);

            evt.EventType.TagFieldPosition     = false;
            evt.EventType.TagHalfFieldPosition = true;
            evt.AddDefaultPositions();
            Assert.IsNotNull(evt.FieldPosition);
            Assert.IsNotNull(evt.HalfFieldPosition);
            Assert.IsNull(evt.GoalPosition);

            evt.EventType.TagFieldPosition     = false;
            evt.EventType.TagHalfFieldPosition = false;
            evt.EventType.TagGoalPosition      = true;
            evt.AddDefaultPositions();
            Assert.IsNotNull(evt.FieldPosition);
            Assert.IsNotNull(evt.HalfFieldPosition);
            Assert.IsNotNull(evt.GoalPosition);

            /* Adding the default positions doesn't not overwrite the existing data */
            evt.EventType.FieldPositionIsDistance     = true;
            evt.EventType.HalfFieldPositionIsDistance = true;
            evt.FieldPosition.Points [0].X            = 100;
            evt.FieldPosition.Points [0].Y            = 100;
            evt.HalfFieldPosition.Points [0].X        = 100;
            evt.HalfFieldPosition.Points [0].Y        = 100;
            evt.AddDefaultPositions();
            Assert.AreEqual(1, evt.FieldPosition.Points.Count);
            Assert.AreEqual(1, evt.HalfFieldPosition.Points.Count);
            Assert.AreEqual(100, evt.FieldPosition.Points [0].X);
            Assert.AreEqual(100, evt.HalfFieldPosition.Points [0].X);
        }
        public void TestSetEventVMWithCoordinates()
        {
            Mock <IDrawingToolkit> tkMock = new Mock <IDrawingToolkit> ();
            var timelineEvent             = new LMTimelineEvent {
                EventType = new EventType()
            };

            timelineEvent.EventType.TagFieldPosition = true;
            timelineEvent.AddDefaultPositions();
            var timelineEventVM = new LMTimelineEventVM {
                Model = timelineEvent
            };

            TimelineEventLocationView view = new TimelineEventLocationView {
                FieldPosition    = FieldPositionType.Field,
                BackgroundWidth  = 100,
                BackgroundHeight = 100,
            };

            view.SetViewModel(timelineEventVM);

            view.Draw(tkMock.Object, null);

            tkMock.Verify(tk => tk.DrawCircle(It.IsAny <Point> (), It.IsAny <double> ()), Times.Once());
        }
        public void TestEventDrawWhenPointChanges()
        {
            int redrawCount = 0;
            Mock <IDrawingToolkit> tkMock = new Mock <IDrawingToolkit> ();
            var timelineEvent             = new LMTimelineEvent {
                EventType = new EventType()
            };
            var timelineEventVM = new LMTimelineEventVM {
                Model = timelineEvent
            };
            TimelineEventLocationView view = new TimelineEventLocationView {
                FieldPosition    = FieldPositionType.Field,
                BackgroundWidth  = 100,
                BackgroundHeight = 100,
            };

            view.SetViewModel(timelineEventVM);
            view.RedrawEvent += (co, area) => redrawCount++;

            timelineEvent.EventType.TagFieldPosition = true;
            timelineEvent.AddDefaultPositions();

            view.Points = timelineEvent.FieldPosition.Points;
            view.Draw(tkMock.Object, null);

            Assert.Greater(redrawCount, 1);
            tkMock.Verify(tk => tk.DrawCircle(It.IsAny <Point> (), It.IsAny <double> ()), Times.Once());
        }
        public void HandleViewModelPropertyChanged_TimeChanged_RedrawNotTriggered()
        {
            int redrawCount = 0;
            Mock <IDrawingToolkit> tkMock = new Mock <IDrawingToolkit> ();
            var timelineEvent             = new LMTimelineEvent {
                EventType = new EventType()
            };
            var timelineEventVM = new LMTimelineEventVM {
                Model = timelineEvent
            };
            TimelineEventLocationView view = new TimelineEventLocationView {
                FieldPosition    = FieldPositionType.Field,
                BackgroundWidth  = 100,
                BackgroundHeight = 100,
            };

            view.SetViewModel(timelineEventVM);
            timelineEvent.EventType.TagFieldPosition = true;
            timelineEvent.AddDefaultPositions();
            view.RedrawEvent += (co, area) => redrawCount++;

            timelineEventVM.Start = new Time();

            Assert.AreEqual(0, redrawCount);
        }