public void Test_PackageSorting() { List <UpdatePackageData> packages = new List <UpdatePackageData> { new UpdatePackageData { PublicId = this.PrgPkg_4, Version = "3.5" } , new UpdatePackageData { PublicId = this.PrgPkg_2, Version = "2.0" } , new UpdatePackageData { PublicId = this.PrgPkg_1, Version = "1.0" } , new UpdatePackageData { PublicId = this.PrgPkg_3, Version = "3.0" } }; List <UpdatePackageData> ordered = UpdateInstructionCreator.Sort(packages); Assert.AreEqual(this.PrgPkg_1, ordered[0].PublicId); Assert.AreEqual(this.PrgPkg_2, ordered[1].PublicId); Assert.AreEqual(this.PrgPkg_3, ordered[2].PublicId); Assert.AreEqual(this.PrgPkg_4, ordered[3].PublicId); }
public void Test_Worker_EnsureProperPackageIsPicked() { List <UpdatePackageData> packages = new List <UpdatePackageData> { new UpdatePackageData { Version = "1.2", FileName = "MyPackageBasedApp Updates v. 1.2.zip" } , new UpdatePackageData { Version = "1.1.2", FileName = "MyPackageBasedApp Updates v. 1.1.2.zip" } , new UpdatePackageData { Version = "1.1.3", FileName = "MyPackageBasedApp Updates v. 1.1.3.zip" } }; packages.ForEach(x => x.StoredFilePath = Locator.Static.BuildUpdatePackagePath(this.Update12Folder, x).FullName); Tuple <XDocument, FileInfo> tuple = UpdateInstructionCreator.CreateXDoc(packages , new ProgramInfo { PrimaryAssembly = new AssemblyInfo { Location = @"C:\AppFolder\MyApp.exe" } }, "Program Display Name"); XDocument xDoc = tuple.Item1; FileInfo file = tuple.Item2; Assert.AreEqual($@"{this.Update12Folder.FullName}\UpdateInstructions.xml", file.FullName); UpdateInstructions instructions = UpdateInstructionsReader.DeserializeDocument(xDoc); Assert.AreEqual("Program Display Name", instructions.ProgramName); Assert.That(() => instructions.Packages.First().Version, Is.EqualTo("1.1.2")); Assert.That(() => instructions.Packages.Last().Version, Is.EqualTo("1.2")); var worker = new PackageUpdaterWorker(); string expected = worker.GetProperPackagePath(instructions); Assert.That(expected, Is.EqualTo($@"{this.Update12Folder.FullName}\1.2\MyPackageBasedApp Updates v. 1.2.zip")); }
public void Test_UpdateInstructionCreator() { var locator = new Locator(new ProgramInfo { Name = "App.exe" }, @"C:\AppFolder\"); List <UpdatePackageData> packages = new List <UpdatePackageData> { new UpdatePackageData { PublicId = this.PrgPkg_4, Version = "3.5", FileName = "Updates v 3.5.zip", ReleaseNotes = "Features for 3.5" } , new UpdatePackageData { PublicId = this.PrgPkg_2, Version = "2.0", FileName = "Updates v 2.0.zip", ReleaseNotes = "Features for 2.0" } , new UpdatePackageData { PublicId = this.PrgPkg_1, Version = "1.0", FileName = "Updates v 1.0.zip", ReleaseNotes = "Features for 1.0" } , new UpdatePackageData { PublicId = this.PrgPkg_3, Version = "3.0", FileName = "Updates v 3.0.zip", ReleaseNotes = "Features for 3.0" } }; DirectoryInfo currentUpdateSubfolder = locator.GetCurrentUpdateSubfolder(packages); packages.ForEach(x => x.StoredFilePath = Locator.Static.BuildUpdatePackagePath(currentUpdateSubfolder, x).FullName); Tuple <XDocument, FileInfo> tuple = UpdateInstructionCreator.CreateXDoc(packages , new ProgramInfo { PrimaryAssembly = new Model.AssemblyInfo { Location = @"C:\AppFolder\MyApp.exe" } }, "Program Display Name"); XDocument xDoc = tuple.Item1; FileInfo file = tuple.Item2; Assert.AreEqual($@"{currentUpdateSubfolder.FullName}\UpdateInstructions.xml", file.FullName); global::Telimena.Updater.UpdateInstructions updaterInstructions = global::Telimena.Updater.UpdateInstructionsReader.DeserializeDocument(xDoc); Assert.AreEqual(@"3.5", updaterInstructions.LatestVersion); Assert.AreEqual(@"C:\AppFolder\MyApp.exe", updaterInstructions.ProgramExecutableLocation); Assert.AreEqual("Program Display Name", updaterInstructions.ProgramName); Assert.That(() => updaterInstructions.Packages[0].Version, Is.EqualTo("1.0")); Assert.That(() => updaterInstructions.Packages[1].Version, Is.EqualTo("2.0")); Assert.That(() => updaterInstructions.Packages[2].Version, Is.EqualTo("3.0")); Assert.That(() => updaterInstructions.Packages[3].Version, Is.EqualTo("3.5")); Assert.That(() => updaterInstructions.Packages[0].ReleaseNotes, Is.EqualTo("Features for 1.0")); Assert.That(() => updaterInstructions.Packages[1].ReleaseNotes, Is.EqualTo("Features for 2.0")); Assert.That(() => updaterInstructions.Packages[2].ReleaseNotes, Is.EqualTo("Features for 3.0")); Assert.That(() => updaterInstructions.Packages[3].ReleaseNotes, Is.EqualTo("Features for 3.5")); Assert.AreEqual($@"{currentUpdateSubfolder.FullName}\1.0\Updates v 1.0.zip", updaterInstructions.Packages[0].Path); Assert.AreEqual($@"{currentUpdateSubfolder.FullName}\2.0\Updates v 2.0.zip", updaterInstructions.Packages[1].Path); Assert.AreEqual($@"{currentUpdateSubfolder.FullName}\3.0\Updates v 3.0.zip", updaterInstructions.Packages[2].Path); Assert.AreEqual($@"{currentUpdateSubfolder.FullName}\3.5\Updates v 3.5.zip", updaterInstructions.Packages[3].Path); updaterInstructions = null; global::Telimena.PackageTriggerUpdater.UpdateInstructions packageUpdaterInstructions = global::Telimena.PackageTriggerUpdater.UpdateInstructionsReader.DeserializeDocument(xDoc); Assert.AreEqual(@"3.5", packageUpdaterInstructions.LatestVersion); Assert.AreEqual(@"C:\AppFolder\MyApp.exe", packageUpdaterInstructions.ProgramExecutableLocation); Assert.That(() => packageUpdaterInstructions.Packages[0].Version, Is.EqualTo("1.0")); Assert.That(() => packageUpdaterInstructions.Packages[1].Version, Is.EqualTo("2.0")); Assert.That(() => packageUpdaterInstructions.Packages[2].Version, Is.EqualTo("3.0")); Assert.That(() => packageUpdaterInstructions.Packages[3].Version, Is.EqualTo("3.5")); Assert.That(() => packageUpdaterInstructions.Packages[0].ReleaseNotes, Is.EqualTo("Features for 1.0")); Assert.That(() => packageUpdaterInstructions.Packages[1].ReleaseNotes, Is.EqualTo("Features for 2.0")); Assert.That(() => packageUpdaterInstructions.Packages[2].ReleaseNotes, Is.EqualTo("Features for 3.0")); Assert.That(() => packageUpdaterInstructions.Packages[3].ReleaseNotes, Is.EqualTo("Features for 3.5")); Assert.AreEqual($@"{currentUpdateSubfolder.FullName}\1.0\Updates v 1.0.zip", packageUpdaterInstructions.Packages[0].Path); Assert.AreEqual($@"{currentUpdateSubfolder.FullName}\2.0\Updates v 2.0.zip", packageUpdaterInstructions.Packages[1].Path); Assert.AreEqual($@"{currentUpdateSubfolder.FullName}\3.0\Updates v 3.0.zip", packageUpdaterInstructions.Packages[2].Path); Assert.AreEqual($@"{currentUpdateSubfolder.FullName}\3.5\Updates v 3.5.zip", packageUpdaterInstructions.Packages[3].Path); }