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); }
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 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()); }