public async Task FastDownloadWorks()
        {
            var downloader = new FeedDownloaderStub();
            var series = new Series();
            await series.SetEpisodes(Task.FromResult(new List<Episode>().AsEnumerable()));
            downloader.SetResult(Task.FromResult(series));
            var underTest = new PodcastCollection(downloader);

            Assert.AreEqual(7, underTest.AllGroups.Count);
        }
        public async Task ExcpetionsCreateEmptySeries()
        {
            var downloader = new FeedDownloaderStub();
            var series = new Series();

            var episodeTCS = new TaskCompletionSource<IEnumerable<Episode>>();
            var downloadTCS = new TaskCompletionSource<Series>();

            var parseTask = series.SetEpisodes(episodeTCS.Task);
            downloader.SetResult(downloadTCS.Task);

            var underTest = new PodcastCollection(downloader);

            episodeTCS.TrySetResult(new List<Episode>().AsEnumerable());
            downloadTCS.TrySetException(new NullReferenceException());
            await parseTask;

            Assert.AreEqual(0, underTest.AllGroups.Count);
        }
        public async Task SlowDownloadWorks()
        {
            var downloader = new FeedDownloaderStub();
            var series = new Series();

            var episodeTCS = new TaskCompletionSource<IEnumerable<Episode>>();
            var downloadTCS = new TaskCompletionSource<Series>();

            var parseTask = series.SetEpisodes(episodeTCS.Task);
            downloader.SetResult(downloadTCS.Task);

            var underTest = new PodcastCollection(downloader);

            episodeTCS.TrySetResult(new List<Episode>().AsEnumerable());
            downloadTCS.TrySetResult(series);
            await parseTask;

            Assert.AreEqual(7, underTest.AllGroups.Count);
        }
 public void NullDownloaderFails()
 {
     var undertest = new PodcastCollection(default(IFeedDownloader));
     Assert.AreEqual(0, undertest.AllGroups.Count);
 }