Example #1
0
        public void TestDeleteProjectItems()
        {
            LMProject p = new LMProject();

            p.Dashboard = LMDashboard.DefaultTemplate(10);
            p.UpdateEventTypesAndTimers();
            p.LocalTeamTemplate = LMTeam.DefaultTemplate(10);

            for (int i = 0; i < 10; i++)
            {
                LMTimelineEvent evt = new LMTimelineEvent {
                    EventType = p.EventTypes [i],
                    Start     = new Time(1000),
                    Stop      = new Time(2000),
                };
                p.Timeline.Add(evt);
            }

            storage.Store(p);
            p = storage.Retrieve <LMProject> (p.ID);

            // Removing this object should not remove the EvenType from the database, which might be referenced by
            // LMTimelineEvent's in the timeline
            EventType evtType = (p.Dashboard.List [0] as AnalysisEventButton).EventType;

            p.Dashboard.List.Remove(p.Dashboard.List [0]);
            storage.Store(p);
            Assert.DoesNotThrow(() => storage.Retrieve <LMProject> (p.ID));

            // Delete an event with a LMPlayer, a Team and an EventType, it should delete only the timeline event
            p.Timeline [0].Teams.Add(p.LocalTeamTemplate);
            p.Timeline [0].Players.Add(p.LocalTeamTemplate.List [0]);
            p.Timeline.Remove(p.Timeline [0]);
            Assert.DoesNotThrow(() => storage.Retrieve <LMProject> (p.ID));
        }
Example #2
0
        public void TestProject()
        {
            LMProject p = new LMProject();

            p.Dashboard = LMDashboard.DefaultTemplate(10);
            p.UpdateEventTypesAndTimers();
            p.LocalTeamTemplate   = LMTeam.DefaultTemplate(10);
            p.VisitorTeamTemplate = LMTeam.DefaultTemplate(12);
            MediaFile mf = new MediaFile("path", 34000, 25, true, true, "mp4", "h264",
                                         "aac", 320, 240, 1.3, null, "Test asset");
            var pd = new ProjectDescription();

            pd.FileSet = new MediaFileSet();
            pd.FileSet.Add(mf);
            p.Description = pd;
            p.AddEvent(new LMTimelineEvent());

            storage.Store <LMProject> (p);
            Assert.AreEqual(45, db.DocumentCount);

            p = storage.RetrieveAll <LMProject> ().First();
            Assert.IsNotNull(p.DocumentID);
            p.Load();
            Assert.IsTrue(Object.ReferenceEquals(p.Description.FileSet, p.Timeline [0].FileSet));
            storage.Store(p);
            Assert.AreEqual(45, db.DocumentCount);

            storage.Delete(p);
            Assert.AreEqual(1, db.DocumentCount);
        }
Example #3
0
        LMProject CreateProject()
        {
            var project = new LMProject {
                Description = new ProjectDescription()
            };

            project.LocalTeamTemplate = (LMTeam)App.Current.TeamTemplatesProvider.Templates.FirstOrDefault(t => t.Name == "spain");
            Assert.IsNotNull(project.LocalTeamTemplate);
            project.VisitorTeamTemplate = (LMTeam)App.Current.TeamTemplatesProvider.Templates.FirstOrDefault(t => t.Name == "france");
            Assert.IsNotNull(project.VisitorTeamTemplate);
            project.Dashboard = App.Current.CategoriesTemplatesProvider.Templates.FirstOrDefault(t => t.Name == "basket") as LMDashboard;
            Assert.IsNotNull(project.Dashboard);
            project.Description.Competition = "Liga";
            project.Description.MatchDate   = DateTime.UtcNow;
            project.Description.Description = "Created by LongoMatch";
            project.Description.Season      = "2015-2016";
            project.Description.LocalName   = project.LocalTeamTemplate.TeamName;
            project.Description.VisitorName = project.VisitorTeamTemplate.TeamName;
            project.Description.FileSet     = new MediaFileSet();
            project.Description.FileSet.Add(new MediaFile {
                FilePath = "Test.mp4",
                Duration = new Time {
                    TotalSeconds = 60000
                }
            });
            project.UpdateEventTypesAndTimers();
            return(project);
        }
Example #4
0
        LMProject CreateProject(bool fill = true)
        {
            LMProject p = new LMProject();

            p.Dashboard = LMDashboard.DefaultTemplate(10);
            p.UpdateEventTypesAndTimers();
            p.LocalTeamTemplate   = LMTeam.DefaultTemplate(10);
            p.VisitorTeamTemplate = LMTeam.DefaultTemplate(12);
            MediaFile mf = new MediaFile("path", 34000, 25, true, true, "mp4", "h264",
                                         "aac", 320, 240, 1.3, null, "Test asset");
            var pd = new ProjectDescription();

            pd.FileSet = new MediaFileSet();
            pd.FileSet.Add(mf);
            p.Description = pd;
            if (fill)
            {
                p.AddEvent(p.EventTypes [0], new Time(1000), new Time(2000), null, null);
                p.AddEvent(p.EventTypes [0], new Time(1000), new Time(2000), null, null);
                p.AddEvent(p.EventTypes [1], new Time(1000), new Time(2000), null, null);
                p.AddEvent(p.EventTypes [2], new Time(1000), new Time(2000), null, null);
                p.AddEvent(p.EventTypes [2], new Time(1000), new Time(2000), null, null);
                p.AddEvent(p.EventTypes [2], new Time(1000), new Time(2000), null, null);
                p.AddEvent(p.EventTypes [6], new Time(1000), new Time(2000), null, null);
            }

            return(p);
        }
Example #5
0
        //Specific LongoMatch objects
        public static LMProject CreateProject(bool withEvents = true)
        {
            LMTimelineEvent pl;
            LMProject       p = new LMProject();

            p.Dashboard         = LMDashboard.DefaultTemplate(10);
            p.LocalTeamTemplate = LMTeam.DefaultTemplate(5);
            p.LocalTeamTemplate.FormationStr   = "2-2";
            p.VisitorTeamTemplate              = LMTeam.DefaultTemplate(5);
            p.VisitorTeamTemplate.FormationStr = "2-2";
            var pd = new ProjectDescription();

            pd.FileSet = new MediaFileSet();
            pd.FileSet.Add(new MediaFile(Path.GetTempFileName(), 34000, 25, true, true, "mp4", "h264",
                                         "aac", 320, 240, 1.3, null, "Test asset 1"));
            pd.FileSet.Add(new MediaFile(Path.GetTempFileName(), 34000, 25, true, true, "mp4", "h264",
                                         "aac", 320, 240, 1.3, null, "Test asset 2"));
            p.Description = pd;
            p.UpdateEventTypesAndTimers();

            if (withEvents)
            {
                AnalysisEventButton b = p.Dashboard.List [0] as AnalysisEventButton;

                /* No tags, no players */
                pl = new LMTimelineEvent {
                    EventType = b.EventType,
                    Start     = new Time(0),
                    Stop      = new Time(100),
                    FileSet   = pd.FileSet
                };
                p.Timeline.Add(pl);
                /* tags, but no players */
                b  = p.Dashboard.List [1] as AnalysisEventButton;
                pl = new LMTimelineEvent {
                    EventType = b.EventType,
                    Start     = new Time(0),
                    Stop      = new Time(100),
                    FileSet   = pd.FileSet
                };
                pl.Tags.Add(b.AnalysisEventType.Tags [0]);
                p.Timeline.Add(pl);
                /* tags and players */
                b  = p.Dashboard.List [2] as AnalysisEventButton;
                pl = new LMTimelineEvent {
                    EventType = b.EventType,
                    Start     = new Time(0),
                    Stop      = new Time(100),
                    FileSet   = pd.FileSet
                };
                pl.Tags.Add(b.AnalysisEventType.Tags [1]);
                pl.Players.Add(p.LocalTeamTemplate.List [0]);
                p.Timeline.Add(pl);
            }

            return(p);
        }
Example #6
0
        public void TestUpdateEventTypesAndTimers()
        {
            LMProject p = new LMProject();

            p.Dashboard = LMDashboard.DefaultTemplate(5);
            Assert.AreEqual(0, p.Timers.Count);
            Assert.AreEqual(0, p.EventTypes.Count);
            p.UpdateEventTypesAndTimers();
            Assert.AreEqual(1, p.Timers.Count);
            Assert.AreEqual(10, p.EventTypes.Count);

            // Delete a category button with no events
            p.Dashboard.List.Remove(p.Dashboard.List.OfType <AnalysisEventButton> ().First());
            p.UpdateEventTypesAndTimers();
            Assert.AreEqual(1, p.Timers.Count);
            Assert.AreEqual(9, p.EventTypes.Count);

            // Delete a category button with events in the timeline
            AnalysisEventButton button = p.Dashboard.List.OfType <AnalysisEventButton> ().First();

            p.Timeline.Add(new LMTimelineEvent {
                EventType = button.EventType
            });
            p.UpdateEventTypesAndTimers();
            Assert.AreEqual(1, p.Timers.Count);
            Assert.AreEqual(9, p.EventTypes.Count);
            p.Dashboard.List.Remove(button);
            p.UpdateEventTypesAndTimers();
            Assert.AreEqual(1, p.Timers.Count);
            Assert.AreEqual(9, p.EventTypes.Count);

            // Remove the event from the timeline, the event type is no longuer in the dashboard or the timeline
            p.Timeline.Clear();
            p.UpdateEventTypesAndTimers();
            Assert.AreEqual(1, p.Timers.Count);
            Assert.AreEqual(8, p.EventTypes.Count);
        }
 void FillProject()
 {
     project.Dashboard               = analysisTemplate;
     project.LocalTeamTemplate       = hometemplate;
     project.VisitorTeamTemplate     = awaytemplate;
     project.Description.Competition = competitionentry.Text;
     project.Description.MatchDate   = datepicker1.Date;
     project.Description.Description = desctextview.Buffer.GetText(desctextview.Buffer.StartIter,
                                                                   desctextview.Buffer.EndIter, true);
     project.Description.Season      = seasonentry.Text;
     project.Description.LocalName   = project.LocalTeamTemplate.TeamName;
     project.Description.VisitorName = project.VisitorTeamTemplate.TeamName;
     project.Description.FileSet     = mediafilesetselection1.FileSet;
     project.UpdateEventTypesAndTimers();
     project.ConsolidateDescription();
     project.ProjectType = projectType;
 }
Example #8
0
        public void TestSaveProjectWithEvents()
        {
            LMProject p = new LMProject();

            p.Dashboard = LMDashboard.DefaultTemplate(10);
            p.UpdateEventTypesAndTimers();
            p.LocalTeamTemplate   = LMTeam.DefaultTemplate(10);
            p.VisitorTeamTemplate = LMTeam.DefaultTemplate(12);
            MediaFile mf = new MediaFile("path", 34000, 25, true, true, "mp4", "h264",
                                         "aac", 320, 240, 1.3, null, "Test asset");
            var pd = new ProjectDescription();

            pd.FileSet = new MediaFileSet();
            pd.FileSet.Add(mf);
            p.Description = pd;

            for (int i = 0; i < 10; i++)
            {
                LMTimelineEvent evt = new LMTimelineEvent {
                    EventType = p.EventTypes [i],
                    Start     = new Time(1000),
                    Stop      = new Time(2000),
                };
                evt.Players.Add(p.LocalTeamTemplate.Players [0]);
                p.Timeline.Add(evt);
            }

            storage.Store <LMProject> (p);
            Assert.AreEqual(54, db.DocumentCount);
            storage.Store <LMProject> (p);
            Assert.AreEqual(54, db.DocumentCount);

            LMProject p2 = storage.Retrieve <LMProject> (p.ID);

            Assert.AreEqual(p.Timeline.Count, p2.Timeline.Count);
            Assert.AreEqual(p2.LocalTeamTemplate.List [0], p2.Timeline [0].Players [0]);
            Assert.AreEqual((p2.Dashboard.List [0] as AnalysisEventButton).EventType,
                            p2.Timeline [0].EventType);
            Assert.IsNotNull(p2.DocumentID);

            storage.Delete(p);
            Assert.AreEqual(1, db.DocumentCount);
        }
Example #9
0
        //Specific LongoMatch objects
        public static LMProject CreateProject(bool withEvents = true, bool withLineupEvent = false)
        {
            LMTimelineEvent pl;
            LMProject       p = new LMProject();

            p.Dashboard         = LMDashboard.DefaultTemplate(10);
            p.LocalTeamTemplate = LMTeam.DefaultTemplate(5);
            p.LocalTeamTemplate.FormationStr   = "2-2";
            p.VisitorTeamTemplate              = LMTeam.DefaultTemplate(5);
            p.VisitorTeamTemplate.FormationStr = "2-2";
            var pd = new ProjectDescription();

            pd.FileSet = new MediaFileSet();
            pd.FileSet.Add(new MediaFile(Path.GetTempFileName(), 34000, 25, true, true, "mp4", "h264",
                                         "aac", 320, 240, 1.3, null, "Test asset 1"));
            pd.FileSet.Add(new MediaFile(Path.GetTempFileName(), 34000, 25, true, true, "mp4", "h264",
                                         "aac", 320, 240, 1.3, null, "Test asset 2"));
            p.Description = pd;
            p.Periods.Replace(new RangeObservableCollection <Period> {
                new Period {
                    Name  = "First Period",
                    Nodes = new RangeObservableCollection <TimeNode> {
                        new TimeNode {
                            Start = new Time(10),
                            Stop  = new Time(50)
                        }
                    }
                },
                new Period {
                    Name  = "Second Period",
                    Nodes = new RangeObservableCollection <TimeNode> {
                        new TimeNode {
                            Start = new Time(50),
                            Stop  = new Time(90)
                        }
                    }
                },
            });
            p.UpdateEventTypesAndTimers();

            if (withLineupEvent)
            {
                p.CreateLineupEvent();
            }

            if (withEvents)
            {
                AnalysisEventButton b = p.Dashboard.List [0] as AnalysisEventButton;

                /* No tags, no players */
                pl = new LMTimelineEvent {
                    EventType = b.EventType,
                    Start     = new Time(0),
                    Stop      = new Time(50),
                    FileSet   = pd.FileSet
                };
                p.Timeline.Add(pl);
                /* tags, but no players */
                b  = p.Dashboard.List [1] as AnalysisEventButton;
                pl = new LMTimelineEvent {
                    EventType = b.EventType,
                    Start     = new Time(20),
                    Stop      = new Time(60),
                    FileSet   = pd.FileSet
                };
                pl.Tags.Add(b.AnalysisEventType.Tags [0]);
                p.Timeline.Add(pl);
                /* tags and players */
                b  = p.Dashboard.List [2] as AnalysisEventButton;
                pl = new LMTimelineEvent {
                    EventType = b.EventType,
                    Start     = new Time(70),
                    Stop      = new Time(100),
                    FileSet   = pd.FileSet
                };
                pl.Tags.Add(b.AnalysisEventType.Tags [1]);
                pl.Players.Add(p.LocalTeamTemplate.List [0]);
                p.Timeline.Add(pl);
            }

            return(p);
        }