Esempio n. 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.");
        }
Esempio n. 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));
        }
Esempio n. 3
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));
        }