예제 #1
0
        /// <summary>
        /// Utility method to get the settings
        /// </summary>
        /// <param name="lookUp">IDynamoLookUp instance</param>
        /// <param name="updateManager"></param>
        /// <returns></returns>
        public static UpdateManagerConfiguration GetSettings(IDynamoLookUp lookUp, IUpdateManager updateManager = null)
        {
            string filePath;
            var    exists = TryGetConfigFilePath(out filePath);

#if DEBUG
            //This code is just to create the default config file to
            //save the default settings, which later on can be modified
            //to re-direct it to other download target for testing.
            if (!exists)
            {
                var umConfig = new UpdateManagerConfiguration();
                umConfig.Save(filePath, updateManager);
            }
#endif
            if (!exists)
            {
                return new UpdateManagerConfiguration()
                       {
                           DynamoLookUp = lookUp
                       }
            }
            ;

            var config = Load(filePath, updateManager);
            if (null != config)
            {
                config.DynamoLookUp = lookUp;
            }

            return(config);
        }
예제 #2
0
        /// <summary>
        /// Utility method to get the settings
        /// </summary>
        /// <param name="lookUp">IDynamoLookUp instance</param>
        /// <param name="updateManager"></param>
        /// <returns></returns>
        public static UpdateManagerConfiguration GetSettings(IDynamoLookUp lookUp, IUpdateManager updateManager = null)
        {
            string filePath;
            var exists = TryGetConfigFilePath(out filePath);
#if DEBUG
            //This code is just to create the default config file to
            //save the default settings, which later on can be modified
            //to re-direct it to other download target for testing.
            if (!exists)
            {
                var umConfig = new UpdateManagerConfiguration();
                umConfig.Save(filePath, updateManager);
            }
#endif
            if (!exists) 
                return new UpdateManagerConfiguration() { DynamoLookUp = lookUp };

            var config = Load(filePath, updateManager);
            if (null != config)
                config.DynamoLookUp = lookUp;

            return config;
        }
예제 #3
0
        public void ConfigurationRedirection()
        {
            //Inject test config to UpdateManager instance, using reflection.
            var config = new UpdateManagerConfiguration()
            {
                DownloadSourcePath = DOWNLOAD_SOURCE_PATH_S,
                SignatureSourcePath = SIGNATURE_SOURCE_PATH_S
            };

            var um = new DynUpdateManager(config);
            Assert.IsNotNull(um);
        
            var updateRequest = new Mock<IAsynchronousRequest>();
            updateRequest.Setup(ur => ur.Data)
                .Returns(UpdateManagerTestHelpers.updateAvailableData);
            um.UpdateDataAvailable(updateRequest.Object);

            // Spoof a download completion by setting the downloaded update info to the update info
            um.DownloadedUpdateInfo = um.UpdateInfo;
            Assert.NotNull(um.UpdateInfo);
            Assert.AreEqual("9.9.9.0", um.AvailableVersion.ToString());
            Assert.AreEqual(DOWNLOAD_SOURCE_PATH_S, um.UpdateInfo.VersionInfoURL);
            Assert.AreEqual(
                SIGNATURE_SOURCE_PATH_S + @"DynamoInstall9.9.9.sig",
                um.UpdateInfo.SignatureURL);
        }
예제 #4
0
 public void ConfigurationSerialization()
 {
     var config = new UpdateManagerConfiguration()
     {
         DownloadSourcePath = DOWNLOAD_SOURCE_PATH_S,
         SignatureSourcePath = SIGNATURE_SOURCE_PATH_S
     };
     
     //save to a temp file.
     var tempFile = Path.GetTempFileName();
     Assert.DoesNotThrow(() => config.Save(tempFile, null));
     
     //read from a temp file.
     UpdateManagerConfiguration savedConfig = null;
     Assert.DoesNotThrow(() => savedConfig = UpdateManagerConfiguration.Load(tempFile, null));
     
     //Compare parameters.
     Assert.IsNotNull(savedConfig);
     Assert.AreEqual(config.CheckNewerDailyBuild, savedConfig.CheckNewerDailyBuild);
     Assert.AreEqual(config.SignatureSourcePath, savedConfig.SignatureSourcePath);
     Assert.AreEqual(config.DownloadSourcePath, savedConfig.DownloadSourcePath);
     Assert.AreEqual(config.ForceUpdate, savedConfig.ForceUpdate);
 }