Пример #1
0
        public async Task YouTubeService_GetVideoById()
        {
            var            id      = "ci1PJexnfNE";
            YouTubeService service = CreateService();

            var request = service.Videos.List("id,snippet,statistics,contentDetails");

            request.Id = id;
            var result = await request.ExecuteAsync();

            var item = Assert.Single(result.Items);

            Assert.Equal(id, item.Id);
            Assert.StartsWith("Why is C such an influential language?", item.Snippet.Description);
            Assert.Equal("UC9-y-6csu5WGm29I7JiwpnA", item.Snippet.ChannelId);
            Assert.NotNull(item.Statistics);
            Assert.NotNull(item.ContentDetails);
            // Assert.Empty(item.Snippet.Tags);

            var video = YouTubeVideo.From(item);

            Assert.Equal(2, video.MentionedVideos.Count());
            Assert.Equal("9T8A89jgeTI", video.MentionedVideos.First());
            Assert.Equal("rh7kpkwXnwA", video.MentionedVideos.Skip(1).Single());
            Assert.Equal(TimeSpan.Parse("00:10:50"), video.Length);
        }