public void TestLoadNoDebugModes() { string configPath = Path.Combine(TestDirectory, "testDebugModes", "noDebugModes.config"); XmlDocument xml = new XmlDocument(); xml.Load(configPath); var debugItems = xml.DocumentElement.SelectNodes("DebugMode"); Assert.IsEmpty(debugItems); var testDebugModeNames = new List <string>() { "test5", "test6" }; // Register the test debug modes. foreach (var dbgModeName in testDebugModeNames) { DebugModes.AddDebugMode(dbgModeName, dbgModeName); } // Load the enabled/disabled status from the test config file. DebugModes.LoadDebugModesStatusFromConfig(configPath); foreach (var dbgModeName in testDebugModeNames) { Assert.IsNotNull(DebugModes.GetDebugMode(dbgModeName)); Assert.AreEqual(DebugModes.IsEnabled(dbgModeName), false); } }
public void TestMissingConfig() { Type dbgModesType = typeof(DebugModes); var testDebugModeNames = new List <string>() { "test7", "test8" }; // Register the test debug modes. foreach (var dbgModeName in testDebugModeNames) { DebugModes.AddDebugMode(dbgModeName, dbgModeName); } // Load the enabled/disabled status from the test config file. string configPath = Path.Combine(TestDirectory, "testDebugModes", "missing.config"); DebugModes.LoadDebugModesStatusFromConfig(configPath); foreach (var dbgModeName in testDebugModeNames) { Assert.IsNotNull(DebugModes.GetDebugMode(dbgModeName)); Assert.AreEqual(DebugModes.IsEnabled(dbgModeName), false); } }
public void TestLoadNoDebugModes() { string configPath = Path.Combine(TestDirectory, "testDebugModes", "noDebugModes.config"); XmlDocument xml = new XmlDocument(); xml.Load(configPath); var debugItems = xml.DocumentElement.SelectNodes("DebugMode"); Assert.IsEmpty(debugItems); Type dbgModesType = typeof(DebugModes); var testDebugModeNames = new List <string>() { "test5", "test6" }; // Register the test debug modes. MethodInfo addDebugMode = dbgModesType.GetMethod("AddDebugMode", BindingFlags.Static | BindingFlags.NonPublic); foreach (var dbgModeName in testDebugModeNames) { addDebugMode.Invoke(null, new object[] { dbgModeName, dbgModeName }); } // Load the enabled/disabled status from the test config file. dbgModesType.GetMethod("LoadDebugModesStatusFromConfig", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[] { configPath }); foreach (var dbgModeName in testDebugModeNames) { Assert.IsNotNull(DebugModes.GetDebugMode(dbgModeName)); Assert.AreEqual(DebugModes.IsEnabled(dbgModeName), false); } }
public void TestMissingConfig() { Type dbgModesType = typeof(DebugModes); var testDebugModeNames = new List <string>() { "test7", "test8" }; // Register the test debug modes. MethodInfo addDebugMode = dbgModesType.GetMethod("AddDebugMode", BindingFlags.Static | BindingFlags.NonPublic); foreach (var dbgModeName in testDebugModeNames) { addDebugMode.Invoke(null, new object[] { dbgModeName, dbgModeName }); } // Load the enabled/disabled status from the test config file. string configPath = Path.Combine(TestDirectory, "testDebugModes", "missing.config"); dbgModesType.GetMethod("LoadDebugModesStatusFromConfig", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[] { configPath }); foreach (var dbgModeName in testDebugModeNames) { Assert.IsNotNull(DebugModes.GetDebugMode(dbgModeName)); Assert.AreEqual(DebugModes.IsEnabled(dbgModeName), false); } }
internal void UnmarkForUninstall(IPreferences prefs) { MarkedForUninstall = false; if (DebugModes.IsEnabled("DynamoPackageStates")) { // Should this be a "Loaded state" or something else ? // Or maybe state should only be set when trying to Load the package...not here. PackageState = PackageStates.Loaded; } prefs.PackageDirectoriesToUninstall.RemoveAll(x => x.Equals(RootDirectory)); }
internal void MarkForUninstall(IPreferences prefs) { MarkedForUninstall = true; if (DebugModes.IsEnabled("DynamoPackageStates")) { PackageState = PackageStates.PendingUnload; } if (!prefs.PackageDirectoriesToUninstall.Contains(RootDirectory)) { prefs.PackageDirectoriesToUninstall.Add(RootDirectory); } }
public void TestLoadDebugModes() { string configPath = Path.Combine(TestDirectory, "testDebugModes", "debugModes.config"); XmlDocument xml = new XmlDocument(); xml.Load(configPath); var debugItems = xml.DocumentElement.SelectNodes("DebugMode"); var testDebugModes = new Dictionary <string, bool>(); foreach (XmlNode item in debugItems) { testDebugModes[item.Attributes["name"].Value] = bool.Parse(item.Attributes["enabled"].Value); } Type dbgModesType = typeof(DebugModes); // Register the test debug modes. MethodInfo addDebugMode = dbgModesType.GetMethod("AddDebugMode", BindingFlags.Static | BindingFlags.NonPublic); foreach (var dbgModeName in testDebugModes) { addDebugMode.Invoke(null, new object[] { dbgModeName.Key, dbgModeName.Key }); } // Load the enabled/disabled status from the test config file. dbgModesType.GetMethod("LoadDebugModesStatusFromConfig", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[] { configPath }); foreach (var item in testDebugModes) { var dbgMode = DebugModes.GetDebugMode(item.Key); Assert.IsNotNull(dbgMode); Assert.AreEqual(dbgMode.IsEnabled, item.Value); } var forceEnabled = false; foreach (var item in testDebugModes) { DebugModes.SetDebugModeEnabled(item.Key, forceEnabled); } foreach (var item in testDebugModes) { Assert.AreEqual(DebugModes.IsEnabled(item.Key), forceEnabled); } }
internal void MarkForUninstall(IPreferences prefs) { MarkedForUninstall = true; if (DebugModes.IsEnabled("DynamoPackageStates")) { PackageState = PackageStates.PendingUnload; } else { RaisePropertyChanged(nameof(EnableOldMarkedForUnistallState)); } if (!prefs.PackageDirectoriesToUninstall.Contains(RootDirectory)) { prefs.PackageDirectoriesToUninstall.Add(RootDirectory); } }
public void TestLoadDebugModes() { string configPath = Path.Combine(TestDirectory, "testDebugModes", "debugModes.config"); XmlDocument xml = new XmlDocument(); xml.Load(configPath); var debugItems = xml.DocumentElement.SelectNodes("DebugMode"); var testDebugModes = new Dictionary <string, bool>(); foreach (XmlNode item in debugItems) { testDebugModes[item.Attributes["name"].Value] = bool.Parse(item.Attributes["enabled"].Value); } // Register the test debug modes. foreach (var dbgModeName in testDebugModes) { DebugModes.AddDebugMode(dbgModeName.Key, dbgModeName.Key); } // Load the enabled/disabled status from the test config file. DebugModes.LoadDebugModesStatusFromConfig(configPath); foreach (var item in testDebugModes) { var dbgMode = DebugModes.GetDebugMode(item.Key); Assert.IsNotNull(dbgMode); Assert.AreEqual(dbgMode.IsEnabled, item.Value); } var forceEnabled = false; foreach (var item in testDebugModes) { DebugModes.SetDebugModeEnabled(item.Key, forceEnabled); } foreach (var item in testDebugModes) { Assert.AreEqual(DebugModes.IsEnabled(item.Key), forceEnabled); } }
/// <summary> /// Check Dynamo package install state /// </summary> /// <param name="packageDownloadHandle">package download handle</param> /// <param name="downloadPath">package download path</param> internal void SetPackageState(PackageDownloadHandle packageDownloadHandle, string downloadPath) { Package dynPkg; if (packageDownloadHandle.Extract(DynamoViewModel.Model, downloadPath, out dynPkg)) { PackageManagerExtension.PackageLoader.LoadPackages(new List <Package> { dynPkg }); packageDownloadHandle.DownloadState = PackageDownloadHandle.State.Installed; if (DebugModes.IsEnabled("DynamoPackageStates")) { // Temporary location for setting the package state. // Should be moved somewhere with more visibility into possible errors. dynPkg.PackageState = Package.PackageStates.Loaded; } } else { packageDownloadHandle.DownloadState = PackageDownloadHandle.State.Error; packageDownloadHandle.Error(Resources.MessageInvalidPackage); } }