public void TestSerialization() { MediaFile mf = new MediaFile ("path", 34000, 25, true, true, "mp4", "h264", "aac", 320, 240, 1.3, null, "Test asset"); var pd = new ProjectDescription (); Utils.CheckSerialization (pd); pd.FileSet = new MediaFileSet (); pd.FileSet.Add (mf); pd.Competition = "Comp"; pd.Category = "Cat"; pd.Group = "Group"; pd.Phase = "Phase"; pd.Season = "Season"; pd.LastModified = DateTime.UtcNow.ToUniversalTime (); pd.LocalGoals = 1; pd.VisitorGoals = 2; pd.MatchDate = DateTime.UtcNow.ToUniversalTime (); Utils.CheckSerialization (pd); ProjectDescription newpd = Utils.SerializeDeserialize (pd); Assert.AreEqual (pd.FileSet.First ().FilePath, newpd.FileSet.First ().FilePath); Assert.AreEqual (pd.Competition, newpd.Competition); Assert.AreEqual (pd.Category, newpd.Category); Assert.AreEqual (pd.Group, newpd.Group); Assert.AreEqual (pd.Phase, newpd.Phase); Assert.AreEqual (pd.Season, newpd.Season); Assert.AreEqual (pd.LocalGoals, newpd.LocalGoals); Assert.AreEqual (pd.VisitorGoals, newpd.VisitorGoals); Assert.AreEqual (pd.MatchDate, newpd.MatchDate); }
public void TestAddProject() { string dbdir = Path.Combine (tmpdir, "test.ldb"); DataBase db = new DataBase (dbdir); ProjectDescription pd1 = new ProjectDescription (); Project p1 = new Project {Description = pd1}; Assert.IsTrue (db.AddProject (p1)); Assert.IsTrue (File.Exists (Path.Combine (dbdir, p1.ID.ToString()))); Assert.IsTrue (db.AddProject (p1)); Assert.AreEqual (db.Count, 1); db = new DataBase (dbdir); Assert.AreEqual (db.Count, 1); }
static string FormatDesc(ProjectDescription pdesc) { string desc = String.Format ("{0}-{1} ({2}-{3})\n{4}: {5}\n{6}: {7}\n{8}: {9}", pdesc.LocalName, pdesc.VisitorName, pdesc.LocalGoals, pdesc.VisitorGoals, Catalog.GetString ("Date"), pdesc.MatchDate.ToShortDateString (), Catalog.GetString ("Competition"), pdesc.Competition, Catalog.GetString ("Season"), pdesc.Season); return desc; }
ProjectLongoMatch CreateProject(bool fill = true) { ProjectLongoMatch p = new ProjectLongoMatch (); p.Dashboard = DashboardLongoMatch.DefaultTemplate (10); p.UpdateEventTypesAndTimers (); p.LocalTeamTemplate = SportsTeam.DefaultTemplate (10); p.VisitorTeamTemplate = SportsTeam.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; }
public static int Sort(ProjectDescription p1, ProjectDescription p2, ProjectSortType sortType) { int ret = 0; if (p1 == null && p2 == null) { ret = 0; } else if (p1 == null) { ret = -1; } else if (p2 == null) { ret = 1; } else { switch (sortType) { case ProjectSortType.SortByName: { ret = String.Compare (p1.Title, p2.Title); if (ret == 0) { ret = -DateTime.Compare (p1.MatchDate, p2.MatchDate); } break; } case ProjectSortType.SortByDate: { ret = -DateTime.Compare (p1.MatchDate, p2.MatchDate); if (ret == 0) { ret = String.Compare (p1.Title, p2.Title); } break; } case ProjectSortType.SortByModificationDate: { ret = -DateTime.Compare (p1.LastModified, p2.LastModified); break; } case ProjectSortType.SortBySeason: { ret = String.Compare (p1.Season, p2.Season); if (ret == 0) { ret = String.Compare (p1.Title, p2.Title); } break; } case ProjectSortType.SortByCompetition: { ret = String.Compare (p1.Competition, p2.Competition); if (ret == 0) { ret = String.Compare (p1.Title, p2.Title); } break; } } } return ret; }
void HandleProjectSelected(ProjectDescription project) { Config.EventsBroker.EmitOpenProjectID (project.ProjectID); }
public bool Add(ProjectDescription desc) { if (ProjectsDict.ContainsKey (desc.ProjectID)) { ProjectsDict [desc.ProjectID] = desc; } else { ProjectsDict.Add (desc.ProjectID, desc); } return Save (); }
static public int Sort(ProjectDescription p1, ProjectDescription p2, ProjectSortType sortType) { int ret = 0; if (p1 == null && p2 == null) { ret = 0; } else if (p1 == null) { ret = -1; } else if (p2 == null) { ret = 1; } else { switch (sortType) { case ProjectSortType.SortByName: { ret = String.Compare(p1.Title, p2.Title); if (ret == 0) { ret = -DateTime.Compare(p1.MatchDate, p2.MatchDate); } break; } case ProjectSortType.SortByDate: { ret = -DateTime.Compare(p1.MatchDate, p2.MatchDate); if (ret == 0) { ret = String.Compare(p1.Title, p2.Title); } break; } case ProjectSortType.SortByModificationDate: { ret = -DateTime.Compare(p1.LastModified, p2.LastModified); break; } case ProjectSortType.SortBySeason: { ret = String.Compare(p1.Season, p2.Season); if (ret == 0) { ret = String.Compare(p1.Title, p2.Title); } break; } case ProjectSortType.SortByCompetition: { ret = String.Compare(p1.Competition, p2.Competition); if (ret == 0) { ret = String.Compare(p1.Title, p2.Title); } break; } } } return(ret); }
/// <summary> /// Updates the project description with a matching ID to the new description. /// </summary> /// <param name="description">Project Description.</param> public void UpdateProject(ProjectDescription description) { TreeIter first; /* Projects are only update in the treeview mode */ store.GetIterFirst (out first); while (store.IterIsValid (first)) { ProjectDescription pd = store.GetValue (first, COL_PROJECT_DESCRIPTION) as ProjectDescription; if (description.ID == pd.ID) { // Change value in model store.SetValue (first, COL_DISPLAY_NAME, FormatDesc (description)); store.SetValue (first, COL_PROJECT_DESCRIPTION, description); // Also update our internal list projects [projects.IndexOf (pd)] = description; break; } store.IterNext (ref first); } }
public void TestUpdateProject() { string dbdir = Path.Combine (tmpdir, "test.ldb"); DataBase db = new DataBase (dbdir); ProjectDescription pd1 = new ProjectDescription (); Project p1 = new Project {Description = pd1}; DateTime lastModified = p1.Description.LastModified; Assert.IsTrue (db.AddProject (p1)); Assert.IsTrue (db.UpdateProject (p1)); Assert.AreNotEqual (p1.Description.LastModified, lastModified); }
public void TestGetProject() { string dbdir = Path.Combine (tmpdir, "test.ldb"); DataBase db = new DataBase (dbdir); ProjectDescription pd1 = new ProjectDescription (); Project p1 = new Project {Description = pd1}; db.AddProject (p1); Project p2 = db.GetProject (p1.ID); Assert.AreEqual (p1.ID, p2.ID); Assert.IsNull (db.GetProject (new Guid())); }
public void TestGetAllProjects() { string dbdir = Path.Combine (tmpdir, "test.ldb"); DataBase db = new DataBase (dbdir); ProjectDescription pd1 = new ProjectDescription (); ProjectDescription pd2 = new ProjectDescription (); Project p1 = new Project {Description = pd1}; Project p2 = new Project {Description = pd2}; db.AddProject (p1); db.AddProject (p2); Assert.AreEqual (db.Count, 2); List<ProjectDescription> projects = db.GetAllProjects (); Assert.AreEqual (db.Count, 2); Assert.AreEqual (projects.Count, 2); Assert.AreEqual (projects[0], pd1); Assert.AreEqual (projects[1], pd2); }
public void TestExists() { string dbdir = Path.Combine (tmpdir, "test.ldb"); DataBase db = new DataBase (dbdir); ProjectDescription pd1 = new ProjectDescription (); Project p1 = new Project {Description = pd1}; Assert.IsFalse (db.Exists (p1)); db.AddProject (p1); Assert.IsTrue (db.Exists (p1)); }
public void TestSetDescription() { ProjectDescription pd = new ProjectDescription (); Project p = new Project (); p.Description = pd; Assert.IsNotNull (pd.ID); Assert.AreEqual (p.ID, pd.ProjectID); }