Example #1
0
        public async Task TryToDownloadTwoVideoFromYoutube()
        {
            var path = Path.Combine(RunningPath, "download");

            string[] youtubeList = { "Kv3RfdHZ25c", "3rJfBFamlIw" };
            await Service.DownloadYouTubeAsync(youtubeList, MediaType.MediaCodec.none);

            var files = Directory.GetFiles(path);

            files.Length.ShouldBe(2);
            Directory.Delete(path, true);
        }
Example #2
0
        public void YoutubeToMp4Calls()
        {
            IYouTubeService service   = Substitute.For <IYouTubeService>();
            List <string>   dummyUrls = new List <string>()
            {
                "", ""
            };

            int counter = 0;

            service
            .When(e => e.DownloadYouTubeAsync(Arg.Any <List <string> >(), Arg.Any <MediaType.MediaCodec>()))
            .Do(_ => counter++);

            service.DownloadYouTubeAsync(dummyUrls, MediaType.MediaCodec.mp3);
            service.DownloadYouTubeAsync(dummyUrls, MediaType.MediaCodec.mp3);
            service.DownloadYouTubeAsync(dummyUrls, MediaType.MediaCodec.mp3);
            counter.ShouldBe(3);
        }
Example #3
0
        public void YoutubeToMp4Exception()
        {
            IYouTubeService service = Substitute.For <IYouTubeService>();

            service
            .When(x => x.DownloadYouTubeAsync("", MediaType.MediaCodec.none))
            .Do(x => throw new Exception());

            Action action = () => service.DownloadYouTubeAsync("", MediaType.MediaCodec.none);

            action.ShouldThrow <Exception>();
        }