public void ShouldGroupsReturnCorrectGroups() { Shows shows = new Shows(); shows.Add(CreateShowControl("Show1", "RSS", "GroupA")); shows.Add(CreateShowControl("Show2", "RSSA", "GroupA")); shows.Add(CreateShowControl("Show3", "RSSB", "GroupB")); shows.Groups().Should().HaveCount(2); shows.Groups().Contains("GroupA").Should().BeTrue(); shows.Groups().Contains("GroupB").Should().BeTrue(); }
private void PopulateTree() { TreeGroupHolder treeGroupHolder = new TreeGroupHolder(ShowsItemsTree); ShowsItemsTree.Items.Clear(); Shows shows = (Shows)Shows.GetShowService; List <string> groups = new List <string>(); groups.Add("Ungrouped"); groups.Add("Frist|Second"); groups.Add("Frist|Second|More"); groups.Add("Frist|Second|MoreB"); groups.Add("Frist|Other|More"); groups = groups.OrderBy(x => x).ToList(); foreach (string groupName in groups) { treeGroupHolder.Add(groupName); } groups = shows.Groups(); groups = groups.OrderBy(x => x).ToList(); AddStaredShows(); foreach (string groupName in groups) { List <ShowControl> showsInCat = shows.ShowInGroup(groupName); if (!showsInCat.Any()) { continue; } showsInCat = showsInCat.OrderBy(x => x.Title).ToList(); TreeViewItem categoryNode = new TreeViewItem { Header = groupName }; ShowsItemsTree.Items.Add(categoryNode); foreach (ShowControl show in showsInCat) { bool local = (show.ShowOption.ShowStorage == ShowStorageType.LocalStorage); string header; string localDisplay = string.Empty; string updatesDisplay = string.Empty; if (local) { localDisplay = " -L-"; } if (show.ShowOption.CheckforUpdates) { updatesDisplay = " -U-"; } header = show.Title + $"{localDisplay}{updatesDisplay} [ {show.EpisodesWatched}/{show.Episodes.Count} ]"; TreeViewItem showNode = new TreeViewItem { Header = header, Tag = show }; categoryNode.Items.Add(showNode); } } }