private void ShowNodePublishInfo(object funcDef) { if (funcDef is List <CustomNodeDefinition> ) { var fs = funcDef as List <CustomNodeDefinition>; foreach (var f in fs) { var pkg = dynamoViewModel.Model.Loader.PackageLoader.GetOwnerPackage(f); if (dynamoViewModel.Model.Loader.PackageLoader.GetOwnerPackage(f) != null) { var m = MessageBox.Show("The node is part of the dynamo package called \"" + pkg.Name + "\" - do you want to submit a new version of this package? \n\nIf not, this node will be moved to the new package you are creating.", "Package Warning", MessageBoxButton.YesNo, MessageBoxImage.Question); if (m == MessageBoxResult.Yes) { var pkgVm = new PackageViewModel(dynamoViewModel, pkg); pkgVm.PublishNewPackageVersionCommand.Execute(); return; } } } var newPkgVm = new PublishPackageViewModel(this.dynamoViewModel); newPkgVm.CustomNodeDefinitions = fs; this.dynamoViewModel.OnRequestPackagePublishDialog(newPkgVm); } else { dynamoViewModel.Model.Logger.Log("Failed to obtain function definition from node."); } }
private void ShowNodePublishInfo(ICollection <Tuple <CustomNodeInfo, CustomNodeDefinition> > funcDefs) { foreach (var f in funcDefs) { var pkg = DynamoViewModel.Model.PackageLoader.GetOwnerPackage(f.Item1); if (DynamoViewModel.Model.PackageLoader.GetOwnerPackage(f.Item1) != null) { var m = MessageBox.Show( "The node is part of the dynamo package called \"" + pkg.Name + "\" - do you want to submit a new version of this package? \n\nIf not, this node will be moved to the new package you are creating.", "Package Warning", MessageBoxButton.YesNo, MessageBoxImage.Question); if (m == MessageBoxResult.Yes) { var pkgVm = new PackageViewModel(DynamoViewModel, pkg); pkgVm.PublishNewPackageVersionCommand.Execute(); return; } } } var newPkgVm = new PublishPackageViewModel(DynamoViewModel) { CustomNodeDefinitions = funcDefs.Select(pair => pair.Item2).ToList() }; DynamoViewModel.OnRequestPackagePublishDialog(newPkgVm); }
public void ReturnsSameAsInputForUnknownMessages() { var message = "Unknown error"; var actual = PublishPackageViewModel.TranslatePackageManagerError(message); Assert.AreEqual(message, actual); }
private void ShowNodePublishInfo(ICollection <Tuple <CustomNodeInfo, CustomNodeDefinition> > funcDefs) { foreach (var f in funcDefs) { var pmExtension = DynamoViewModel.Model.GetPackageManagerExtension(); var pkg = pmExtension.PackageLoader.GetOwnerPackage(f.Item1); if (pkg != null) { var m = MessageBox.Show(String.Format(Resources.MessageSubmitSameNamePackage, DynamoViewModel.BrandingResourceProvider.ProductName, pkg.Name), Resources.PackageWarningMessageBoxTitle, MessageBoxButton.YesNo, MessageBoxImage.Question); if (m == MessageBoxResult.Yes) { var pkgVm = new PackageViewModel(DynamoViewModel, pkg); pkgVm.PublishNewPackageVersionCommand.Execute(); return; } } } var newPkgVm = new PublishPackageViewModel(DynamoViewModel) { CustomNodeDefinitions = funcDefs.Select(pair => pair.Item2).ToList() }; DynamoViewModel.OnRequestPackagePublishDialog(newPkgVm); }
public void AddingDyfRaisesCanExecuteChangeOnDelegateCommand() { var vm = new PublishPackageViewModel(ViewModel); ViewModel.OnRequestPackagePublishDialog(vm); //find a customnode to add to the package string packagedirectory = Path.Combine(TestDirectory, "pkgs"); var packages = Directory.EnumerateDirectories(packagedirectory); var first = Path.GetFullPath(packages.First()); string dyfpath = Path.Combine(first, "dyf"); var customnodes = Directory.GetFiles(dyfpath); var firstnode = customnodes.First(); Console.WriteLine("add node at" + firstnode + "to package"); var canExecuteChangedFired = 0; vm.SubmitCommand.CanExecuteChanged += ((o, e) => { canExecuteChangedFired++; }); //now add a customnode to the package vm.AddFile(firstnode); //assert that canExecute changed was fired one time Assert.AreEqual(canExecuteChangedFired, 1); }
public void NewPackageVersionUpload_DoesNotThrowExceptionWhenDLLIsLoadedSeveralTimes() { string packagesDirectory = Path.Combine(TestDirectory, "pkgs"); var pathManager = new Mock <Dynamo.Interfaces.IPathManager>(); pathManager.SetupGet(x => x.PackagesDirectories).Returns(() => new List <string> { packagesDirectory }); var loader = new PackageLoader(pathManager.Object); loader.LoadAll(new LoadPackageParams { Preferences = ViewModel.Model.PreferenceSettings }); PublishPackageViewModel vm = null; var package = loader.LocalPackages.FirstOrDefault(x => x.Name == "Custom Rounding"); Assert.DoesNotThrow(() => { vm = PublishPackageViewModel.FromLocalPackage(ViewModel, package); }); Assert.AreEqual(PackageUploadHandle.State.Error, vm.UploadState); }
public void OnRequestPackagePublishDialog(PublishPackageViewModel vm) { if (RequestPackagePublishDialog != null) { RequestPackagePublishDialog(vm); } }
public void SetsErrorState() { //open a dyf file and modify it string packagedirectory = Path.Combine(TestDirectory, "pkgs"); var packages = Directory.EnumerateDirectories(packagedirectory); var first = Path.GetFullPath(packages.FirstOrDefault(x => Path.GetFileName(x).Equals("Custom Rounding"))); string dyfpath = Path.Combine(first, "dyf"); var customnodes = Directory.GetFiles(dyfpath); var firstnode = customnodes.First(); OpenModel(firstnode); //add a preset so that customnode has changes that are unsaved GetModel().CurrentWorkspace.AddPreset("a useless preset", "some thing that will modify the definition", new List <Guid>() { GetModel().CurrentWorkspace.Nodes.First().GUID }); Assert.IsTrue(GetModel().CurrentWorkspace.HasUnsavedChanges); //now try to upload this file var vm = new PublishPackageViewModel(this.ViewModel); ViewModel.OnRequestPackagePublishDialog(vm); //now add a customnode to the package vm.AddFile(firstnode); Console.WriteLine("add node at" + firstnode + "to package"); vm.PublishLocallyCommand.Execute(); //assert that we have not uploaded the file or indicated that we have Assert.AreNotEqual(vm.UploadState, PackageUploadHandle.State.Uploaded); Console.WriteLine(vm.ErrorString); }
private void PublishNewPackage(bool isTestMode) { Model.RefreshCustomNodesFromDirectory(dynamoViewModel.Model.CustomNodeManager, isTestMode); var vm = PublishPackageViewModel.FromLocalPackage(dynamoViewModel, Model); vm.IsNewVersion = false; dynamoViewModel.OnRequestPackagePublishDialog(vm); }
public void ReturnsTranslationForPackageAlreadyExistsError() { var message = "A package with the given name and engine already exists."; var actual = PublishPackageViewModel.TranslatePackageManagerError(message); var expected = "A package with the given name already exists."; Assert.AreEqual(expected, actual); }
public void ReturnsTranslationForUserIsNotAMaintainerError() { var message = "The user sending the new package version, DynamoTeam, is not a maintainer of the package Clockwork for Dynamo 1.x"; var actual = PublishPackageViewModel.TranslatePackageManagerError(message); var expected = "The current user, 'DynamoTeam', is not a maintainer of the package 'Clockwork for Dynamo 1.x'."; Assert.AreEqual(expected, actual); }
public void CanOpenPackagePublishDialogAndWindowIsOwned() { var l = new PublishPackageViewModel(dynSettings.PackageManagerClient); Vm.OnRequestPackagePublishDialog(l); AssertWindowOwnedByDynamoView <PackageManagerPublishView>(); }
public void CanOpenPackagePublishDialogAndWindowIsOwned() { var l = new PublishPackageViewModel(ViewModel); ViewModel.OnRequestPackagePublishDialog(l); AssertWindowOwnedByDynamoView <PublishPackageView>(); }
public void PackagePublishWindowClosesWithDynamo() { var l = new PublishPackageViewModel(ViewModel); ViewModel.OnRequestPackagePublishDialog(l); AssertWindowOwnedByDynamoView <PublishPackageView>(); AssertWindowClosedWithDynamoView <PublishPackageView>(); }
private void PublishNewPackageVersion() { this.Model.RefreshCustomNodesFromDirectory(this.dynamoViewModel.Model.CustomNodeManager); var vm = PublishPackageViewModel.FromLocalPackage(dynamoViewModel, this.Model); vm.IsNewVersion = true; dynamoViewModel.OnRequestPackagePublishDialog(vm); }
public void PackagePublishWindowClosesWithDynamo() { var l = new PublishPackageViewModel(dynSettings.PackageManagerClient); Vm.OnRequestPackagePublishDialog(l); AssertWindowOwnedByDynamoView <PackageManagerPublishView>(); AssertWindowClosedWithDynamoView <PackageManagerPublishView>(); }
public void CannotCreateDuplicatePackagePublishDialogs() { var l = new PublishPackageViewModel(ViewModel); for (var i = 0; i < 10; i++) { ViewModel.OnRequestPackagePublishDialog(l); } AssertWindowOwnedByDynamoView <PublishPackageView>(); }
void _vm_RequestShowPackageManagerPublish(PublishPackageViewModel model) { if (_pubPkgView == null) { _pubPkgView = new PackageManagerPublishView(model); _pubPkgView.Closed += (sender, args) => _pubPkgView = null; _pubPkgView.Show(); } _pubPkgView.Focus(); }
public void CannotCreateDuplicatePackagePublishDialogs() { var l = new PublishPackageViewModel(dynSettings.PackageManagerClient); for (var i = 0; i < 10; i++) { Vm.OnRequestPackagePublishDialog(l); } AssertWindowOwnedByDynamoView <PackageManagerPublishView>(); }
/// <summary> /// Class constructor /// </summary> public DynamoController(ExecutionEnvironment env, Type viewModelType, string context) { dynSettings.Controller = this; this.Context = context; //Start heartbeat reporting Services.InstrumentationLogger.Start(); //create the view model to which the main window will bind //the DynamoModel is created therein this.DynamoViewModel = (DynamoViewModel)Activator.CreateInstance(viewModelType, new object[] { this }); // custom node loader string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string pluginsPath = Path.Combine(directory, "definitions"); CustomNodeManager = new CustomNodeManager(pluginsPath); SearchViewModel = new SearchViewModel(); PackageManagerClient = new PackageManagerClient(); dynSettings.PackageManagerClient = PackageManagerClient; PublishPackageViewModel = new PublishPackageViewModel(PackageManagerClient); dynSettings.PackageLoader = new PackageLoader(); dynSettings.PackageLoader.DoCachedPackageUninstalls(); dynSettings.PackageLoader.LoadPackages(); FSchemeEnvironment = env; DynamoViewModel.Model.CurrentSpace.X = DynamoView.CANVAS_OFFSET_X; DynamoViewModel.Model.CurrentSpace.Y = DynamoView.CANVAS_OFFSET_Y; dynSettings.Controller.DynamoViewModel.Log(String.Format( "Dynamo -- Build {0}", Assembly.GetExecutingAssembly().GetName().Version)); DynamoLoader.ClearCachedAssemblies(); DynamoLoader.LoadBuiltinTypes(); //run tests if (FScheme.RunTests(dynSettings.Controller.DynamoViewModel.Log)) { dynSettings.Controller.DynamoViewModel.Log("All Tests Passed. Core library loaded OK."); } NodeSubmittedForRendering += new EventHandler(Controller_NodeSubmittedForRendering); NodeRemovedFromRendering += new EventHandler(Controller_NodeRemovedFromRendering); }
void _vm_RequestRequestPackageManagerPublish(PublishPackageViewModel model) { if (_pubPkgView == null) { _pubPkgView = new PackageManagerPublishView(model); _pubPkgView.Closed += (sender, args) => _pubPkgView = null; _pubPkgView.Show(); if (_pubPkgView.IsLoaded && this.IsLoaded) { _pubPkgView.Owner = this; } } _pubPkgView.Focus(); }
public void CanPublishLateInitializedJsonCustomNode() { string nodePath = Path.Combine(TestDirectory, "core", "CustomNodes", "jsonCustomNode.dyf"); //add this customNode to the package without opening it. var vm = new PublishPackageViewModel(this.ViewModel); ViewModel.OnRequestPackagePublishDialog(vm); vm.AddFile(nodePath); //assert we don't raise any exceptions during getAllFiles //- this will check the customNode has no unsaved changes. Assert.AreEqual(1, vm.CustomNodeDefinitions.Count); Assert.DoesNotThrow(() => { vm.GetAllFiles(); }); Assert.AreEqual(nodePath, vm.GetAllFiles().First()); }
public void NewPackageVersionUpload_DoesNotThrowExceptionWhenDLLIsLoadedSeveralTimes() { string packagesDirectory = Path.Combine(TestDirectory, "pkgs"); var loader = new PackageLoader(packagesDirectory); loader.LoadAll(new LoadPackageParams { Preferences = ViewModel.Model.PreferenceSettings }); PublishPackageViewModel vm = null; Assert.DoesNotThrow(() => { vm = PublishPackageViewModel.FromLocalPackage(ViewModel, loader.LocalPackages.First()); }); Assert.AreEqual(PackageUploadHandle.State.Error, vm.UploadState); }
void DynamoViewModelRequestRequestPackageManagerPublish(PublishPackageViewModel model) { if (_pubPkgView == null) { _pubPkgView = new PublishPackageView(model) { Owner = this, WindowStartupLocation = WindowStartupLocation.CenterOwner }; _pubPkgView.Closed += (sender, args) => _pubPkgView = null; _pubPkgView.Show(); if (_pubPkgView.IsLoaded && IsLoaded) { _pubPkgView.Owner = this; } } _pubPkgView.Focus(); }
[Category("TechDebt")] //when a package is published - it does not load its customNodes. This may be intentional. public void PublishingACustomNodeSetsPackageInfoCorrectly_() { var cnworkspace = this.GetModel().CustomNodeManager.CreateCustomNode("nodeToBePublished", "somecategory", "publish this node") as CustomNodeWorkspaceModel; var inputNode = new Symbol(); inputNode.InputSymbol = "input;"; cnworkspace.AddAndRegisterNode(inputNode); var tempPath = Path.Combine(TempFolder, "nodeToBePublished.dyf"); cnworkspace.Save(tempPath, false, this.GetModel().EngineController); Assert.IsNull(GetModel().CustomNodeManager.NodeInfos[cnworkspace.CustomNodeId].PackageInfo); Assert.IsFalse(GetModel().CustomNodeManager.NodeInfos[cnworkspace.CustomNodeId].IsPackageMember); //now lets publish this node as a local package. var newPkgVm = new PublishPackageViewModel(ViewModel) { CustomNodeDefinitions = new List <CustomNodeDefinition>() { cnworkspace.CustomNodeDefinition } }; newPkgVm.Name = "PublishingACustomNodeSetsPackageInfoCorrectly"; newPkgVm.MajorVersion = "0"; newPkgVm.MinorVersion = "0"; newPkgVm.BuildVersion = "1"; newPkgVm.PublishLocallyCommand.Execute(); Assert.IsTrue(GetModel().GetPackageManagerExtension().PackageLoader.LocalPackages.Any (x => x.Name == "PublishingACustomNodeSetsPackageInfoCorrectly" && x.Loaded == true && x.LoadedCustomNodes.Count == 1)); Assert.AreEqual(new PackageInfo("PublishingACustomNodeSetsPackageInfoCorrectly", new Version(0, 0, 1)) , GetModel().CustomNodeManager.NodeInfos[cnworkspace.CustomNodeId].PackageInfo); Assert.IsFalse(GetModel().CustomNodeManager.NodeInfos[cnworkspace.CustomNodeId].IsPackageMember); }
private void ShowNodePublishInfo() { var newPkgVm = new PublishPackageViewModel(DynamoViewModel); DynamoViewModel.OnRequestPackagePublishDialog(newPkgVm); }
private void PublishExecute() { if (!NetworkInterface.GetIsNetworkAvailable()) { UIServices.Show(Resources.NoNetworkConnection, MessageLevel.Warning); return; } if (!this.IsValid) { UIServices.Show(Resources.PackageHasNoFile, MessageLevel.Warning); return; } string storedKey = _settingsManager.ReadApiKeyFromSettingFile(); var publishPackageViewModel = new PublishPackageViewModel(_settingsManager.PublishPackageLocation, this) { PublishKey = storedKey }; _uiServices.OpenPublishDialog(publishPackageViewModel); string newKey = publishPackageViewModel.PublishKey; if (!String.IsNullOrEmpty(newKey)) { _settingsManager.WriteApiKeyToSettingFile(newKey); } }
private void PublishExecute() { if (!NetworkInterface.GetIsNetworkAvailable()) { UIServices.Show(Resources.NoNetworkConnection, MessageLevel.Warning); return; } // validate the package to see if there is any error before actually creating the package. PackageIssue firstIssue = Validate().FirstOrDefault(p => p.Level == PackageIssueLevel.Error); if (firstIssue != null) { UIServices.Show( Resources.PackageCreationFailed + Environment.NewLine + Environment.NewLine + firstIssue.Description, MessageLevel.Warning); return; } using (var mruSourceManager = new MruPackageSourceManager( new PublishSourceSettings(_settingsManager))) { var publishPackageViewModel = new PublishPackageViewModel( mruSourceManager, _settingsManager, this); _uiServices.OpenPublishDialog(publishPackageViewModel); } }