public void DownloadReleasesFromHttpServerIntegrationTest() { 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", FrameworkVersion.Net40, tempDir); using (fixture) { var progress = new ReplaySubject <int>(); fixture.DownloadReleases(entriesToDownload, progress).First(); this.Log().Info("Progress: [{0}]", String.Join(",", progress)); progress.Buffer(2, 1).All(x => x.Count != 2 || x[1] > x[0]).First().ShouldBeTrue(); progress.Last().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); }); } }
public void ApplyReleasesWithDeltaReleases() { string tempDir; using (Utility.WithTempDirectory(out tempDir)) { string packagesDir = Path.Combine(tempDir, "theApp", "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))); var fixture = new UpdateManager("http://lol", "theApp", FrameworkVersion.Net40, tempDir, null, new FakeUrlDownloader()); 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, FrameworkVersion.Net40); updateInfo.ReleasesToApply.Contains(deltaEntry).ShouldBeTrue(); using (fixture) { var progress = new ReplaySubject <int>(); fixture.ApplyReleases(updateInfo, progress).First(); this.Log().Info("Progress: [{0}]", String.Join(",", progress)); progress.Buffer(2, 1).All(x => x.Count != 2 || x[1] > x[0]).First().ShouldBeTrue(); progress.Last().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") }, new { Name = Path.Combine("sub", "Ionic.Zip.dll"), Version = new Version("1.9.1.8") }, }; filesToFind.ForEach(x => { var path = Path.Combine(tempDir, "theApp", "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); }); } }
public void ApplyReleaseWhichMovesAFileToADifferentDirectory() { string tempDir; using (Utility.WithTempDirectory(out tempDir)) { Directory.CreateDirectory(Path.Combine(tempDir, "theApp")); Directory.CreateDirectory(Path.Combine(tempDir, "theApp", "packages")); new[] { "Shimmer.Core.1.1.0.0-full.nupkg", "Shimmer.Core.1.3.0.0-full.nupkg", }.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(tempDir, "theApp", "packages", x))); var fixture = new UpdateManager("http://lol", "theApp", FrameworkVersion.Net40, tempDir, null, new FakeUrlDownloader()); var baseEntry = ReleaseEntry.GenerateFromFile(Path.Combine(tempDir, "theApp", "packages", "Shimmer.Core.1.1.0.0-full.nupkg")); var latestFullEntry = ReleaseEntry.GenerateFromFile(Path.Combine(tempDir, "theApp", "packages", "Shimmer.Core.1.3.0.0-full.nupkg")); var updateInfo = UpdateInfo.Create(baseEntry, new[] { latestFullEntry }, "dontcare", FrameworkVersion.Net40); updateInfo.ReleasesToApply.Contains(latestFullEntry).ShouldBeTrue(); using (fixture) { var progress = new ReplaySubject <int>(); fixture.ApplyReleases(updateInfo, progress).First(); this.Log().Info("Progress: [{0}]", String.Join(",", progress)); progress.Buffer(2, 1).All(x => x.Count != 2 || x[1] > x[0]).First().ShouldBeTrue(); progress.Last().ShouldEqual(100); } var rootDirectory = Path.Combine(tempDir, "theApp", "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(); } }
public void ApplyReleasesWithDeltaReleases() { string tempDir; using (Utility.WithTempDirectory(out tempDir)) { Directory.CreateDirectory(Path.Combine(tempDir, "theApp", "packages")); new[] { "Shimmer.Core.1.0.0.0-full.nupkg", "Shimmer.Core.1.1.0.0-delta.nupkg", "Shimmer.Core.1.1.0.0-full.nupkg", }.ForEach(x => File.Copy(IntegrationTestHelper.GetPath("fixtures", x), Path.Combine(tempDir, "theApp", "packages", x))); var fixture = new UpdateManager("http://lol", "theApp", FrameworkVersion.Net40, tempDir, null, new FakeUrlDownloader()); var baseEntry = ReleaseEntry.GenerateFromFile(Path.Combine(tempDir, "theApp", "packages", "Shimmer.Core.1.0.0.0-full.nupkg")); var deltaEntry = ReleaseEntry.GenerateFromFile(Path.Combine(tempDir, "theApp", "packages", "Shimmer.Core.1.1.0.0-delta.nupkg")); var latestFullEntry = ReleaseEntry.GenerateFromFile(Path.Combine(tempDir, "theApp", "packages", "Shimmer.Core.1.1.0.0-full.nupkg")); var updateInfo = UpdateInfo.Create(baseEntry, new[] { deltaEntry, latestFullEntry }, "dontcare", FrameworkVersion.Net40); updateInfo.ReleasesToApply.Contains(deltaEntry).ShouldBeTrue(); using (fixture) { var progress = new ReplaySubject<int>(); fixture.ApplyReleases(updateInfo, progress).First(); this.Log().Info("Progress: [{0}]", String.Join(",", progress)); progress.Buffer(2,1).All(x => x.Count != 2 || x[1] > x[0]).First().ShouldBeTrue(); progress.Last().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")}, new {Name = "Ionic.Zip.dll", Version = new Version("1.9.1.8")}, }; filesToFind.ForEach(x => { var path = Path.Combine(tempDir, "theApp", "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); }); } }
public void DownloadReleasesFromFileDirectoryIntegrationTest() { 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", FrameworkVersion.Net40, tempDir); using (fixture) { var progress = new ReplaySubject <int>(); fixture.DownloadReleases(entriesToDownload, progress).First(); this.Log().Info("Progress: [{0}]", String.Join(",", progress)); progress.Buffer(2, 1).All(x => x.Count != 2 || x[1] > x[0]).First().ShouldBeTrue(); progress.Last().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); }); } }
public void DownloadReleasesFromFileDirectoryIntegrationTest() { 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", FrameworkVersion.Net40, tempDir); using (fixture) { var progress = new ReplaySubject<int>(); fixture.DownloadReleases(entriesToDownload, progress).First(); this.Log().Info("Progress: [{0}]", String.Join(",", progress)); progress.Buffer(2,1).All(x => x.Count != 2 || x[1] > x[0]).First().ShouldBeTrue(); progress.Last().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); }); } }
public void DownloadReleasesFromHttpServerIntegrationTest() { 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", FrameworkVersion.Net40, tempDir); using (fixture) { var progress = new ReplaySubject<int>(); fixture.DownloadReleases(entriesToDownload, progress).First(); this.Log().Info("Progress: [{0}]", String.Join(",", progress)); progress.Buffer(2,1).All(x => x.Count != 2 || x[1] > x[0]).First().ShouldBeTrue(); progress.Last().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); }); } }
public void ApplyReleaseWhichMovesAFileToADifferentDirectory() { string tempDir; using (Utility.WithTempDirectory(out tempDir)) { string packagesDir = Path.Combine(tempDir, "theApp", "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))); var fixture = new UpdateManager("http://lol", "theApp", FrameworkVersion.Net40, tempDir, null, new FakeUrlDownloader()); 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, FrameworkVersion.Net40); updateInfo.ReleasesToApply.Contains(latestFullEntry).ShouldBeTrue(); using (fixture) { var progress = new ReplaySubject<int>(); fixture.ApplyReleases(updateInfo, progress).First(); this.Log().Info("Progress: [{0}]", String.Join(",", progress)); progress.Buffer(2, 1).All(x => x.Count != 2 || x[1] > x[0]).First().ShouldBeTrue(); progress.Last().ShouldEqual(100); } var rootDirectory = Path.Combine(tempDir, "theApp", "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(); } }