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 CanOpenDocumentationBrowserWhenMoreInformationIsClicked() { DebugModes.LoadDebugModesStatusFromConfig(Path.Combine(GetTestDirectory(ExecutingDirectory), "DynamoCoreWpfTests", "python2ObsoleteMode.config")); DynamoModel.IsTestMode = false; // Act // open file var examplePath = Path.Combine(UnitTestBase.TestDirectory, @"core\python", "python.dyn"); Open(examplePath); DispatcherUtil.DoEvents(); var ironPythonDialog = this.View.GetChildrenWindowsOfType <IronPythonInfoDialog>().First(); var viewExtensionTabsBeforeBtnClick = this.View.ExtensionTabItems.Count; DispatcherUtil.DoEvents(); ironPythonDialog.MoreInformationBtn.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); var hasDocumentationBrowserTab = this.View.ExtensionTabItems .Any(x => x.Header.ToString() == "Documentation Browser"); DispatcherUtil.DoEvents(); // Assert Assert.AreEqual(viewExtensionTabsBeforeBtnClick + 1, this.View.ExtensionTabItems.Count); Assert.IsTrue(hasDocumentationBrowserTab); DynamoModel.IsTestMode = true; DispatcherUtil.DoEvents(); }
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 WillOnlyLogNotificationWhenAddingAnIronPythonNodeOnce() { DebugModes.LoadDebugModesStatusFromConfig(Path.Combine(GetTestDirectory(ExecutingDirectory), "DynamoCoreWpfTests", "python2ObsoleteMode.config")); // Arrange string pythonNodeName = "Python Script"; raisedEvents = new List <string>(); // Act // open file this.ViewModel.Model.Logger.NotificationLogged += Logger_NotificationLogged; var nodesCountBeforeNodeAdded = this.ViewModel.CurrentSpace.Nodes.Count(); this.ViewModel.ExecuteCommand(new DynamoModel. CreateNodeCommand(Guid.NewGuid().ToString(), pythonNodeName, 0, 0, false, false)); this.ViewModel.ExecuteCommand(new DynamoModel. CreateNodeCommand(Guid.NewGuid().ToString(), pythonNodeName, 0, 0, false, false)); DispatcherUtil.DoEvents(); var nodesCountAfterNodeAdded = this.ViewModel.CurrentSpace.Nodes.Count(); // Assert Assert.AreEqual(nodesCountBeforeNodeAdded + 2, nodesCountAfterNodeAdded); Assert.AreEqual(raisedEvents.Count, 1); Assert.IsTrue(raisedEvents.Any(x => x.Contains(nameof(PythonMigrationViewExtension)))); raisedEvents.Clear(); this.ViewModel.Model.Logger.NotificationLogged -= Logger_NotificationLogged; DispatcherUtil.DoEvents(); }
public void WillDisplayDialogWhenOpeningGraphWithIronPythonNodes() { DebugModes.LoadDebugModesStatusFromConfig(Path.Combine(GetTestDirectory(ExecutingDirectory), "DynamoCoreWpfTests", "python2ObsoleteMode.config")); DynamoModel.IsTestMode = false; // Act // open file Open(@"core\python\python.dyn"); var isIronPythonDialogOpen = this.View.OwnedWindows .Cast <Window>() .Any(x => x.GetType() == typeof(IronPythonInfoDialog)); // Assert Assert.IsTrue(isIronPythonDialogOpen); DynamoModel.IsTestMode = true; DispatcherUtil.DoEvents(); }
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); } }
public void WillDisplayDialogWhenCustomNodeInsideWorkspaceHasIronPythonNode() { DebugModes.LoadDebugModesStatusFromConfig(Path.Combine(GetTestDirectory(ExecutingDirectory), "DynamoCoreWpfTests", "python2ObsoleteMode.config")); DynamoModel.IsTestMode = false; // open file var examplePath = Path.Combine(UnitTestBase.TestDirectory, @"core\python", "PythonCustomNodeHomeWorkspace.dyn"); Open(examplePath); DispatcherUtil.DoEvents(); var ironPythonDialog = this.View.GetChildrenWindowsOfType <IronPythonInfoDialog>().First(); // Assert that the IronPython dialog is shown. Assert.IsNotNull(ironPythonDialog); Assert.IsTrue(ironPythonDialog.IsLoaded); DynamoModel.IsTestMode = true; DispatcherUtil.DoEvents(); }
public void WillNotDisplayIronPythonDialogAgainWhenDoNotShowAgainSettingIsChecked() { DebugModes.LoadDebugModesStatusFromConfig(Path.Combine(GetTestDirectory(ExecutingDirectory), "DynamoCoreWpfTests", "python2ObsoleteMode.config")); DynamoModel.IsTestMode = false; // Arrange var examplePathIronPython = Path.Combine(UnitTestBase.TestDirectory, @"core\python", "python.dyn"); //Disable iron python alerts ViewModel.IsIronPythonDialogDisabled = true; // Act // open file Open(examplePathIronPython); DispatcherUtil.DoEvents(); var ironPythonDialog = this.View.GetChildrenWindowsOfType <IronPythonInfoDialog>(); Assert.IsEmpty(ironPythonDialog); Assert.AreEqual(0, ironPythonDialog.Count()); DynamoModel.IsTestMode = true; DispatcherUtil.DoEvents(); }
public void WillNotDisplayDialogWhenOpeningGraphWithIronPythonNodesSecondTimeInSameSession() { DebugModes.LoadDebugModesStatusFromConfig(Path.Combine(GetTestDirectory(ExecutingDirectory), "DynamoCoreWpfTests", "python2ObsoleteMode.config")); DynamoModel.IsTestMode = false; // Arrange var examplePathIronPython = Path.Combine(UnitTestBase.TestDirectory, @"core\python", "python.dyn"); var examplePathEmptyFile = Path.Combine(UnitTestBase.TestDirectory, @"core\Home.dyn"); // Act // open file Open(examplePathIronPython); var ironPythonWorkspaceId = this.ViewModel.CurrentSpace.Guid; DispatcherUtil.DoEvents(); var ironPythonDialog = this.View.GetChildrenWindowsOfType <IronPythonInfoDialog>().First(); Assert.IsNotNull(ironPythonDialog); Assert.IsTrue(ironPythonDialog.IsLoaded); ironPythonDialog.OkBtn.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); DispatcherUtil.DoEvents(); // Open empty file before open the the IronPython file again Open(examplePathEmptyFile); Assert.AreNotEqual(ironPythonWorkspaceId, this.ViewModel.CurrentSpace.Guid); DispatcherUtil.DoEvents(); Open(examplePathIronPython); Assert.AreEqual(ironPythonWorkspaceId, this.ViewModel.CurrentSpace.Guid); var secondGraphIronPythonDialog = this.View.GetChildrenWindowsOfType <IronPythonInfoDialog>(); DispatcherUtil.DoEvents(); // Assert Assert.AreEqual(0, secondGraphIronPythonDialog.Count()); DynamoModel.IsTestMode = true; DispatcherUtil.DoEvents(); }
public void VerifyDynamoLoadingOnOpeningWorkspaceWithMissingCustomNodes() { List <string> dependenciesList = new List <string>() { "MeshToolkit", "Clockwork for Dynamo 1.x", "Clockwork for Dynamo 2.x", "Dynamo Samples" }; DebugModes.LoadDebugModesStatusFromConfig(Path.Combine(GetTestDirectory(ExecutingDirectory), "DynamoCoreWpfTests", "python2ObsoleteMode.config")); DynamoModel.IsTestMode = false; var examplePath = Path.Combine(@"core\packageDependencyTests\PackageDependencyStates.dyn"); Open(examplePath); Assert.AreEqual(1, View.ExtensionTabItems.Count); var workspaceViewExtension = (WorkspaceDependencyViewExtension)View.viewExtensionManager.ViewExtensions .Where(x => x.Name.Equals("Workspace References")).FirstOrDefault(); foreach (PackageDependencyRow packageDependencyRow in workspaceViewExtension.DependencyView.dataRows) { var dependencyInfo = packageDependencyRow.DependencyInfo; Assert.Contains(dependencyInfo.Name, dependenciesList); } }