Remove more usages of "Squirrel"

This commit is contained in:
Caelan Sayler
2023-12-31 11:23:38 +00:00
parent 1d20f014d6
commit 374996f481
30 changed files with 73 additions and 1338 deletions

View File

@@ -4,7 +4,7 @@ using Velopack.Packaging;
using Xunit.Abstractions;
using Xunit.Sdk;
[assembly: TestFramework("Squirrel.Packaging.Tests.TestsInit", "Squirrel.Packaging.Tests")]
[assembly: TestFramework("Velopack.Packaging.Tests.TestsInit", "Velopack.Packaging.Tests")]
namespace Velopack.Packaging.Tests
{

View File

@@ -1,527 +0,0 @@
//using System;
//using System.Collections.Generic;
//using System.Diagnostics;
//using System.IO;
//using System.Linq;
//using System.Reflection;
//using System.Text;
//using System.Threading;
//using System.Threading.Tasks;
//using NuGet.Versioning;
//using Squirrel.NuGet;
//using Squirrel.Tests.TestHelpers;
//using Xunit;
//using Xunit.Abstractions;
//namespace Squirrel.Tests
//{
// public class ApplyReleasesTests : TestLoggingBase
// {
// public ApplyReleasesTests(ITestOutputHelper log) : base(log)
// {
// }
// public const string APP_ID = "theFakeApp";
// [Fact]
// public async Task CleanInstallRunsSquirrelAwareAppsWithInstallFlag()
// {
// using var _1 = Utility.GetTempDirectory(out var tempDir);
// using var _2 = Utility.GetTempDirectory(out var remotePkgDir);
// IntegrationTestHelper.CreateNewVersionInPackageDir("0.1.0", remotePkgDir);
// using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir);
// await fixture.FullInstall();
// // NB: We execute the Squirrel-aware apps, so we need to give
// // them a minute to settle or else the using statement will
// // try to blow away a running process
// await Task.Delay(1000);
// Assert.False(File.Exists(Path.Combine(tempDir, APP_ID, "current", "args2.txt")));
// Assert.True(File.Exists(Path.Combine(tempDir, APP_ID, "current", "args.txt")));
// var text = File.ReadAllText(Path.Combine(tempDir, APP_ID, "current", "args.txt"), Encoding.UTF8);
// Assert.Contains("firstrun", text);
// }
// [Fact]
// public async Task UpgradeRunsSquirrelAwareAppsWithUpgradeFlag()
// {
// using var _1 = Utility.GetTempDirectory(out var tempDir);
// using var _2 = Utility.GetTempDirectory(out var remotePkgDir);
// IntegrationTestHelper.CreateNewVersionInPackageDir("0.1.0", remotePkgDir);
// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir)) {
// await fixture.FullInstall();
// }
// await Task.Delay(1000);
// IntegrationTestHelper.CreateNewVersionInPackageDir("0.2.0", remotePkgDir);
// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir)) {
// await fixture.UpdateApp();
// }
// await Task.Delay(1000);
// Assert.False(File.Exists(Path.Combine(tempDir, APP_ID, "staging", "app-0.2.0", "args2.txt")));
// Assert.True(File.Exists(Path.Combine(tempDir, APP_ID, "staging", "app-0.2.0", "args.txt")));
// var text = File.ReadAllText(Path.Combine(tempDir, APP_ID, "staging", "app-0.2.0", "args.txt"), Encoding.UTF8);
// Assert.Contains("updated", text);
// Assert.Contains("0.2.0", text);
// }
// [Fact]
// public async Task RunningUpgradeAppTwiceDoesntCrash()
// {
// using var _1 = Utility.GetTempDirectory(out var tempDir);
// using var _2 = Utility.GetTempDirectory(out var remotePkgDir);
// IntegrationTestHelper.CreateNewVersionInPackageDir("0.1.0", remotePkgDir);
// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir)) {
// await fixture.FullInstall();
// }
// await Task.Delay(1000);
// IntegrationTestHelper.CreateNewVersionInPackageDir("0.2.0", remotePkgDir);
// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir)) {
// await fixture.UpdateApp();
// }
// await Task.Delay(1000);
// // NB: The 2nd time we won't have any updates to apply. We should just do nothing!
// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir)) {
// await fixture.UpdateApp();
// }
// await Task.Delay(1000);
// }
// [Fact]
// public async Task FullUninstallRemovesAllVersions()
// {
// using var _1 = Utility.GetTempDirectory(out var tempDir);
// using var _2 = Utility.GetTempDirectory(out var remotePkgDir);
// IntegrationTestHelper.CreateNewVersionInPackageDir("0.1.0", remotePkgDir);
// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir)) {
// await fixture.FullInstall();
// }
// await Task.Delay(1000);
// IntegrationTestHelper.CreateNewVersionInPackageDir("0.2.0", remotePkgDir);
// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir)) {
// await fixture.UpdateApp();
// }
// await Task.Delay(1000);
// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir)) {
// await fixture.FullUninstall();
// }
// Assert.False(File.Exists(Path.Combine(tempDir, APP_ID, "app-0.1.0", "args.txt")));
// Assert.False(File.Exists(Path.Combine(tempDir, APP_ID, "app-0.2.0", "args.txt")));
// Assert.True(File.Exists(Path.Combine(tempDir, APP_ID, ".dead")));
// }
// [Fact]
// public async Task CanInstallAndUpdatePackageWithDotsInId()
// {
// string tempDir;
// string remotePkgDir;
// const string pkgName = "Squirrel.Installed.App";
// using (Utility.GetTempDirectory(out tempDir))
// using (Utility.GetTempDirectory(out remotePkgDir)) {
// // install 0.1.0
// IntegrationTestHelper.CreateFakeInstalledApp("0.1.0", remotePkgDir, "SquirrelInstalledAppWithDots.nuspec");
// var pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir);
// ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES"));
// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, pkgName, tempDir)) {
// await fixture.FullInstall();
// }
// //Assert.True(Directory.Exists(Path.Combine(tempDir, pkgName, "app-0.1.0")));
// Assert.True(Directory.Exists(Path.Combine(tempDir, pkgName, "current")));
// var info = new AppDescWindows(Path.Combine(tempDir, pkgName), pkgName);
// var version = info.GetVersions().Single();
// Assert.True(version.IsCurrent);
// Assert.Equal(new SemanticVersion(0, 1, 0), version.Manifest.Version);
// await Task.Delay(1000);
// Assert.True(File.ReadAllText(Path.Combine(version.DirectoryPath, "args.txt")).Contains("--squirrel-firstrun"));
// // update top 0.2.0
// IntegrationTestHelper.CreateFakeInstalledApp("0.2.0", remotePkgDir, "SquirrelInstalledAppWithDots.nuspec");
// pkgs = ReleaseEntry.BuildReleasesFile(remotePkgDir);
// ReleaseEntry.WriteReleaseFile(pkgs, Path.Combine(remotePkgDir, "RELEASES"));
// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, pkgName, tempDir)) {
// await fixture.UpdateApp();
// }
// info.UpdateAndRetrieveCurrentFolder(false);
// var versions = info.GetVersions().ToArray();
// Assert.Equal(2, versions.Count());
// Assert.Equal(new SemanticVersion(0, 2, 0), versions.Single(s => s.IsCurrent).Version);
// //Assert.True(Directory.Exists(Path.Combine(tempDir, pkgName, "app-0.2.0")));
// await Task.Delay(1000);
// // uninstall
// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, pkgName, tempDir)) {
// await fixture.FullUninstall();
// }
// Assert.False(File.Exists(Path.Combine(tempDir, pkgName, "app-0.1.0", "args.txt")));
// Assert.False(File.Exists(Path.Combine(tempDir, pkgName, "app-0.2.0", "args.txt")));
// Assert.True(File.Exists(Path.Combine(tempDir, pkgName, ".dead")));
// }
// }
// [Fact]
// public void WhenNoNewReleasesAreAvailableTheListIsEmpty()
// {
// using var _ = Utility.GetTempDirectory(out var tempDir);
// var appDir = Directory.CreateDirectory(Path.Combine(tempDir, APP_ID));
// var packages = Path.Combine(appDir.FullName, "packages");
// Directory.CreateDirectory(packages);
// var package = "Squirrel.Core.1.0.0.0-full.nupkg";
// File.Copy(IntegrationTestHelper.GetPath("fixtures", package), Path.Combine(packages, package));
// var aGivenPackage = Path.Combine(packages, package);
// var baseEntry = ReleaseEntry.GenerateFromFile(aGivenPackage);
// var updateInfo = UpdateInfo.Create(baseEntry, new[] { baseEntry }, "dontcare");
// Assert.Empty(updateInfo.ReleasesToApply);
// }
// [Fact]
// public void ThrowsWhenOnlyDeltaReleasesAreAvailable()
// {
// string tempDir;
// using (Utility.GetTempDirectory(out tempDir)) {
// var appDir = Directory.CreateDirectory(Path.Combine(tempDir, APP_ID));
// var packages = Path.Combine(appDir.FullName, "packages");
// Directory.CreateDirectory(packages);
// var baseFile = "Squirrel.Core.1.0.0.0-full.nupkg";
// File.Copy(IntegrationTestHelper.GetPath("fixtures", baseFile),
// Path.Combine(packages, baseFile));
// var basePackage = Path.Combine(packages, baseFile);
// var baseEntry = ReleaseEntry.GenerateFromFile(basePackage);
// var deltaFile = "Squirrel.Core.1.1.0.0-delta.nupkg";
// File.Copy(IntegrationTestHelper.GetPath("fixtures", deltaFile),
// Path.Combine(packages, deltaFile));
// var deltaPackage = Path.Combine(packages, deltaFile);
// var deltaEntry = ReleaseEntry.GenerateFromFile(deltaPackage);
// Assert.Throws<Exception>(
// () => UpdateInfo.Create(baseEntry, new[] { deltaEntry }, "dontcare"));
// }
// }
// [Fact]
// public async Task ApplyReleasesWithOneReleaseFile()
// {
// string tempDir;
// using (Utility.GetTempDirectory(out tempDir)) {
// string appDir = Path.Combine(tempDir, APP_ID);
// string packagesDir = Path.Combine(appDir, "packages");
// Directory.CreateDirectory(packagesDir);
// new[] {
// "Squirrel.Core.1.0.0.0-full.nupkg",
// "Squirrel.Core.1.1.0.0-full.nupkg",
// }.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(packagesDir, x)));
// using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir("", APP_ID, tempDir);
// var baseEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.0.0.0-full.nupkg"));
// var latestFullEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.1.0.0-full.nupkg"));
// var updateInfo = UpdateInfo.Create(baseEntry, new[] { latestFullEntry }, packagesDir);
// updateInfo.ReleasesToApply.Contains(latestFullEntry).ShouldBeTrue();
// var progress = new List<int>();
// await fixture.ApplyReleasesPublic(updateInfo, false, false, progress.Add);
// this.Log().Info("Progress: [{0}]", String.Join(",", progress));
// progress
// .Aggregate(0, (acc, x) => {
// (x >= acc).ShouldBeTrue();
// return x;
// })
// .ShouldEqual(100);
// var filesToFind = new[] {
// new { Name = "NLog.dll", Version = new Version("2.0.0.0") },
// new { Name = "NSync.Core.dll", Version = new Version("1.1.0.0") },
// };
// filesToFind.ForEach(x => {
// var path = Path.Combine(tempDir, APP_ID, "staging", "app-1.1.0.0", x.Name);
// this.Log().Info("Looking for {0}", path);
// File.Exists(path).ShouldBeTrue();
// var vi = FileVersionInfo.GetVersionInfo(path);
// var verInfo = new Version(vi.FileVersion ?? "1.0.0.0");
// x.Version.ShouldEqual(verInfo);
// });
// }
// }
// [Fact]
// public async Task ApplyReleaseWhichRemovesAFile()
// {
// string tempDir;
// using (Utility.GetTempDirectory(out tempDir)) {
// string appDir = Path.Combine(tempDir, APP_ID);
// string packagesDir = Path.Combine(appDir, "packages");
// Directory.CreateDirectory(packagesDir);
// new[] {
// "Squirrel.Core.1.1.0.0-full.nupkg",
// "Squirrel.Core.1.2.0.0-full.nupkg",
// }.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(packagesDir, x)));
// using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir("", APP_ID, tempDir);
// var baseEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.1.0.0-full.nupkg"));
// var latestFullEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.2.0.0-full.nupkg"));
// var updateInfo = UpdateInfo.Create(baseEntry, new[] { latestFullEntry }, packagesDir);
// updateInfo.ReleasesToApply.Contains(latestFullEntry).ShouldBeTrue();
// var progress = new List<int>();
// await fixture.ApplyReleasesPublic(updateInfo, false, false, progress.Add);
// this.Log().Info("Progress: [{0}]", String.Join(",", progress));
// progress
// .Aggregate(0, (acc, x) => {
// (x >= acc).ShouldBeTrue();
// return x;
// })
// .ShouldEqual(100);
// var rootDirectory = Path.Combine(tempDir, APP_ID, "staging", "app-1.2.0.0");
// new[] {
// new { Name = "NLog.dll", Version = new Version("2.0.0.0") },
// new { Name = "NSync.Core.dll", Version = new Version("1.1.0.0") },
// }.ForEach(x => {
// var path = Path.Combine(rootDirectory, x.Name);
// this.Log().Info("Looking for {0}", path);
// File.Exists(path).ShouldBeTrue();
// });
// var removedFile = Path.Combine("sub", "Ionic.Zip.dll");
// var deployedPath = Path.Combine(rootDirectory, removedFile);
// File.Exists(deployedPath).ShouldBeFalse();
// }
// }
// [Fact]
// public async Task ApplyReleaseWhichMovesAFileToADifferentDirectory()
// {
// string tempDir;
// using (Utility.GetTempDirectory(out tempDir)) {
// string appDir = Path.Combine(tempDir, APP_ID);
// string packagesDir = Path.Combine(appDir, "packages");
// Directory.CreateDirectory(packagesDir);
// new[] {
// "Squirrel.Core.1.1.0.0-full.nupkg",
// "Squirrel.Core.1.3.0.0-full.nupkg",
// }.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(packagesDir, x)));
// using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir("", APP_ID, tempDir);
// var baseEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.1.0.0-full.nupkg"));
// var latestFullEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.3.0.0-full.nupkg"));
// var updateInfo = UpdateInfo.Create(baseEntry, new[] { latestFullEntry }, packagesDir);
// updateInfo.ReleasesToApply.Contains(latestFullEntry).ShouldBeTrue();
// var progress = new List<int>();
// await fixture.ApplyReleasesPublic(updateInfo, false, false, progress.Add);
// this.Log().Info("Progress: [{0}]", String.Join(",", progress));
// progress
// .Aggregate(0, (acc, x) => {
// (x >= acc).ShouldBeTrue();
// return x;
// })
// .ShouldEqual(100);
// var rootDirectory = Path.Combine(tempDir, APP_ID, "staging", "app-1.3.0.0");
// new[] {
// new { Name = "NLog.dll", Version = new Version("2.0.0.0") },
// new { Name = "NSync.Core.dll", Version = new Version("1.1.0.0") },
// }.ForEach(x => {
// var path = Path.Combine(rootDirectory, x.Name);
// this.Log().Info("Looking for {0}", path);
// File.Exists(path).ShouldBeTrue();
// });
// var oldFile = Path.Combine(rootDirectory, "sub", "Ionic.Zip.dll");
// File.Exists(oldFile).ShouldBeFalse();
// var newFile = Path.Combine(rootDirectory, "other", "Ionic.Zip.dll");
// File.Exists(newFile).ShouldBeTrue();
// }
// }
// [Fact]
// public async Task ApplyReleasesWithDeltaReleases()
// {
// string tempDir;
// using (Utility.GetTempDirectory(out tempDir)) {
// string appDir = Path.Combine(tempDir, APP_ID);
// string packagesDir = Path.Combine(appDir, "packages");
// Directory.CreateDirectory(packagesDir);
// new[] {
// "Squirrel.Core.1.0.0.0-full.nupkg",
// "Squirrel.Core.1.1.0.0-delta.nupkg",
// "Squirrel.Core.1.1.0.0-full.nupkg",
// }.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(packagesDir, x)));
// using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir("", APP_ID, tempDir);
// var baseEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.0.0.0-full.nupkg"));
// var deltaEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.1.0.0-delta.nupkg"));
// var latestFullEntry = ReleaseEntry.GenerateFromFile(Path.Combine(packagesDir, "Squirrel.Core.1.1.0.0-full.nupkg"));
// var updateInfo = UpdateInfo.Create(baseEntry, new[] { deltaEntry, latestFullEntry }, packagesDir);
// updateInfo.ReleasesToApply.Contains(deltaEntry).ShouldBeTrue();
// var progress = new List<int>();
// await fixture.ApplyReleasesPublic(updateInfo, false, false, progress.Add);
// this.Log().Info("Progress: [{0}]", String.Join(",", progress));
// // TODO: this is failing intermittently, not sure why but is not a big deal atm
// // progress
// // .Aggregate(0, (acc, x) => { (x >= acc).ShouldBeTrue(); return x; })
// // .ShouldEqual(100);
// var filesToFind = new[] {
// new { Name = "NLog.dll", Version = new Version("2.0.0.0") },
// new { Name = "NSync.Core.dll", Version = new Version("1.1.0.0") },
// };
// filesToFind.ForEach(x => {
// var path = Path.Combine(tempDir, APP_ID, "staging", "app-1.1.0.0", x.Name);
// this.Log().Info("Looking for {0}", path);
// File.Exists(path).ShouldBeTrue();
// var vi = FileVersionInfo.GetVersionInfo(path);
// var verInfo = new Version(vi.FileVersion ?? "1.0.0.0");
// x.Version.ShouldEqual(verInfo);
// });
// }
// }
// [Fact]
// public async Task CreateFullPackagesFromDeltaSmokeTest()
// {
// string tempDir;
// using (Utility.GetTempDirectory(out tempDir)) {
// string appDir = Path.Combine(tempDir, APP_ID);
// string packagesDir = Path.Combine(appDir, "packages");
// Directory.CreateDirectory(packagesDir);
// new[] {
// "Squirrel.Core.1.0.0.0-full.nupkg",
// "Squirrel.Core.1.1.0.0-delta.nupkg"
// }.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(tempDir, APP_ID, "packages", x)));
// using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir("", APP_ID, tempDir);
// var baseEntry = ReleaseEntry.GenerateFromFile(Path.Combine(tempDir, APP_ID, "packages", "Squirrel.Core.1.0.0.0-full.nupkg"));
// var deltaEntry = ReleaseEntry.GenerateFromFile(Path.Combine(tempDir, APP_ID, "packages", "Squirrel.Core.1.1.0.0-delta.nupkg"));
// var result = fixture.createFullPackagesFromDeltas(new[] { deltaEntry }, baseEntry, null);
// var zp = new ZipPackage(Path.Combine(tempDir, APP_ID, "packages", result.Filename));
// zp.Version.ToString().ShouldEqual("1.1.0.0");
// }
// }
// [Fact]
// public async Task CreateShortcutsRoundTrip()
// {
// using var _1 = Utility.GetTempDirectory(out var tempDir);
// using var _2 = Utility.GetTempDirectory(out var remotePkgDir);
// IntegrationTestHelper.CreateNewVersionInPackageDir("0.1.0", remotePkgDir);
// using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, tempDir);
// await fixture.FullInstall();
// fixture.CreateShortcutsForExecutable("SquirrelAwareApp.exe",
// ShortcutLocation.Desktop | ShortcutLocation.StartMenu | ShortcutLocation.Startup | ShortcutLocation.AppRoot, false, null, null);
// Assert.True(File.Exists(Path.Combine(tempDir, APP_ID, "PublishSingleFileAwareApp.lnk")));
// // NB: COM is Weird.
// Thread.Sleep(1000);
// fixture.RemoveShortcutsForExecutable("SquirrelAwareApp.exe",
// ShortcutLocation.Desktop | ShortcutLocation.StartMenu | ShortcutLocation.Startup | ShortcutLocation.AppRoot);
// // NB: Squirrel-Aware first-run might still be running, slow
// // our roll before blowing away the temp path
// Thread.Sleep(1000);
// }
// //[Fact]
// //public async Task GetShortcutsSmokeTest()
// //{
// // string remotePkgPath;
// // string path;
// // using (Utility.WithTempDirectory(out path)) {
// // using (Utility.WithTempDirectory(out remotePkgPath))
// // using (var mgr = new UpdateManager(remotePkgPath, APP_ID, path)) {
// // IntegrationTestHelper.CreateFakeInstalledApp("1.0.0.1", remotePkgPath);
// // await mgr.FullInstall();
// // }
// // var fixture = new ApplyReleasesImpl(Path.Combine(path, APP_ID));
// // var result = fixture.GetShortcutsForExecutable("SquirrelAwareApp.exe", ShortcutLocation.Desktop | ShortcutLocation.StartMenu | ShortcutLocation.Startup, null);
// // Assert.Equal(3, result.Keys.Count);
// // // NB: Squirrel-Aware first-run might still be running, slow
// // // our roll before blowing away the temp path
// // Thread.Sleep(1000);
// // }
// //}
// }
//}

View File

@@ -1,178 +0,0 @@
//using System;
//using System.IO;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//using System.Web;
//using Squirrel.Tests.TestHelpers;
//using Xunit;
//namespace Squirrel.Tests
//{
// public class CheckForUpdateTests
// {
// [Fact(Skip = "Rewrite this to be an integration test")]
// public void NewReleasesShouldBeDetected()
// {
// Assert.Fail("Rewrite this to be an integration test");
// /*
// string localReleasesFile = Path.Combine(".", "theApp", "packages", "RELEASES");
// var fileInfo = new Mock<FileInfoBase>();
// fileInfo.Setup(x => x.OpenRead())
// .Returns(File.OpenRead(IntegrationTestHelper.GetPath("fixtures", "RELEASES-OnePointOh")));
// var fs = new Mock<IFileSystemFactory>();
// fs.Setup(x => x.GetFileInfo(localReleasesFile)).Returns(fileInfo.Object);
// var urlDownloader = new Mock<IUrlDownloader>();
// var dlPath = IntegrationTestHelper.GetPath("fixtures", "RELEASES-OnePointOne");
// urlDownloader.Setup(x => x.DownloadUrl(It.IsAny<string>(), It.IsAny<IObserver<int>>()))
// .Returns(Observable.Return(File.ReadAllText(dlPath, Encoding.UTF8)));
// var fixture = new UpdateManager("http://lol", "theApp", ".", fs.Object, urlDownloader.Object);
// var result = default(UpdateInfo);
// using (fixture) {
// result = fixture.CheckForUpdate().First();
// }
// Assert.NotNull(result);
// Assert.Equal(1, result.ReleasesToApply.Single().Version.Major);
// Assert.Equal(1, result.ReleasesToApply.Single().Version.Minor);
// */
// }
// [Fact(Skip = "Rewrite this to be an integration test")]
// public void CorruptedReleaseFileMeansWeStartFromScratch()
// {
// Assert.Fail("Rewrite this to be an integration test");
// /*
// string localPackagesDir = Path.Combine(".", "theApp", "packages");
// string localReleasesFile = Path.Combine(localPackagesDir, "RELEASES");
// var fileInfo = new Mock<FileInfoBase>();
// fileInfo.Setup(x => x.Exists).Returns(true);
// fileInfo.Setup(x => x.OpenRead())
// .Returns(new MemoryStream(Encoding.UTF8.GetBytes("lol this isn't right")));
// var dirInfo = new Mock<DirectoryInfoBase>();
// dirInfo.Setup(x => x.Exists).Returns(true);
// var fs = new Mock<IFileSystemFactory>();
// fs.Setup(x => x.GetFileInfo(localReleasesFile)).Returns(fileInfo.Object);
// fs.Setup(x => x.CreateDirectoryRecursive(localPackagesDir)).Verifiable();
// fs.Setup(x => x.DeleteDirectoryRecursive(localPackagesDir)).Verifiable();
// fs.Setup(x => x.GetDirectoryInfo(localPackagesDir)).Returns(dirInfo.Object);
// var urlDownloader = new Mock<IUrlDownloader>();
// var dlPath = IntegrationTestHelper.GetPath("fixtures", "RELEASES-OnePointOne");
// urlDownloader.Setup(x => x.DownloadUrl(It.IsAny<string>(), It.IsAny<IObserver<int>>()))
// .Returns(Observable.Return(File.ReadAllText(dlPath, Encoding.UTF8)));
// var fixture = new UpdateManager("http://lol", "theApp", ".", fs.Object, urlDownloader.Object);
// using (fixture) {
// fixture.CheckForUpdate().First();
// }
// fs.Verify(x => x.CreateDirectoryRecursive(localPackagesDir), Times.Once());
// fs.Verify(x => x.DeleteDirectoryRecursive(localPackagesDir), Times.Once());
// */
// }
// [Fact(Skip = "Rewrite this to be an integration test")]
// public void CorruptRemoteFileShouldThrowOnCheck()
// {
// Assert.Fail("Rewrite this to be an integration test");
// /*
// string localPackagesDir = Path.Combine(".", "theApp", "packages");
// string localReleasesFile = Path.Combine(localPackagesDir, "RELEASES");
// var fileInfo = new Mock<FileInfoBase>();
// fileInfo.Setup(x => x.Exists).Returns(false);
// var dirInfo = new Mock<DirectoryInfoBase>();
// dirInfo.Setup(x => x.Exists).Returns(true);
// var fs = new Mock<IFileSystemFactory>();
// fs.Setup(x => x.GetFileInfo(localReleasesFile)).Returns(fileInfo.Object);
// fs.Setup(x => x.CreateDirectoryRecursive(localPackagesDir)).Verifiable();
// fs.Setup(x => x.DeleteDirectoryRecursive(localPackagesDir)).Verifiable();
// fs.Setup(x => x.GetDirectoryInfo(localPackagesDir)).Returns(dirInfo.Object);
// var urlDownloader = new Mock<IUrlDownloader>();
// urlDownloader.Setup(x => x.DownloadUrl(It.IsAny<string>(), It.IsAny<IObserver<int>>()))
// .Returns(Observable.Return("lol this isn't right"));
// var fixture = new UpdateManager("http://lol", "theApp", ".", fs.Object, urlDownloader.Object);
// using (fixture) {
// Assert.Throws<Exception>(() => fixture.CheckForUpdate().First());
// }
// */
// }
// [Fact(Skip = "TODO")]
// public void IfLocalVersionGreaterThanRemoteWeRollback()
// {
// throw new NotImplementedException();
// }
// [Fact(Skip = "TODO")]
// public void IfLocalAndRemoteAreEqualThenDoNothing()
// {
// throw new NotImplementedException();
// }
// [Theory]
// [InlineData(@"94689fede03fed7ab59c24337673a27837f0c3ec MyCoolApp-1.0.nupkg 1004502", "MyCoolApp", null)]
// [InlineData(@"0000000000000000000000000000000000000000 https://www.test.org/Folder/MyCoolApp-1.2-delta.nupkg?query=param 1231953", "MyCoolApp", "https://www.test.org/Folder")]
// public async Task WebSourceRequestsExpectedUrls(string releaseEntry, string releaseName, string baseUrl)
// {
// baseUrl = baseUrl ?? "https://example.com/files";
// var dl = new FakeDownloader();
// var source = new Sources.SimpleWebSource("https://example.com/files", dl);
// dl.MockedResponseBytes = Encoding.UTF8.GetBytes(releaseEntry);
// var releases = await source.GetReleaseFeed(null, null);
// Assert.True(releases.Count() == 1);
// Assert.Equal(releaseName, releases[0].PackageName);
// Assert.Equal("https://example.com/files/RELEASES", new Uri(dl.LastUrl).GetLeftPart(UriPartial.Path));
// await source.DownloadReleaseEntry(releases[0], "test", null);
// Assert.Equal(baseUrl + "/" + releases[0].Filename, new Uri(dl.LastUrl).GetLeftPart(UriPartial.Path));
// }
// [Theory]
// [InlineData("http://example.com", "MyPackage.nupkg", "http://example.com/MyPackage.nupkg")]
// [InlineData("http://example.com?auth=hello", "MyPackage.nupkg", "http://example.com/MyPackage.nupkg?auth=hello")]
// [InlineData("http://example.com?auth=hello", "https://my.packages.domain/MyPackage-1.0.0.nupkg", "https://my.packages.domain/MyPackage-1.0.0.nupkg")]
// public async Task SimpleWebSourcePreservesQueryParametersAndAbsoluteReleaseUri(string baseUri, string releaseUri, string expectedPackageUrl)
// {
// var dl = new FakeDownloader();
// var source = new Sources.SimpleWebSource(baseUri, dl);
// var baseKvp = HttpUtility.ParseQueryString(new Uri(baseUri).Query);
// var baseDict = baseKvp.AllKeys.Where(k => k != null).ToDictionary(k => k, k => baseKvp[k]);
// var releaseEntry = $"94689fede03fed7ab59c24337673a27837f0c3ec {releaseUri} 1004502";
// dl.MockedResponseBytes = Encoding.UTF8.GetBytes(releaseEntry);
// var releases = await source.GetReleaseFeed();
// var expected = new Uri(baseUri).GetLeftPart(UriPartial.Path).TrimEnd('/') + "/RELEASES";
// Assert.StartsWith(expected, dl.LastUrl);
// // check that each query parameter in base url is in the releases string
// var releasesUri = new Uri(dl.LastUrl);
// var releasesKvp = HttpUtility.ParseQueryString(releasesUri.Query);
// var releasesDict = releasesKvp.AllKeys.Where(k => k != null).ToDictionary(k => k, k => releasesKvp[k]);
// foreach (var kvp in baseDict) {
// Assert.Equal(releasesDict[kvp.Key], kvp.Value);
// }
// await source.DownloadReleaseEntry(releases[0], "test", null);
// Assert.Equal(expectedPackageUrl, dl.LastUrl);
// }
// }
//}

View File

@@ -1,194 +0,0 @@
//using System;
//using System.Collections.Generic;
//using System.IO;
//using System.Linq;
//using System.Net;
//using System.Text;
//using System.Threading.Tasks;
//using Squirrel.SimpleSplat;
//using Squirrel.Tests.TestHelpers;
//using Xunit;
//namespace Squirrel.Tests
//{
// public class DownloadReleasesTests
// {
// [Fact(Skip = "Rewrite this to be an integration test")]
// public void ChecksumShouldFailIfFilesAreMissing()
// {
// Assert.Fail("Rewrite this to be an integration test");
// /*
// var filename = "Squirrel.Core.1.0.0.0.nupkg";
// var nuGetPkg = IntegrationTestHelper.GetPath("fixtures", filename);
// var fs = new Mock<IFileSystemFactory>();
// var urlDownloader = new Mock<IUrlDownloader>();
// ReleaseEntry entry;
// using (var f = File.OpenRead(nuGetPkg)) {
// entry = ReleaseEntry.GenerateFromFile(f, filename);
// }
// var fileInfo = new Mock<FileInfoBase>();
// fileInfo.Setup(x => x.OpenRead()).Returns(File.OpenRead(nuGetPkg));
// fileInfo.Setup(x => x.Exists).Returns(false);
// fs.Setup(x => x.GetFileInfo(Path.Combine(".", "theApp", "packages", filename))).Returns(fileInfo.Object);
// var fixture = ExposedObject.From(
// new UpdateManager("http://lol", "theApp", ".", fs.Object, urlDownloader.Object));
// bool shouldDie = true;
// try {
// // NB: We can't use Assert.Throws here because the binder
// // will try to pick the wrong method
// fixture.checksumPackage(entry);
// } catch (Exception) {
// shouldDie = false;
// }
// shouldDie.ShouldBeFalse();
// */
// }
// [Fact(Skip = "Rewrite this to be an integration test")]
// public void ChecksumShouldFailIfFilesAreBogus()
// {
// Assert.Fail("Rewrite this to be an integration test");
// /*
// var filename = "Squirrel.Core.1.0.0.0.nupkg";
// var nuGetPkg = IntegrationTestHelper.GetPath("fixtures", filename);
// var fs = new Mock<IFileSystemFactory>();
// var urlDownloader = new Mock<IUrlDownloader>();
// ReleaseEntry entry;
// using (var f = File.OpenRead(nuGetPkg)) {
// entry = ReleaseEntry.GenerateFromFile(f, filename);
// }
// var fileInfo = new Mock<FileInfoBase>();
// fileInfo.Setup(x => x.OpenRead()).Returns(new MemoryStream(Encoding.UTF8.GetBytes("Lol broken")));
// fileInfo.Setup(x => x.Exists).Returns(true);
// fileInfo.Setup(x => x.Length).Returns(new FileInfo(nuGetPkg).Length);
// fileInfo.Setup(x => x.Delete()).Verifiable();
// fs.Setup(x => x.GetFileInfo(Path.Combine(".", "theApp", "packages", filename))).Returns(fileInfo.Object);
// var fixture = ExposedObject.From(
// new UpdateManager("http://lol", "theApp", ".", fs.Object, urlDownloader.Object));
// bool shouldDie = true;
// try {
// fixture.checksumPackage(entry);
// } catch (Exception ex) {
// this.Log().InfoException("Checksum failure", ex);
// shouldDie = false;
// }
// shouldDie.ShouldBeFalse();
// fileInfo.Verify(x => x.Delete(), Times.Once());
// */
// }
// [Fact(Skip = "Rewrite this to be an integration test")]
// public async Task DownloadReleasesFromHttpServerIntegrationTest()
// {
// Assert.Fail("Rewrite this to not use the SampleUpdatingApp");
// /*
// string tempDir = null;
// var updateDir = new DirectoryInfo(IntegrationTestHelper.GetPath("..", "SampleUpdatingApp", "SampleReleasesFolder"));
// IDisposable disp;
// try {
// var httpServer = new StaticHttpServer(30405, updateDir.FullName);
// disp = httpServer.Start();
// } catch (HttpListenerException) {
// Assert.False(true, @"Windows sucks, go run 'netsh http add urlacl url=http://+:30405/ user=MYMACHINE\MyUser");
// return;
// }
// var entriesToDownload = updateDir.GetFiles("*.nupkg")
// .Select(x => ReleaseEntry.GenerateFromFile(x.FullName))
// .ToArray();
// entriesToDownload.Count().ShouldBeGreaterThan(0);
// using (disp)
// using (Utility.WithTempDirectory(out tempDir)) {
// // NB: This is normally done by CheckForUpdates, but since
// // we're skipping that in the test we have to do it ourselves
// Directory.CreateDirectory(Path.Combine(tempDir, "SampleUpdatingApp", "packages"));
// var fixture = new UpdateManager("http://localhost:30405", "SampleUpdatingApp", tempDir);
// using (fixture) {
// var progress = new List<int>();
// await fixture.DownloadReleases(entriesToDownload, progress.Add);
// progress
// .Aggregate(0, (acc, x) => { x.ShouldBeGreaterThan(acc); return x; })
// .ShouldEqual(100);
// }
// entriesToDownload.ForEach(x => {
// this.Log().Info("Looking for {0}", x.Filename);
// var actualFile = Path.Combine(tempDir, "SampleUpdatingApp", "packages", x.Filename);
// File.Exists(actualFile).ShouldBeTrue();
// var actualEntry = ReleaseEntry.GenerateFromFile(actualFile);
// actualEntry.SHA1.ShouldEqual(x.SHA1);
// actualEntry.Version.ShouldEqual(x.Version);
// });
// }
// */
// }
// [Fact(Skip = "Rewrite this to be an integration test")]
// public async Task DownloadReleasesFromFileDirectoryIntegrationTest()
// {
// Assert.Fail("Rewrite this to not use the SampleUpdatingApp");
// /*
// string tempDir = null;
// var updateDir = new DirectoryInfo(IntegrationTestHelper.GetPath("..", "SampleUpdatingApp", "SampleReleasesFolder"));
// var entriesToDownload = updateDir.GetFiles("*.nupkg")
// .Select(x => ReleaseEntry.GenerateFromFile(x.FullName))
// .ToArray();
// entriesToDownload.Count().ShouldBeGreaterThan(0);
// using (Utility.WithTempDirectory(out tempDir)) {
// // NB: This is normally done by CheckForUpdates, but since
// // we're skipping that in the test we have to do it ourselves
// Directory.CreateDirectory(Path.Combine(tempDir, "SampleUpdatingApp", "packages"));
// var fixture = new UpdateManager(updateDir.FullName, "SampleUpdatingApp", tempDir);
// using (fixture) {
// var progress = new List<int>();
// await fixture.DownloadReleases(entriesToDownload, progress.Add);
// this.Log().Info("Progress: [{0}]", String.Join(",", progress));
// progress
// .Aggregate(0, (acc, x) => { x.ShouldBeGreaterThan(acc); return x; })
// .ShouldEqual(100);
// }
// entriesToDownload.ForEach(x => {
// this.Log().Info("Looking for {0}", x.Filename);
// var actualFile = Path.Combine(tempDir, "SampleUpdatingApp", "packages", x.Filename);
// File.Exists(actualFile).ShouldBeTrue();
// var actualEntry = ReleaseEntry.GenerateFromFile(actualFile);
// actualEntry.SHA1.ShouldEqual(x.SHA1);
// actualEntry.Version.ShouldEqual(x.Version);
// });
// }
// */
// }
// }
//}

View File

@@ -1,367 +0,0 @@
//using System;
//using System.Collections.Generic;
//using System.IO;
//using System.Linq;
//using System.Text;
//using System.Threading;
//using System.Threading.Tasks;
//using Microsoft.Win32;
//using Squirrel;
//using Squirrel.Tests.TestHelpers;
//using Xunit;
//using System.Net;
//using Squirrel.NuGet;
//using System.Net.Http;
//using NuGet.Versioning;
//using Squirrel.Sources;
//namespace Squirrel.Tests
//{
// public class UpdateManagerTests
// {
// public const string APP_ID = "theFakeApp";
// public class CreateUninstallerRegKeyTests
// {
// [Fact]
// public async Task CallingMethodTwiceShouldUpdateInstaller()
// {
// using var _1 = Utility.GetTempDirectory(out var path);
// using var _2 = Utility.GetTempDirectory(out var remotePkgDir);
// IntegrationTestHelper.CreateNewVersionInPackageDir("0.1.0", remotePkgDir);
// using (var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, path))
// await fixture.FullInstall();
// using (var mgr = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePkgDir, APP_ID, path)) {
// await mgr.CreateUninstallerRegistryEntry();
// var regKey = await mgr.CreateUninstallerRegistryEntry();
// Assert.False(String.IsNullOrWhiteSpace((string) regKey.GetValue("DisplayName")));
// mgr.RemoveUninstallerRegistryEntry();
// }
// // NB: Squirrel-Aware first-run might still be running, slow
// // our roll before blowing away the temp path
// Thread.Sleep(1000);
// var key = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default)
// .OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall");
// using (key) {
// Assert.False(key.GetSubKeyNames().Contains(APP_ID));
// }
// }
// public class UpdateLocalReleasesTests
// {
// [Fact]
// public async Task UpdateLocalReleasesSmokeTest()
// {
// using var _1 = Utility.GetTempDirectory(out var tempDir);
// var appDir = Path.Combine(tempDir, APP_ID);
// var packageDir = Directory.CreateDirectory(Path.Combine(appDir, "packages"));
// new[] {
// "Squirrel.Core.1.0.0.0-full.nupkg",
// "Squirrel.Core.1.1.0.0-delta.nupkg",
// "Squirrel.Core.1.1.0.0-full.nupkg",
// }.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(tempDir, APP_ID, "packages", x)));
// var info = new AppDescWindows(appDir, APP_ID);
// ReleaseEntry.BuildReleasesFile(info.PackagesDir);
// var releasePath = Path.Combine(packageDir.FullName, "RELEASES");
// File.Exists(releasePath).ShouldBeTrue();
// var entries = ReleaseEntry.ParseReleaseFile(File.ReadAllText(releasePath, Encoding.UTF8));
// entries.Count().ShouldEqual(3);
// }
// [Fact]
// public async Task InitialInstallSmokeTest()
// {
// using var _1 = Utility.GetTempDirectory(out var tempDir);
// var remotePackageDir = Directory.CreateDirectory(Path.Combine(tempDir, "remotePackages"));
// var localAppDir = Path.Combine(tempDir, APP_ID);
// new[] {
// "Squirrel.Core.1.0.0.0-full.nupkg",
// }.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(remotePackageDir.FullName, x)));
// using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePackageDir.FullName, APP_ID, tempDir);
// await fixture.FullInstall();
// var releasePath = Path.Combine(localAppDir, "packages", "RELEASES");
// File.Exists(releasePath).ShouldBeTrue();
// var entries = ReleaseEntry.ParseReleaseFile(File.ReadAllText(releasePath, Encoding.UTF8));
// entries.Count().ShouldEqual(1);
// Assert.True(File.Exists(Path.Combine(localAppDir, "current", "ReactiveUI.dll")));
// Assert.True(File.Exists(Path.Combine(localAppDir, "current", "NSync.Core.dll")));
// var manifest = NuspecManifest.ParseFromFile(Path.Combine(localAppDir, "current", Utility.SpecVersionFileName));
// Assert.Equal(new NuGetVersion(1, 0, 0, 0), manifest.Version);
// }
// [Fact]
// public async Task SpecialCharactersInitialInstallTest()
// {
// using var _1 = Utility.GetTempDirectory(out var tempDir);
// var remotePackageDir = Directory.CreateDirectory(Path.Combine(tempDir, "remotePackages"));
// var localAppDir = Path.Combine(tempDir, APP_ID);
// new[] {
// "SpecialCharacters-0.1.0-full.nupkg",
// }.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(remotePackageDir.FullName, x)));
// using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePackageDir.FullName, APP_ID, tempDir);
// await fixture.FullInstall();
// var releasePath = Path.Combine(localAppDir, "packages", "RELEASES");
// File.Exists(releasePath).ShouldBeTrue();
// var entries = ReleaseEntry.ParseReleaseFile(File.ReadAllText(releasePath, Encoding.UTF8));
// entries.Count().ShouldEqual(1);
// new[] {
// "file space name.txt"
// }.ForEach(x => File.Exists(Path.Combine(localAppDir, "current", x)).ShouldBeTrue());
// }
// [Fact]
// public async Task WhenBothFilesAreInSyncNoUpdatesAreApplied()
// {
// using var _1 = Utility.GetTempDirectory(out var tempDir);
// var appDir = Path.Combine(tempDir, APP_ID);
// var localPackages = Path.Combine(appDir, "packages");
// var remotePackages = Path.Combine(tempDir, "releases");
// Directory.CreateDirectory(localPackages);
// Directory.CreateDirectory(remotePackages);
// new[] {
// "Squirrel.Core.1.0.0.0-full.nupkg",
// "Squirrel.Core.1.1.0.0-delta.nupkg",
// "Squirrel.Core.1.1.0.0-full.nupkg",
// }.ForEach(x => {
// var path = IntegrationTestHelper.GetPath("fixtures", x);
// File.Copy(path, Path.Combine(localPackages, x));
// File.Copy(path, Path.Combine(remotePackages, x));
// });
// // sync both release files
// var info = new AppDescWindows(appDir, APP_ID);
// ReleaseEntry.BuildReleasesFile(info.PackagesDir);
// ReleaseEntry.BuildReleasesFile(remotePackages);
// // check for an update
// using var mgr = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePackages, APP_ID, tempDir);
// UpdateInfo updateInfo = await mgr.CheckForUpdate();
// Assert.NotNull(updateInfo);
// Assert.Empty(updateInfo.ReleasesToApply);
// }
// [Fact]
// public async Task WhenRemoteReleasesDoNotHaveDeltasNoUpdatesAreApplied()
// {
// using var _1 = Utility.GetTempDirectory(out var tempDir);
// var appDir = Path.Combine(tempDir, APP_ID);
// var localPackages = Path.Combine(appDir, "packages");
// var remotePackages = Path.Combine(tempDir, "releases");
// Directory.CreateDirectory(localPackages);
// Directory.CreateDirectory(remotePackages);
// new[] {
// "Squirrel.Core.1.0.0.0-full.nupkg",
// "Squirrel.Core.1.1.0.0-delta.nupkg",
// "Squirrel.Core.1.1.0.0-full.nupkg",
// }.ForEach(x => {
// var path = IntegrationTestHelper.GetPath("fixtures", x);
// File.Copy(path, Path.Combine(localPackages, x));
// });
// new[] {
// "Squirrel.Core.1.0.0.0-full.nupkg",
// "Squirrel.Core.1.1.0.0-full.nupkg",
// }.ForEach(x => {
// var path = IntegrationTestHelper.GetPath("fixtures", x);
// File.Copy(path, Path.Combine(remotePackages, x));
// });
// // sync both release files
// var info = new AppDescWindows(appDir, APP_ID);
// ReleaseEntry.BuildReleasesFile(info.PackagesDir);
// ReleaseEntry.BuildReleasesFile(remotePackages);
// using var mgr = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePackages, APP_ID, tempDir);
// UpdateInfo updateInfo = await mgr.CheckForUpdate();
// Assert.NotNull(updateInfo);
// Assert.Empty(updateInfo.ReleasesToApply);
// }
// [Fact]
// public async Task WhenTwoRemoteUpdatesAreAvailableChoosesDeltaVersion()
// {
// using var _1 = Utility.GetTempDirectory(out var tempDir);
// var appDir = Path.Combine(tempDir, APP_ID);
// var localPackages = Path.Combine(appDir, "packages");
// var remotePackages = Path.Combine(tempDir, "releases");
// Directory.CreateDirectory(localPackages);
// Directory.CreateDirectory(remotePackages);
// new[] { "Squirrel.Core.1.0.0.0-full.nupkg", }.ForEach(x => {
// var path = IntegrationTestHelper.GetPath("fixtures", x);
// File.Copy(path, Path.Combine(localPackages, x));
// });
// new[] {
// "Squirrel.Core.1.0.0.0-full.nupkg",
// "Squirrel.Core.1.1.0.0-delta.nupkg",
// "Squirrel.Core.1.1.0.0-full.nupkg",
// }.ForEach(x => {
// var path = IntegrationTestHelper.GetPath("fixtures", x);
// File.Copy(path, Path.Combine(remotePackages, x));
// });
// // sync both release files
// var info = new AppDescWindows(appDir, APP_ID);
// ReleaseEntry.BuildReleasesFile(info.PackagesDir);
// ReleaseEntry.BuildReleasesFile(remotePackages);
// using var mgr = UpdateManagerTestImpl.FromLocalPackageTempDir(remotePackages, APP_ID, tempDir);
// UpdateInfo updateInfo = await mgr.CheckForUpdate();
// Assert.True(updateInfo.ReleasesToApply.First().IsDelta);
// updateInfo = await mgr.CheckForUpdate(ignoreDeltaUpdates: true);
// Assert.False(updateInfo.ReleasesToApply.First().IsDelta);
// }
// [Fact]
// public async Task WhenFolderDoesNotExistThrowHelpfulError()
// {
// using var _1 = Utility.GetTempDirectory(out var tempDir);
// var directory = Path.Combine(tempDir, "missing-folder");
// using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(directory, APP_ID, tempDir);
// await Assert.ThrowsAsync<Exception>(() => fixture.CheckForUpdate());
// }
// [Fact]
// public async Task WhenReleasesFileDoesntExistThrowACustomError()
// {
// using var _1 = Utility.GetTempDirectory(out var tempDir);
// var directory = Path.Combine(tempDir, "folder");
// Directory.CreateDirectory(directory);
// using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(directory, APP_ID, tempDir);
// await Assert.ThrowsAsync<Exception>(() => fixture.CheckForUpdate());
// }
// [Fact]
// public async Task WhenReleasesFileIsBlankThrowAnException()
// {
// using var _1 = Utility.GetTempDirectory(out var tempDir);
// var directory = Path.Combine(tempDir, "folder");
// Directory.CreateDirectory(directory);
// using var fixture = UpdateManagerTestImpl.FromLocalPackageTempDir(directory, APP_ID, tempDir);
// File.WriteAllText(Path.Combine(directory, "RELEASES"), "");
// await Assert.ThrowsAsync(typeof(Exception), () => fixture.CheckForUpdate());
// }
// [Fact]
// public async Task WhenUrlResultsInWebExceptionWeShouldThrow()
// {
// // This should result in a WebException (which gets caught) unless you can actually access http://lol
// using var _1 = Utility.GetTempDirectory(out var tempDir);
// using var fixture = UpdateManagerTestImpl.FromFakeWebSource("http://lol", APP_ID, tempDir);
// await Assert.ThrowsAsync(typeof(HttpRequestException), () => fixture.CheckForUpdate());
// }
// [Fact]
// public void IsInstalledHandlesInvalidDirectoryStructure()
// {
// using (Utility.GetTempDirectory(out var tempDir)) {
// Directory.CreateDirectory(Path.Combine(tempDir, APP_ID));
// Directory.CreateDirectory(Path.Combine(tempDir, APP_ID, "app-1.0.1"));
// Directory.CreateDirectory(Path.Combine(tempDir, APP_ID, "wrongDir"));
// File.WriteAllText(Path.Combine(tempDir, APP_ID, "Update.exe"), "1");
// using (var fixture = UpdateManagerTestImpl.FromFakeWebSource("http://lol", APP_ID, tempDir)) {
// Assert.Null(new AppDescWindows(Path.Combine(tempDir, "app.exe")).CurrentlyInstalledVersion);
// Assert.Null(new AppDescWindows(Path.Combine(tempDir, APP_ID, "app.exe")).CurrentlyInstalledVersion);
// Assert.Null(new AppDescWindows(Path.Combine(tempDir, APP_ID, "wrongDir", "app.exe")).CurrentlyInstalledVersion);
// Assert.Equal(new SemanticVersion(1, 0, 9),
// new AppDescWindows(Path.Combine(tempDir, APP_ID, "app-1.0.9", "app.exe")).CurrentlyInstalledVersion);
// }
// }
// }
// [Fact]
// public void CurrentlyInstalledVersionDoesNotThrow()
// {
// using var fixture = new UpdateManager();
// Assert.Null(fixture.CurrentlyInstalledVersion());
// Assert.False(fixture.IsInstalledApp);
// }
// [Theory]
// [InlineData(0, 0, 25, 0)]
// [InlineData(12, 0, 25, 3)]
// [InlineData(55, 0, 25, 13)]
// [InlineData(100, 0, 25, 25)]
// [InlineData(0, 25, 50, 25)]
// [InlineData(12, 25, 50, 28)]
// [InlineData(55, 25, 50, 38)]
// [InlineData(100, 25, 50, 50)]
// public void CalculatesPercentageCorrectly(int percentageOfCurrentStep, int stepStartPercentage, int stepEndPercentage, int expectedPercentage)
// {
// var percentage = Utility.CalculateProgress(percentageOfCurrentStep, stepStartPercentage, stepEndPercentage);
// Assert.Equal(expectedPercentage, percentage);
// }
// [Fact]
// public void CalculatesPercentageCorrectlyForUpdateExe()
// {
// // Note: this mimicks the update.exe progress reporting of multiple steps
// var progress = new List<int>();
// // 3 % (3 stages), check for updates
// foreach (var step in new[] { 0, 33, 66, 100 }) {
// progress.Add(Utility.CalculateProgress(step, 0, 3));
// Assert.InRange(progress.Last(), 0, 3);
// }
// Assert.Equal(3, progress.Last());
// // 3 - 30 %, download releases
// for (var step = 0; step <= 100; step++) {
// progress.Add(Utility.CalculateProgress(step, 3, 30));
// Assert.InRange(progress.Last(), 3, 30);
// }
// Assert.Equal(30, progress.Last());
// // 30 - 100 %, apply releases
// for (var step = 0; step <= 100; step++) {
// progress.Add(Utility.CalculateProgress(step, 30, 100));
// Assert.InRange(progress.Last(), 30, 100);
// }
// Assert.Equal(100, progress.Last());
// }
// }
// }
// }
//}