internal async Task DownloadLatestVersionTest(OperatingSystem os) { var operatingSystemProvider = Substitute.For <IOperatingSystemProvider>(); operatingSystemProvider.GetOperatingSystem().Returns(x => os); var linkProvider = new LinkProvider(operatingSystemProvider); var ffmpegExecutablesPath = FFmpeg.ExecutablesPath; try { FFbinariesVersionInfo currentVersion = JsonConvert.DeserializeObject <FFbinariesVersionInfo>(File.ReadAllText(Resources.FFbinariesInfo)); FFmpeg.ExecutablesPath = "assemblies"; if (Directory.Exists("assemblies")) { Directory.Delete("assemblies", true); } FFmpegDownloader downloader = new FFmpegDownloader(operatingSystemProvider); await downloader.DownloadLatestVersion(currentVersion).ConfigureAwait(false); Assert.True(File.Exists(downloader.ComputeFileDestinationPath("ffmpeg", os))); Assert.True(File.Exists(downloader.ComputeFileDestinationPath("ffprobe", os))); } finally { FFmpeg.ExecutablesPath = ffmpegExecutablesPath; } }
internal async Task FullProcessPassed() { const OperatingSystem os = OperatingSystem.Linux64; var operatingSystemProvider = Substitute.For <IOperatingSystemProvider>(); operatingSystemProvider.GetOperatingSystem().Returns(x => os); FFmpegDownloader._linkProvider = new LinkProvider(operatingSystemProvider); var ffmpegExecutablesPath = FFmpeg.ExecutablesPath; try { FFmpeg.ExecutablesPath = Path.Combine(Path.GetTempPath(), System.Guid.NewGuid().ToString("N")); string ffmpegPath = FFmpegDownloader.ComputeFileDestinationPath("ffmpeg", os); string ffprobePath = FFmpegDownloader.ComputeFileDestinationPath("ffprobe", os); // 1- First download await FFmpegDownloader.GetLatestVersion().ConfigureAwait(false); Assert.True(File.Exists(ffmpegPath)); Assert.True(File.Exists(ffprobePath)); // 2- Check updates (same version) await FFmpegDownloader.GetLatestVersion().ConfigureAwait(false); 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" }; FFmpegDownloader.SaveVersion(fFbinariesVersionInfo); await FFmpegDownloader.GetLatestVersion().ConfigureAwait(false); Assert.True(File.Exists(ffmpegPath)); Assert.True(File.Exists(ffprobePath)); // 4- Missing ffmpeg File.Delete(ffmpegPath); await FFmpegDownloader.GetLatestVersion().ConfigureAwait(false); Assert.True(File.Exists(ffmpegPath)); Assert.True(File.Exists(ffprobePath)); // 5- Missing ffprobe File.Delete(ffprobePath); await FFmpegDownloader.GetLatestVersion().ConfigureAwait(false); Assert.True(File.Exists(ffmpegPath)); Assert.True(File.Exists(ffprobePath)); } finally { FFmpeg.ExecutablesPath = ffmpegExecutablesPath; } }