internal async Task FullProcessPassed() { const OperatingSystem os = OperatingSystem.Linux64; var operatingSystemProvider = Substitute.For <IOperatingSystemProvider>(); operatingSystemProvider.GetOperatingSystem().Returns(x => os); OfficialFFmpegDownloader downloader = new OfficialFFmpegDownloader(operatingSystemProvider); var ffmpegExecutablesPath = FFmpeg.ExecutablesPath; try { FFmpeg.SetExecutablesPath(Path.Combine(Path.GetTempPath(), System.Guid.NewGuid().ToString("N"))); string ffmpegPath = downloader.ComputeFileDestinationPath("ffmpeg", os, FFmpeg.ExecutablesPath); string ffprobePath = downloader.ComputeFileDestinationPath("ffprobe", os, FFmpeg.ExecutablesPath); // 1- First download await downloader.GetLatestVersion(FFmpeg.ExecutablesPath); Assert.True(File.Exists(ffmpegPath)); Assert.True(File.Exists(ffprobePath)); // 2- Check updates (same version) await downloader.GetLatestVersion(FFmpeg.ExecutablesPath); Assert.True(File.Exists(ffmpegPath)); Assert.True(File.Exists(ffprobePath)); // 3- Check updates (outdated version) var fFbinariesVersionInfo = new FFbinariesVersionInfo { Version = new Version().ToString() // "0.0" }; downloader.SaveVersion(fFbinariesVersionInfo, FFmpeg.ExecutablesPath); await downloader.GetLatestVersion(FFmpeg.ExecutablesPath); Assert.True(File.Exists(ffmpegPath)); Assert.True(File.Exists(ffprobePath)); // 4- Missing ffmpeg File.Delete(ffmpegPath); await downloader.GetLatestVersion(FFmpeg.ExecutablesPath); Assert.True(File.Exists(ffmpegPath)); Assert.True(File.Exists(ffprobePath)); // 5- Missing ffprobe File.Delete(ffprobePath); await downloader.GetLatestVersion(FFmpeg.ExecutablesPath); Assert.True(File.Exists(ffmpegPath)); Assert.True(File.Exists(ffprobePath)); } finally { FFmpeg.SetExecutablesPath(ffmpegExecutablesPath); } }
internal async Task FullProcessPassedWithProgressAndRetries() { const OperatingSystem os = OperatingSystem.Linux64; var operatingSystemProvider = Substitute.For <IOperatingSystemProvider>(); operatingSystemProvider.GetOperatingSystem().Returns(x => os); OfficialFFmpegDownloader downloader = new OfficialFFmpegDownloader(operatingSystemProvider); var ffmpegExecutablesPath = FFmpeg.ExecutablesPath; try { FFmpeg.SetExecutablesPath(_storageFixture.GetTempDirectory()); string ffmpegPath = downloader.ComputeFileDestinationPath("ffmpeg", os, FFmpeg.ExecutablesPath); string ffprobePath = downloader.ComputeFileDestinationPath("ffprobe", os, FFmpeg.ExecutablesPath); IProgress <ProgressInfo> progress; // 1- First download progress = new Progress <ProgressInfo>(); await downloader.GetLatestVersion(FFmpeg.ExecutablesPath, progress, 3); Assert.True(File.Exists(ffmpegPath)); Assert.True(File.Exists(ffprobePath)); // 2- Check updates (same version) progress = new Progress <ProgressInfo>(); await downloader.GetLatestVersion(FFmpeg.ExecutablesPath, progress, 3); Assert.True(File.Exists(ffmpegPath)); Assert.True(File.Exists(ffprobePath)); // 3- Check updates (outdated version) var fFbinariesVersionInfo = new FFbinariesVersionInfo { Version = new Version().ToString() // "0.0" }; downloader.SaveVersion(fFbinariesVersionInfo, FFmpeg.ExecutablesPath); progress = new Progress <ProgressInfo>(); await downloader.GetLatestVersion(FFmpeg.ExecutablesPath, progress, 3); Assert.True(File.Exists(ffmpegPath)); Assert.True(File.Exists(ffprobePath)); // 4- Missing ffmpeg File.Delete(ffmpegPath); progress = new Progress <ProgressInfo>(); await downloader.GetLatestVersion(FFmpeg.ExecutablesPath, progress, 3); Assert.True(File.Exists(ffmpegPath)); Assert.True(File.Exists(ffprobePath)); // 5- Missing ffprobe File.Delete(ffprobePath); progress = new Progress <ProgressInfo>(); await downloader.GetLatestVersion(FFmpeg.ExecutablesPath, progress, 3); Assert.True(File.Exists(ffmpegPath)); Assert.True(File.Exists(ffprobePath)); } finally { FFmpeg.SetExecutablesPath(ffmpegExecutablesPath); } }