public void CanGetYoutubeMediaInformation() { string ExpectedVideoTitle = "sample-title"; string ExpectedVideoID = "hW9tIK5pcl8"; string ExpectedUploaderID = "sample-uploader"; string ExpectedDescription = "sample-description"; int ExpectedLikes = 51; int ExpectedDislikes = 12; int ExpectedViews = 314; double ExpectedDuration = 312.54; string ExpectedVideoUri = $"https://www.youtube.com/watch?v={ExpectedVideoID}"; string ExpectedIdentifiedArtist = "sample-artist"; string ExpectedIdentifiedSong = "sample-song"; string ExpectedUploadDate = "20181216"; MockForGetMediaInformationWithYoutubeTest processMock = new MockForGetMediaInformationWithYoutubeTest( ExpectedVideoTitle, ExpectedVideoID, ExpectedUploaderID, ExpectedDescription, ExpectedLikes, ExpectedDislikes, ExpectedViews, ExpectedDuration, ExpectedVideoUri, ExpectedIdentifiedArtist, ExpectedIdentifiedSong, ExpectedUploadDate ); YoutubeDl downloader = new YoutubeDl(processMock); IMediaInformation actual = downloader.GetMediaInformation(new Uri(ExpectedVideoUri)); Assert.IsTrue(processMock.ProcessStarted, "Youtube-dl was not started."); Assert.IsTrue(processMock.ParametersPassedCorrectly, "Command-line arguments were passed incorrectly to youtube-dl."); Assert.IsNotNull(actual); Assert.IsInstanceOfType(actual, typeof(ILikeableMedia)); Assert.IsInstanceOfType(actual, typeof(IIdentifiedSong)); Assert.AreEqual(ExpectedVideoUri, actual.MediaUri); Assert.AreEqual(ExpectedDuration, actual.Duration); Assert.AreEqual(ExpectedVideoTitle, actual.Title); Assert.AreEqual(ExpectedDescription, actual.Description); Assert.AreEqual(ExpectedVideoID, actual.VideoId); ILikeableMedia actual2 = (ILikeableMedia)actual; Assert.AreEqual(ExpectedLikes, actual2.Likes); Assert.AreEqual(ExpectedDislikes, actual2.Dislikes); IIdentifiedSong actual3 = (IIdentifiedSong)actual; Assert.AreEqual(ExpectedIdentifiedArtist, actual3.Artist); Assert.AreEqual(ExpectedIdentifiedSong, actual3.TrackTitle); }
public bool Write(string path, IIdentifiedSong songMetadata) { TagLib.File f = TagLib.File.Create(path); f.Tag.Title = songMetadata.TrackTitle; f.Tag.AlbumArtists = new string[] { songMetadata.Artist }; try { f.Save(); } catch (Exception) { return(false); } return(true); }