Пример #1
0
        public void UploadCancel_Test()
        {
            var youtubeFacade = new YoutubeFacade(
                ClientId,
                ClientSecret,
                "Sport Video Analyzer",
                "1/QdUuZknDmquIdTo46TI8kgnhSMG9bEvAvqnWGYq4mRk".ConvertToSecureString());
            var cts             = new CancellationTokenSource();
            var videoUploadTask = youtubeFacade
                                  .UploadVideo(
                SampleFiles.Helicopter_1min_48sec,
                "Test video",
                "Test description",
                cts.Token);

            cts.CancelAfter(TimeSpan.FromSeconds(3));
            try
            {
                videoUploadTask.Wait();
            }
            catch (AggregateException e)
            {
                Assert.IsTrue(e.InnerExceptions[0] is TaskCanceledException);
                Assert.Pass();
            }
            Assert.Fail("TaskCanceledException was expected.");
        }
Пример #2
0
        public void RetriesUploads_Test()
        {
            var youtubeFacade = new YoutubeFacade(
                ClientId,
                ClientSecret,
                "Sport Video Analyzer",
                SavedRefreshTokenToMyChannel.ConvertToSecureString());
            var videoUploadTask = youtubeFacade
                                  .UploadVideo(
                SampleFiles.Helicopter_1min_48sec,
                "Test video",
                "Test description",
                CancellationToken.None);

            videoUploadTask.Wait();
            var videoId = videoUploadTask.Result;

            Assert.IsNotNull(youtubeFacade.GetVideoInfo(videoId));

            var deleteResult = youtubeFacade.DeleteVideo(videoId);

            // ждем 5 сек пока ютуб расчехлится, что видео удалено.
            Thread.Sleep(5000);
            Assert.IsNull(youtubeFacade.GetVideoInfo(videoId));
        }
Пример #3
0
        public async void GetUserChannels_Test()
        {
            var youtube = new YoutubeFacade(ClientId,
                                            ClientSecret,
                                            "IA.Episodes",
                                            SavedRefreshTokenToMyChannel.ConvertToSecureString());
            var channels = await youtube.GetUserChannels();

            Assert.IsTrue(channels.Any(v => v.Title == "SportVideoAnalyzer"));
        }
Пример #4
0
        public async void GetPlaylists_Test()
        {
            var youtube = new YoutubeFacade(ClientId,
                                            ClientSecret,
                                            "IA.Episodes",
                                            SavedRefreshTokenToMyChannel.ConvertToSecureString());
            var channels = await youtube.GetUserChannels();

            var channelId = channels.First(v => v.Title == "SportVideoAnalyzer").Id;
            var playlists = await youtube.GetChannelPlaylists(channelId);

            Assert.IsTrue(playlists.Count > 5);
        }
Пример #5
0
        public async void UploadToPlaylist_Test()
        {
            var youtubeFacade = new YoutubeFacade(
                ClientId,
                ClientSecret,
                "Sport Video Analyzer",
                SavedRefreshTokenToMyChannel.ConvertToSecureString());
            var videoId = await youtubeFacade
                          .UploadVideo(
                SampleFiles.Helicopter_1min_48sec,
                "Test video",
                "Test description",
                CancellationToken.None);

            await youtubeFacade.AddToPlayList(videoId, "PLC66zCbeSJSxdwzMkVZMqx7zVpb4cUZz7");

            Assert.IsNotNull(youtubeFacade.GetVideoInfo(videoId));

            var deleteResult = youtubeFacade.DeleteVideo(videoId);

            // ждем 2 сек пока ютуб расчехлится, что видео удалено.
            Thread.Sleep(2000);
            Assert.IsNull(youtubeFacade.GetVideoInfo(videoId));
        }
Пример #6
0
 public void GetVideoInfo_Test()
 {
     var youtube = new YoutubeFacade(ClientId, ClientSecret, "IA.Episodes", SavedRefreshTokenToMyChannel.ConvertToSecureString());
     var info    = youtube.GetVideoInfo("KmSnmcuUZYs");
 }