public void TestLocator()
        {
            Locator locator =
                new Locator(new ProgramInfo {
                Name = "TestApp"
            });
            var pkg = new UpdatePackageData()
            {
                FileName = "Updates.zip", Version = "1.2.0"
            };

            var parent = locator.GetCurrentUpdateSubfolder(new[] { pkg });


            var updatePackage = locator.BuildUpdatePackagePath(parent, pkg);

            Assert.AreEqual($@"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\Telimena\TestApp\Updates\1.2.0\1.2.0\Updates.zip", updatePackage.FullName);
        }
        public void Test_UpdaterPathFinder_CannotAccessAppData()
        {
            List <UpdatePackageData> packages = new List <UpdatePackageData>
            {
                new UpdatePackageData   {
                    PublicId = this.PrgPkg_4, Version = "3.5", FileName = "Updates.zip"
                }
                , new UpdatePackageData {
                    PublicId = this.PrgPkg_2, Version = "2.0", FileName = "Updates.zip"
                }
                , new UpdatePackageData {
                    PublicId = this.PrgPkg_1, Version = "1.0", FileName = "Updates.zip"
                }
                , new UpdatePackageData {
                    PublicId = this.PrgPkg_3, Version = "3.0", FileName = "Updates.zip"
                }
            };
            string temp = Path.GetTempPath();

            string        appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            DirectoryInfo dirInfo = new DirectoryInfo(Path.Combine(appData, "Telimena", "Test_UpdaterPathFinder_CannotAccessAppData"));

            dirInfo.Create();
            DirectorySecurity securityRules = new DirectorySecurity();

            securityRules.AddAccessRule(new FileSystemAccessRule("Users", FileSystemRights.Write, AccessControlType.Deny));

            dirInfo.SetAccessControl(securityRules);
            var lpi = new LiveProgramInfo(new ProgramInfo {
                Name = "Test_UpdaterPathFinder_CannotAccessAppData"
            })
            {
                UpdaterName = "MyUpdater.exe"
            };
            Locator locator =
                new Locator(lpi.Program, temp);

            FileInfo updater = locator.GetUpdater(lpi);

            Assert.AreEqual($@"{temp}Test_UpdaterPathFinder_CannotAccessAppData Updates\MyUpdater.exe", updater.FullName);

            DirectoryInfo subFolder = locator.GetCurrentUpdateSubfolder(packages);

            Assert.AreEqual($@"{temp}Test_UpdaterPathFinder_CannotAccessAppData Updates\3.5", subFolder.FullName);

            Assert.AreEqual($@"{temp}Test_UpdaterPathFinder_CannotAccessAppData Updates\3.5\3.5\Updates.zip", locator.BuildUpdatePackagePath(subFolder, packages[0]).FullName);
            Assert.AreEqual($@"{temp}Test_UpdaterPathFinder_CannotAccessAppData Updates\3.5\2.0\Updates.zip", locator.BuildUpdatePackagePath(subFolder, packages[1]).FullName);
        }