public void ZipDestinationFailed() { var downloader = GetDefaultDownloader(); var testHash = "A7SDF6A86SDF9ASDF"; var song = new PlaylistSong(testHash, "Successful Song", "fff2", "Other"); var songPath = Path.Combine(TestSongsDir, "fff2 (Successful Song)"); downloader.HistoryManager.TryAdd(song, 0); var testDownloadResult = new DownloadResult(songPath, DownloadResultStatus.Success, 200); ZipExtractResult testZipResult = new ZipExtractResult() { CreatedOutputDirectory = true, Exception = null, OutputDirectory = songPath, ExtractedFiles = new string[] { "info.dat", "expert.dat", "song.egg" }, ResultStatus = ZipExtractResultStatus.DestinationFailed, SourceZip = "fff2.zip" }; var jobResult = new JobResult() { DownloadResult = testDownloadResult, ZipResult = testZipResult, SongHash = song.Hash, //Song = song, SongDirectory = null }; var testJob = new MockDownloadJob(testHash, jobResult, false); testJob.RunAsync().Wait(); var recentPlaylist = PlaylistManager.GetPlaylist(BuiltInPlaylist.BeatSyncRecent); recentPlaylist.TryAdd(song); var bSaberPlaylist = PlaylistManager.GetPlaylist(BuiltInPlaylist.BeastSaberCurator); bSaberPlaylist.TryAdd(song); // Verify setup Assert.IsTrue(recentPlaylist.Beatmaps.Any(s => song.Hash.Equals(s.Hash))); Assert.IsTrue(bSaberPlaylist.Beatmaps.Any(s => song.Hash.Equals(s.Hash))); Assert.IsTrue(downloader.HistoryManager.TryGetValue(song.Hash, out var entry)); Assert.AreEqual(HistoryFlag.None, entry.Flag); // Run tests downloader.ProcessJob(testJob); Assert.IsTrue(downloader.HistoryManager.TryGetValue(song.Hash, out entry)); Assert.AreEqual(HistoryFlag.Error, entry.Flag); Assert.IsTrue(recentPlaylist.Beatmaps.Any(s => song.Hash.Equals(s.Hash))); Assert.IsTrue(bSaberPlaylist.Beatmaps.Any(s => song.Hash.Equals(s.Hash))); }
public void BeatSaverNotFound() { //Assert.Fail("Need to fix after refactor"); var downloader = GetDefaultDownloader(); var testHash = "ASDFLKJACVOIAOSICJVLKXCVJ"; var song = new PlaylistSong(testHash, "Missing ExpectedDiff", "fff1", "Other"); downloader.HistoryManager.TryAdd(song, 0); var testDownloadResult = new DownloadResult(song.Hash, DownloadResultStatus.NetNotFound, 404); ZipExtractResult testZipResult = null; var jobResult = new JobResult() { DownloadResult = testDownloadResult, ZipResult = testZipResult, SongHash = song.Hash, //Song = song, SongDirectory = null }; var testJob = new MockDownloadJob(testHash, jobResult, false); testJob.RunAsync().Wait(); var recentPlaylist = PlaylistManager.GetPlaylist(BuiltInPlaylist.BeatSyncRecent); recentPlaylist.TryAdd(song); var bSaberPlaylist = PlaylistManager.GetPlaylist(BuiltInPlaylist.BeastSaberCurator); bSaberPlaylist.TryAdd(song); // Verify setup Assert.IsTrue(recentPlaylist.Beatmaps.Any(s => song.Hash.Equals(s.Hash))); Assert.IsTrue(bSaberPlaylist.Beatmaps.Any(s => song.Hash.Equals(s.Hash))); Assert.IsTrue(downloader.HistoryManager.TryGetValue(song.Hash, out var entry)); Assert.AreEqual(HistoryFlag.None, entry.Flag); // Run test downloader.ProcessJob(testJob); Assert.IsTrue(downloader.HistoryManager.TryGetValue(song.Hash, out entry)); Assert.AreEqual(HistoryFlag.BeatSaverNotFound, entry.Flag); Assert.IsFalse(recentPlaylist.Beatmaps.Any(s => song.Hash.Equals(s.Hash))); Assert.IsFalse(bSaberPlaylist.Beatmaps.Any(s => song.Hash.Equals(s.Hash))); }