示例#1
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);
        }
示例#2
0
        public static DynamoController MakeSandbox(string commandFilePath = null)
        {
            DynamoController controller;
            var logger        = new DynamoLogger();
            var updateManager = new UpdateManager.UpdateManager(logger);

            // If a command file path is not specified or if it is invalid, then fallback.
            if (string.IsNullOrEmpty(commandFilePath) || (File.Exists(commandFilePath) == false))
            {
                controller = new DynamoController("None", updateManager, logger,
                                                  new DefaultWatchHandler(), Dynamo.PreferenceSettings.Load());

                controller.DynamoViewModel = new DynamoViewModel(controller, null);
            }
            else
            {
                controller = new DynamoController("None", updateManager, logger,
                                                  new DefaultWatchHandler(), Dynamo.PreferenceSettings.Load());

                controller.DynamoViewModel = new DynamoViewModel(controller, commandFilePath);
            }

            controller.VisualizationManager = new VisualizationManager();
            return(controller);
        }
示例#3
0
        /// <summary>
        ///if we are building a model for CLI mode, then we don't want to start an updateManager
        ///for now, building an updatemanager instance requires finding Dynamo install location
        ///which if we are running on mac os or *nix will use different logic then SandboxLookup
        /// </summary>
        private static IUpdateManager InitializeUpdateManager()
        {
            var cfg = UpdateManagerConfiguration.GetSettings(new SandboxLookUp());
            var um  = new Dynamo.UpdateManager.UpdateManager(cfg);

            Debug.Assert(cfg.DynamoLookUp != null);
            return(um);
        }
        public void UpdateCheckReturnsInfoWhenNewerDailyBuildAvailable()
        {
            var updateRequest = new Mock<IAsynchronousRequest>();
            updateRequest.Setup(ur => ur.Data).Returns(UpdateManagerTestHelpers.dailyBuildAvailableData);

            var updateManager = new DynUpdateManager(NewConfiguration(checkNewerDailyBuild: true));
            updateManager.UpdateDataAvailable(updateRequest.Object);
            Assert.NotNull(updateManager.UpdateInfo);
        }
示例#5
0
            private readonly FieldInfo fieldInfo; //internal configuration field.

            /// <summary>
            /// Creates ConfigInjection instance.
            /// </summary>
            /// <param name="updateManager">UpdateManager instance to which configuration is to be injected.</param>
            /// <param name="configuration">The configuration for injection.</param>
            public ConfigInjection(DynUpdateManager updateManager, UpdateManagerConfiguration configuration)
            {
                this.updateManager = updateManager;
                fieldInfo = updateManager.GetType()
                    .GetField("configuration", BindingFlags.NonPublic | BindingFlags.Instance);
                Assert.IsNotNull(fieldInfo);

                this.configuration = fieldInfo.GetValue(updateManager);
                fieldInfo.SetValue(updateManager, configuration);
            }
示例#6
0
            private readonly FieldInfo fieldInfo;            //internal configuration field.

            /// <summary>
            /// Creates ConfigInjection instance.
            /// </summary>
            /// <param name="updateManager">UpdateManager instance to which configuration is to be injected.</param>
            /// <param name="configuration">The configuration for injection.</param>
            public ConfigInjection(DynUpdateManager updateManager, UpdateManagerConfiguration configuration)
            {
                this.updateManager = updateManager;
                fieldInfo          = updateManager.GetType()
                                     .GetField("configuration", BindingFlags.NonPublic | BindingFlags.Instance);
                Assert.IsNotNull(fieldInfo);

                this.configuration = fieldInfo.GetValue(updateManager);
                fieldInfo.SetValue(updateManager, configuration);
            }
示例#7
0
        public void UpdateCheckReturnsNothingWhenNoVersionsAvailable()
        {
            var updateRequest = new Mock <IAsynchronousRequest>();

            updateRequest.Setup(ur => ur.Data).Returns(UpdateManagerTestHelpers.noData);
            var um = new DynUpdateManager(NewConfiguration());

            um.UpdateDataAvailable(updateRequest.Object);

            Assert.Null(um.UpdateInfo);
        }
        public void IsUpdateAvailableWhenForceUpdateIsTrue()
        {
            var updateRequest = new Mock<IAsynchronousRequest>();
            updateRequest.Setup(ur => ur.Data).Returns(UpdateManagerTestHelpers.noUpdateAvailableData);

            var updateManager = new DynUpdateManager(NewConfiguration(forceUpdate:true));
            updateManager.UpdateDataAvailable(updateRequest.Object);
            updateManager.DownloadedUpdateInfo = updateManager.UpdateInfo;

            Assert.IsTrue(updateManager.IsUpdateAvailable);
        }
示例#9
0
        public void UpdateCheckReturnsInfoWhenNewerDailyBuildAvailable()
        {
            var updateRequest = new Mock <IAsynchronousRequest>();

            updateRequest.Setup(ur => ur.Data).Returns(UpdateManagerTestHelpers.dailyBuildAvailableData);

            var updateManager = new DynUpdateManager(NewConfiguration(checkNewerDailyBuild: true));

            updateManager.UpdateDataAvailable(updateRequest.Object);
            Assert.NotNull(updateManager.UpdateInfo);
        }
示例#10
0
        public void UpdateCheckReturnsNothingWhenNotConnected()
        {
            var updateRequest = new Mock <IAsynchronousRequest>();

            updateRequest.Setup(ur => ur.Data).Returns(string.Empty);

            var um = new DynUpdateManager(NewConfiguration());

            um.UpdateDataAvailable(updateRequest.Object);

            Assert.Null(um.UpdateInfo);
        }
示例#11
0
        public void NoUpdateAvailableWhenUpToDate()
        {
            var updateRequest = new Mock <IAsynchronousRequest>();

            updateRequest.Setup(ur => ur.Data).Returns(UpdateManagerTestHelpers.noUpdateAvailableData);

            var updateManager = new DynUpdateManager(NewConfiguration());

            updateManager.UpdateDataAvailable(updateRequest.Object);
            updateManager.DownloadedUpdateInfo = updateManager.UpdateInfo;

            Assert.IsFalse(updateManager.IsUpdateAvailable);
        }
示例#12
0
        public void UpdateCheckReturnsCorrectVersionWhenAvailable()
        {
            var um = new DynUpdateManager(NewConfiguration());

            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(um.AvailableVersion.ToString(), "9.9.9.0");
        }
示例#13
0
        public void NoUpdateIsAvailableWhenHigherVersionDynamoIsInstalled()
        {
            var lookup = new Mock <DynamoLookUp>();

            lookup.Setup(l => l.GetDynamoInstallLocations()).Returns(new[] { "A" });
            lookup.Setup(l => l.GetDynamoVersion(It.IsAny <string>()))
            .Returns <string>(s => Version.Parse("9.9.9.0"));

            var um = new DynUpdateManager(NewConfiguration(false, false, lookup.Object));

            Assert.IsNotNull(um);

            DynUpdateManager.CheckForProductUpdate(um);
            um.DownloadedUpdateInfo = um.UpdateInfo;

            Assert.IsNull(um.UpdateInfo);
            Assert.IsFalse(um.IsUpdateAvailable);
        }
示例#14
0
        public void UpdateCheckReturnsNothingWhenGivenBadData()
        {
            // Here we simulate some xml that is returned that is well-formed
            // but not what we are looking for. This is the case often when you
            // are logging into a network that requires an additional login, like
            // hotel wi-fi. In this case, the ListBucketResult element will not
            // be found in the xml and we'll get null UpdateInfo.

            var updateRequest = new Mock <IAsynchronousRequest>();

            updateRequest.Setup(ur => ur.Data).Returns(UpdateManagerTestHelpers.badData);

            var um = new DynUpdateManager(NewConfiguration());

            um.UpdateDataAvailable(updateRequest.Object);

            Assert.Null(um.UpdateInfo);
        }
示例#15
0
 /// <summary>
 ///if we are building a model for CLI mode, then we don't want to start an updateManager
 ///for now, building an updatemanager instance requires finding Dynamo install location
 ///which if we are running on mac os or *nix will use different logic then SandboxLookup 
 /// </summary>
 private static IUpdateManager InitializeUpdateManager()
 {
     var cfg = UpdateManagerConfiguration.GetSettings(new SandboxLookUp());
     var um = new Dynamo.UpdateManager.UpdateManager(cfg);
     Debug.Assert(cfg.DynamoLookUp != null);
     return um;
 }
示例#16
0
        public void UpdateCheckReturnsNothingWhenNotConnected()
        {
            var updateRequest = new Mock<IAsynchronousRequest>();
            updateRequest.Setup(ur => ur.Data).Returns(string.Empty);

            var um = new DynUpdateManager(NewConfiguration());
            um.UpdateDataAvailable(updateRequest.Object);

            Assert.Null(um.UpdateInfo);
        }
示例#17
0
        public void UpdateCheckReturnsNothingWhenGivenBadData()
        {
            // Here we simulate some xml that is returned that is well-formed
            // but not what we are looking for. This is the case often when you
            // are logging into a network that requires an additional login, like
            // hotel wi-fi. In this case, the ListBucketResult element will not 
            // be found in the xml and we'll get null UpdateInfo.

            var updateRequest = new Mock<IAsynchronousRequest>();
            updateRequest.Setup(ur => ur.Data).Returns(UpdateManagerTestHelpers.badData);

            var um = new DynUpdateManager(NewConfiguration());
            um.UpdateDataAvailable(updateRequest.Object);

            Assert.Null(um.UpdateInfo);
        }
示例#18
0
        public void NoUpdateIsAvailableWhenHigherVersionDynamoIsInstalled()
        {
            var lookup = new Mock<DynamoLookUp>();
            lookup.Setup(l => l.GetDynamoInstallLocations()).Returns(new[] { "A" });
            lookup.Setup(l => l.GetDynamoVersion(It.IsAny<string>()))
                .Returns<string>(s => Version.Parse("9.9.9.0"));

            var um = new DynUpdateManager(NewConfiguration(false, false, lookup.Object));
            Assert.IsNotNull(um);

            DynUpdateManager.CheckForProductUpdate(um);
            um.DownloadedUpdateInfo = um.UpdateInfo;

            Assert.IsNull(um.UpdateInfo);
            Assert.IsFalse(um.IsUpdateAvailable);
        }
示例#19
0
        public void UpdateCheckReturnsCorrectVersionWhenAvailable()
        {
            var um = new DynUpdateManager(NewConfiguration());
            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(um.AvailableVersion.ToString(), "9.9.9.0");
        }
示例#20
0
        public static DynamoController MakeSandbox(string commandFilePath = null)
        {
            DynamoController controller;
            var logger = new DynamoLogger();
            var updateManager = new UpdateManager.UpdateManager(logger);

            // If a command file path is not specified or if it is invalid, then fallback.
            if (string.IsNullOrEmpty(commandFilePath) || (File.Exists(commandFilePath) == false))
            {
                
                controller = new DynamoController("None", updateManager, logger,
                    new DefaultWatchHandler(), Dynamo.PreferenceSettings.Load());

                controller.DynamoViewModel = new DynamoViewModel(controller, null);
            }
            else
            {
                controller = new DynamoController("None", updateManager, logger,
                 new DefaultWatchHandler(), Dynamo.PreferenceSettings.Load());

                controller.DynamoViewModel = new DynamoViewModel(controller, commandFilePath);
            }

            controller.VisualizationManager = new VisualizationManager();
            return controller;
        }
示例#21
0
        public void UpdateCheckReturnsNothingWhenNoVersionsAvailable()
        {
            var updateRequest = new Mock<IAsynchronousRequest>();
            updateRequest.Setup(ur => ur.Data).Returns(UpdateManagerTestHelpers.noData);
            var um = new DynUpdateManager(NewConfiguration());
            um.UpdateDataAvailable(updateRequest.Object);

            Assert.Null(um.UpdateInfo);
        }
示例#22
0
 public void NoUpdateAvailableWhenUpdateInfoIsNotYetDownloaded()
 {
     var updateManager = new DynUpdateManager(NewConfiguration());
     
     Assert.IsFalse(updateManager.IsUpdateAvailable);
 }
示例#23
0
        public static DynamoController MakeSandbox(string commandFilePath = null)
        {
            var corePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            DynamoPathManager.Instance.InitializeCore(corePath);

            DynamoController controller;
            var logger = new DynamoLogger(DynamoPathManager.Instance.Logs);
            dynSettings.DynamoLogger = logger;

            var updateManager = new UpdateManager.UpdateManager(logger);

            // If a command file path is not specified or if it is invalid, then fallback.
            if (string.IsNullOrEmpty(commandFilePath) || (File.Exists(commandFilePath) == false))
            {
                controller = new DynamoController("None", updateManager,
                    new DefaultWatchHandler(), Dynamo.PreferenceSettings.Load(), corePath);

                controller.DynamoViewModel = new DynamoViewModel(controller, null);
            }
            else
            {
                controller = new DynamoController("None", updateManager,
                 new DefaultWatchHandler(), Dynamo.PreferenceSettings.Load(), corePath);

                controller.DynamoViewModel = new DynamoViewModel(controller, commandFilePath);
            }

            controller.VisualizationManager = new VisualizationManager();
            return controller;
        }
示例#24
0
 void updateManager_UpdateDownloaded(object sender, UpdateManager.UpdateDownloadedEventArgs e)
 {
     UpdateManager.QuitAndInstallUpdate();
 }
示例#25
0
        public static UpdateManager CreateInstance(DynamoLogger logger)
        {
            if (self != null) return self;

            if (null == logger)
                throw new ArgumentNullException("logger", "Unspecified logger (61578808A807)");

            self = new UpdateManager(logger);

            return self;
        }
示例#26
0
        public void NoUpdateAvailableWhenUpdateInfoIsNotYetDownloaded()
        {
            var updateManager = new DynUpdateManager(NewConfiguration());

            Assert.IsFalse(updateManager.IsUpdateAvailable);
        }
示例#27
0
 void Instance_UpdateDownloaded(object sender, UpdateManager.UpdateDownloadedEventArgs e)
 {
     RaisePropertyChanged("Version");
     RaisePropertyChanged("UpToDate");
 }
示例#28
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);
        }