public async Task TestPlayList() { var service = new YouTubeService(new SafeHttpClient(), new Configuration.YouTubeConfiguration { ApiKey = _apiKey }); var channelId = await service.GetChannelIdAsync(channelName); Assert.IsNotNull(channelId); var playlistId = await service.GetPlaylistIdAsync(channelId, playlistName); Assert.IsNotNull(playlistId); var progressCounter = 0; var progressIndicator = new Progress <int>(i => Interlocked.Increment(ref progressCounter)); var playlistItems = await service.GetPlaylistVideosAsync(playlistId, progressIndicator); Assert.IsNotNull(playlistItems); Assert.IsNotEmpty(playlistItems); Assert.Greater(progressCounter, 0); TestContext.WriteLine($"Playlist items: {playlistItems.Count}"); foreach (var item in playlistItems) { Assert.IsNotNull(item?.Id); } }
public async Task GetChannelIdAsyncNotFoundTest() { // Mock var httpMock = new Mock <ISafeHttpClient>(MockBehavior.Strict); var youTubeService = new YouTubeService(httpMock.Object, config); httpMock.Setup(x => x.GetAsync <YouTube.OnlyIdResponse>(It.Is <string>(s => checkApiCall(s, "channels", null)))) .ReturnsAsync(null as YouTube.OnlyIdResponse); // Run var channelId = await youTubeService.GetChannelIdAsync("TestChannelName"); // Assert Assert.IsNull(channelId); // Verify httpMock.VerifyAll(); }