public void TestSQLiteStorage() { var sqliteStorage = new SQLitePodcastService(); sqliteStorage.Migrate(); var feedParser = new FeedParserService(); var podcastService = new PodcastService(feedParser, sqliteStorage, null); var podcasts = new List <Podcast>(); var podcast = podcastService.GetPodcastAsync("http://monstercat.com/podcast/feed.xml").Result; podcasts.Add(podcast); podcastService.SavePodcastAsync(podcast).Wait(); podcastService.SavePodcastsAsync(podcasts).Wait(); var podcastsFromStorage = podcastService.GetPodcastsAsync().Result.ToList(); Assert.AreEqual(podcasts.Count, podcastsFromStorage.Count); for (int i = 0; i < podcasts.Count; i++) { Assert.AreEqual(true, podcasts[i].Equals(podcastsFromStorage[i])); } }
private async Task <List <Podcast> > ParseFeed(string rss) { return(await Task.Run(() => { return PodcastService.ParsePodcastRss(rss); })); }
private PodcastService CreatePodcastService() { var userID = User.Identity.GetUserId(); var service = new PodcastService(userID); return(service); }
public async Task LoadNewEpisodesAsync() { int newEpisodesCount = 0; var allEpisodes = allPodcasts.SelectMany(p => p.Episodes).ToList(); var episodes = allEpisodes.ToList(); var newEpisodes = await PodcastService.CheckForNewEpisodes(allPodcasts.Select(p => p.Podcast)); episodes.AddRange(from episode in newEpisodes select new EpisodeViewModel(episode)); foreach (var episode in episodes) { if (!allEpisodes.Contains(episode)) { allEpisodes.Add(episode); newEpisodesCount++; } } allEpisodes = allEpisodes.OrderByDescending(e => e.Episode.Published).ToList(); var episodesToAdd = allEpisodes.Take(newEpisodesCount).ToList(); foreach (var episode in episodesToAdd) { _episodes.Insert(episodesToAdd.Count - newEpisodesCount, episode); newEpisodesCount--; } await SavePodcastsAsync(); }
public PodcastController(IConfiguration configuration) { string connectionString = configuration.GetSection("ConnectionStrings")["AlgunasVainasConnection"]; _repository = new PodcastRepository(connectionString); _service = new PodcastService(_repository); }
public PodcastServiceShould() { var fixture = new Fixture(); var data = fixture.CreateMany <Podcast>(10).ToList(); _sut = new PodcastService(data); }
public void Setup() { conn = "Server=XXXXX;Database=XXXXX; User ID=XXXXX;Password=XXXXX;Trusted_Connection=False; Encrypt=True;"; repMock = new PodcastRepositoryMock(); svcMock = new PodcastService(repMock); rep = new PodcastRepository(conn); svc = new PodcastService(rep); }
//private ApplicationDbContext _db = new ApplicationDbContext(); // GET: Podcast public ActionResult Index() { var userID = User.Identity.GetUserId(); var service = new PodcastService(userID); var model = service.GetPodcasts(); return(View(model)); }
public AdminService(PodcastRepository podcastRepository, TagsRepository tagsRepository, PodcastService podcastService) { _podcastRepository = podcastRepository; _tagsRepository = tagsRepository; _podcastService = podcastService; }
public PodcastsController( PodcastService podcastService, TagService tagService, IMediator mediator) { _tagService = tagService; _podcastService = podcastService; _mediator = mediator; }
public void TestDownload() { var localStorage = new LocalPodcastService("podcasts.json"); var feedParser = new FeedParserService(); var fileManager = new FileDownloadService(); var podcastService = new PodcastService(feedParser, localStorage, fileManager); var podcastFromService = podcastService.GetPodcastAsync("http://monstercat.com/podcast/feed.xml").Result; podcastService.DownloadEpisodeAsync(podcastFromService.Episodes.OrderByDescending(e => e.Published).ToList()[0]).Wait(); }
public void ShouldGetPodcasts() { // Given var context = new Context <PodcastService>(); PodcastService sut = context.CreateSut(); // When IReadOnlyCollection <PodcastModel> podcasts = sut.GetPodcasts(); // Then podcasts.Should().HaveCount(2); }
public void ShouldGetFeed() { // Given var context = new Context <PodcastService>(); Guid podcastId = Guid.NewGuid(); PodcastService sut = context.CreateSut(); // When FeedModel feed = sut.GetFeed(podcastId); // Then feed.Should().NotBeNull(); }
public async Task ShouldRemovePodcast() { // Given var context = new Context <PodcastService>(); Guid podcastId = Guid.NewGuid(); PodcastService sut = context.CreateSut(); // When await sut.RemovePodcast(podcastId); // Then context.DeletedPodcastId.ShouldBeEquivalentTo(podcastId); }
public Form1() { InitializeComponent(); IPodcastDal dataacess = new PodcastDataAccess.PodcastDal(); service = new PodcastService(dataacess); service.Initialize(); var savedPodcasts = service.GetAllPodcast(); foreach (var p in savedPodcasts) { string[] podcastInfo = { p.ID.ToString(), p.Name, p.Episodes.ToString(), p.RefreshInterval.ToString(), p.Category }; ListViewItem PodcastListDisplay = new ListViewItem(podcastInfo); listPodcast.Items.Add(PodcastListDisplay); } listPodcast.FullRowSelect = true; fillMyCategoryList(); fillMyCombobox(); }
public async Task ShouldAddPodcast() { // Given var context = new Context <PodcastService>(); string feedUrl = "http://www.dr.dk/mu/Feed/harddisken?format=podcast&limit=500"; PodcastService sut = context.CreateSut(); // When await sut.AddPodcast(feedUrl); // Then Podcast addedPodcast = context.AddedPodcast; addedPodcast.Should().NotBeNull(); addedPodcast.Should().NotBeNull(); addedPodcast.Id.Should().NotBeEmpty(); addedPodcast.Title.Should().Be("Harddisken"); addedPodcast.Description.Should().Be("Harddisken er radioens teknologimagasin på P1. Vi forklarer de konkrete teknologiske udviklinger og deres konsekvenser for kulturen, samfundet og hverdagen."); addedPodcast.FeedUrl.Should().Be(feedUrl); addedPodcast.ImageUrl.Should().Be("http://www.dr.dk/mu/Asset?Id=5576dda66187a4061caf6d0e.jpg"); }
private string GetTrackArtworkId(DatabaseTrackInfo track) { return(PodcastService.ArtworkIdFor(PodcastTrackInfo.From(track).Feed)); }
public async Task SavePodcastsAsync() { await PodcastService.SavePodcastsToLocalStorage(allPodcasts.Select(p => p.Podcast).ToList()); }
public HomeService(PodcastService podcastService) { _podcastService = podcastService; }
public DashboardRepo(PodcastService podcastService) { this.podcastService = podcastService; }
public Landing(PodcastService podcastService) { _podcastService = podcastService; }
public override void Render(CellContext context, double cellWidth, double cellHeight) { if (BoundObject == null) { return; } if (!(BoundObject is Feed)) { throw new InvalidCastException("ColumnCellPodcast can only bind to Feed objects"); } Feed feed = (Feed)BoundObject; bool is_default = false; ImageSurface image = artwork_manager == null ? null : artwork_manager.LookupScaleSurface(PodcastService.ArtworkIdFor(feed), image_size, true); if (image == null) { image = default_cover_image; is_default = true; } // int image_render_size = is_default ? image.Height : (int)cellHeight - 8; int image_render_size = image_size; int x = image_spacing; int y = ((int)cellHeight - image_render_size) / 2; ArtworkRenderer.RenderThumbnail(context.Context, image, false, x, y, image_render_size, image_render_size, !is_default, context.Theme.Context.Radius); int fl_width = 0, fl_height = 0, sl_width = 0, sl_height = 0; context.Widget.StyleContext.Save(); context.Widget.StyleContext.AddClass("cell"); context.StyleContext.State |= context.State; Cairo.Color text_color = CairoExtensions.GdkRGBAToCairoColor(context.Widget.StyleContext.GetColor(context.StyleContext.State)); context.Widget.StyleContext.Restore(); text_color.A = 0.75; Pango.Layout layout = context.Layout; layout.Width = (int)((cellWidth - cellHeight - x - 10) * Pango.Scale.PangoScale); layout.Ellipsize = Pango.EllipsizeMode.End; layout.FontDescription.Weight = Pango.Weight.Bold; // Compute the layout sizes for both lines for centering on the cell int old_size = layout.FontDescription.Size; layout.SetText(feed.Title ?? String.Empty); layout.GetPixelSize(out fl_width, out fl_height); if (feed.DbId > 0) { layout.FontDescription.Weight = Pango.Weight.Normal; layout.FontDescription.Size = (int)(old_size * Pango.Scale.Small); layout.FontDescription.Style = Pango.Style.Italic; if (feed.LastDownloadTime == DateTime.MinValue) { layout.SetText(Catalog.GetString("Never updated")); } else if (feed.LastDownloadTime.Date == DateTime.Now.Date) { layout.SetText(String.Format(Catalog.GetString("Updated at {0}"), feed.LastDownloadTime.ToShortTimeString())); } else { layout.SetText(String.Format(Catalog.GetString("Updated {0}"), Hyena.Query.RelativeTimeSpanQueryValue.RelativeToNow(feed.LastDownloadTime).ToUserQuery())); } layout.GetPixelSize(out sl_width, out sl_height); } // Calculate the layout positioning x = ((int)cellHeight - x) + 10; y = (int)((cellHeight - (fl_height + sl_height)) / 2); // Render the second line first since we have that state already if (feed.DbId > 0) { context.Context.MoveTo(x, y + fl_height); context.Context.SetSourceColor(text_color); Pango.CairoHelper.ShowLayout(context.Context, layout); } // Render the first line, resetting the state layout.SetText(feed.Title ?? String.Empty); layout.FontDescription.Weight = Pango.Weight.Bold; layout.FontDescription.Size = old_size; layout.FontDescription.Style = Pango.Style.Normal; layout.SetText(feed.Title ?? String.Empty); context.Context.MoveTo(x, y); text_color.A = 1; context.Context.SetSourceColor(text_color); Pango.CairoHelper.ShowLayout(context.Context, layout); }