public void GetVideoID_CanGetVideoID(params string[] videoUrls) { //Act string[] videoIds = new string[videoUrls.Length]; for (int i = 0; i < videoUrls.Length; i++) { videoIds[i] = target.GetVideoID(videoUrls[i]); } //Assert Assert.Equal("Bey4XXJAqS8", videoIds[0]); Assert.Equal("HmZKgaHa3Fg", videoIds[1]); Assert.Equal("2MpUj-Aua48", videoIds[2]); Assert.Equal("LXb3EKWsInQ", videoIds[3]); }
public async Task <IActionResult> GetVideoMetaData(string videoUrl) { VideoDetails details; try { details = await clientHelper.GetVideoMetadataAsync(clientHelper.GetVideoID(videoUrl)); } catch (FormatException) { return(BadRequest("Provided URL is incorrect")); } return(Ok(details)); }
private async Task <VideoDetails> GetVideoDetails(string ytUrl) { if (!IsValidUrl(ytUrl)) { return(null); } try { return(await clientHelper.GetVideoMetadata(clientHelper.GetVideoID(ytUrl))); } catch (Exception ex) { // todo: handle error } return(null); }