public void I_can_specify_a_valid_channel_url_in_place_of_an_id(string channelUrl, string expectedChannelId) { // Act var result = new ChannelId(channelUrl); var maybeResult = ChannelId.TryParse(channelUrl); // Assert result.Value.Should().Be(expectedChannelId); maybeResult.Should().Be(result); }
public void I_can_specify_a_valid_channel_id(string channelId) { // Act var result = new ChannelId(channelId); var maybeResult = ChannelId.TryParse(channelId); // Assert result.Value.Should().Be(channelId); maybeResult.Should().Be(result); }
/// <summary> /// Asynchronously searches YouTube for the specified <paramref name="searchQuery"/>. /// </summary> /// <param name="searchQuery">The video, playlist, or channel to search for.</param> /// <returns>An <see cref="IReadOnlyList{T}"/> of <see cref="IVideo"/>'s matching the user's specified <paramref name="searchQuery"/>.</returns> public static async ValueTask <IReadOnlyList <IVideo> > SearchAsync(string searchQuery) { if (PlaylistId.TryParse(searchQuery).HasValue) { return(await Youtube.Client.Playlists.GetVideosAsync(PlaylistId.Parse(searchQuery)).CollectAsync(200)); } else if (ChannelId.TryParse(searchQuery).HasValue) { return(await Youtube.Client.Channels.GetUploadsAsync(ChannelId.Parse(searchQuery)).CollectAsync(200)); } return(await Youtube.Client.Search.GetVideosAsync(searchQuery).CollectAsync(200)); }
public void I_cannot_specify_an_invalid_channel_url_in_place_of_an_id(string channelUrl) { // Act & assert Assert.Throws <ArgumentException>(() => new ChannelId(channelUrl)); ChannelId.TryParse(channelUrl).Should().BeNull(); }