diff --git a/test/DynamoCoreWpfTests/PackageManager/PackageManagerUITests.cs b/test/DynamoCoreWpfTests/PackageManager/PackageManagerUITests.cs index 82cd1f00833..b24af6612a0 100644 --- a/test/DynamoCoreWpfTests/PackageManager/PackageManagerUITests.cs +++ b/test/DynamoCoreWpfTests/PackageManager/PackageManagerUITests.cs @@ -1,12 +1,3 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Controls.Primitives; using Dynamo.Core; using Dynamo.Extensions; using Dynamo.PackageManager; @@ -22,6 +13,15 @@ using Greg.Responses; using Moq; using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; using SystemTestServices; namespace DynamoCoreWpfTests.PackageManager @@ -107,7 +107,7 @@ public void CanOpenPackagePublishDialogAndWindowIsOwned() AssertWindowOwnedByDynamoView(); } - [Test, Ignore("Unknown reason")] + [Test] public void CannotCreateDuplicatePackagePublishDialogs() { var l = new PublishPackageViewModel(ViewModel); @@ -116,7 +116,7 @@ public void CannotCreateDuplicatePackagePublishDialogs() ViewModel.OnRequestPackagePublishDialog(l); } - AssertWindowOwnedByDynamoView(); + AssertWindowOwnedByDynamoView(); } [Test] @@ -129,6 +129,135 @@ public void PackagePublishWindowClosesWithDynamo() AssertWindowClosedWithDynamoView(); } + + [Test] + public void PackagePublishKeywordPropertyAllowsSpaces() + { + // Arrange + var singleSpace = " "; + var doubleSpace = " "; + var singleWord = "support"; + var doubleWord = "support mep"; + var doubleWordMultipleSpaces = "support mep"; + var commaDelimetedWords = "support,mep"; + + var l = new PublishPackageViewModel(ViewModel); + + // Act/Assert + l.Keywords = singleSpace; + Assert.AreEqual(singleSpace, l.Keywords); + Assert.AreEqual(0, l.KeywordList.Count()); + + l.Keywords = doubleSpace; + Assert.AreEqual(singleSpace, l.Keywords); + Assert.AreEqual(0, l.KeywordList.Count()); + + l.Keywords = singleWord; + Assert.AreEqual(singleWord, l.Keywords); + Assert.AreEqual(1, l.KeywordList.Count()); + + l.Keywords = doubleWord; + Assert.AreEqual(doubleWord, l.Keywords); + Assert.AreEqual(2, l.KeywordList.Count()); + + l.Keywords = doubleWordMultipleSpaces; + Assert.AreEqual(doubleWord, l.Keywords); + Assert.AreEqual(2, l.KeywordList.Count()); + + l.Keywords = commaDelimetedWords; + Assert.AreEqual(commaDelimetedWords.Replace(',', ' '), l.Keywords); + Assert.AreEqual(2, l.KeywordList.Count()); + } + + [Test] + public void PackagePublishNumericUpDownAllowsOnlyPositiveIntegerValues() + { + // Arrange + var updownControl = new NumericUpDownControl(); + + // Assert negavie + var isValidOutput = updownControl.IsValidInput("l"); + Assert.IsFalse(isValidOutput, "Should not allow letters in numeric input."); + + isValidOutput = updownControl.IsValidInput("-1"); + Assert.IsFalse(isValidOutput, "Should not allow negative integers in numeric input."); + + isValidOutput = updownControl.IsValidInput("1.0"); + Assert.IsFalse(isValidOutput, "Should not allow fractional input."); + + isValidOutput = updownControl.IsValidInput(" "); + Assert.IsFalse(isValidOutput, "Should not allow space input values."); + + isValidOutput = updownControl.IsValidInput(" 1"); + Assert.IsFalse(isValidOutput, "Should not allow space input values."); + + // Assert positive + isValidOutput = updownControl.IsValidInput("0"); + Assert.IsTrue(isValidOutput, "Should allow 0 in numeric input."); + + isValidOutput = updownControl.IsValidInput("1"); + Assert.IsTrue(isValidOutput, "Should allow positive integers in numeric input."); + } + + [Test] + public void TestAscendingSpinnerClickEvent() + { + // Arrange + var updownControl = new NumericUpDownControl(); + var up = updownControl.spinnerUp; + var down = updownControl.spinnerDown; + var inputField = updownControl.inputField; + var watermark = updownControl.Watermark; + + // Act + watermark = "0"; + up.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); + + // Assert + Assert.AreEqual(inputField.Text, "1"); + + up.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); + Assert.AreEqual(inputField.Text, "2"); + + down.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); + Assert.AreEqual(inputField.Text, "1"); + + down.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); + Assert.AreEqual(inputField.Text, "0"); + + down.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); + Assert.AreEqual(inputField.Text, "0"); + } + + [Test] + public void TestDescendingSpinnerClickEvent() + { + // Arrange + var updownControl = new NumericUpDownControl(); + var up = updownControl.spinnerUp; + var down = updownControl.spinnerDown; + var inputField = updownControl.inputField; + var watermark = updownControl.Watermark; + + // Act + watermark = "1"; + down.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); + + // Assert + Assert.AreEqual(inputField.Text, "0"); + + down.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); + Assert.AreEqual(inputField.Text, "0"); + + up.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); + Assert.AreEqual(inputField.Text, "1"); + + up.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); + Assert.AreEqual(inputField.Text, "2"); + + down.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent)); + Assert.AreEqual(inputField.Text, "1"); + } #endregion #region InstalledPackagesControl @@ -1669,5 +1798,524 @@ public void FiltersContextMenuStaysOpen() #endregion + #region PackageViewModel Interaction + + [Test] + public void AddsFilesAndFoldersFromFilePathsCorrectly() + { + string nodePath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\PackageWithNodeDocumentation"); + var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList(); + var allFolders = Directory.GetDirectories(nodePath, "*", SearchOption.AllDirectories).ToList(); + + // Arrange + var vm = new PublishPackageViewModel(this.ViewModel); + vm.AddAllFilesAfterSelection(allFiles); + + var assemblies = vm.Assemblies; + var additionalFiles = vm.AdditionalFiles; + + // Assert number of files PackageContents items is the one we expect + Assert.AreEqual(assemblies.Count, allFiles.Count(f => f.EndsWith(".dll"))); + Assert.AreEqual(additionalFiles.Count, allFiles.Count(f => !f.EndsWith(".dll"))); + + var packageContents = vm.PackageContents; + Assert.AreEqual(packageContents.Count, 1); // We expect only 1 root item here + + // Assert that the PackageContents contains the correct number of items + var allFilesAndFoldres = PackageItemRootViewModel.GetFiles(packageContents.First()); + Assert.AreEqual(allFilesAndFoldres.Count, allFiles.Count + allFolders.Count + 1); + Assert.AreEqual(allFilesAndFoldres.Count(i => i.DependencyType.Equals(DependencyType.Assembly)), assemblies.Count); + Assert.AreEqual(allFilesAndFoldres.Count(i => i.DependencyType.Equals(DependencyType.File)), additionalFiles.Count); + Assert.AreEqual(allFilesAndFoldres.Count(i => i.DependencyType.Equals(DependencyType.Folder)), allFolders.Count + 1); + + // Arrange - try to add the same files again + var dlgMock = new Mock(); + dlgMock.Setup(m => m.Show(It.IsAny(), It.IsAny(), It.IsAny(), + It.Is(x => x == MessageBoxButton.OKCancel || x == MessageBoxButton.OK), It.IsAny())) + .Returns(MessageBoxResult.OK); + MessageBoxService.OverrideMessageBoxDuringTests(dlgMock.Object); + + vm.AddAllFilesAfterSelection(allFiles); + packageContents = vm.PackageContents; + + // Assert that the PackageContents still contains the correct number of items + allFilesAndFoldres = PackageItemRootViewModel.GetFiles(packageContents.First()); + Assert.AreEqual(allFilesAndFoldres.Count, allFiles.Count + allFolders.Count + 1); + Assert.AreEqual(allFilesAndFoldres.Count(i => i.DependencyType.Equals(DependencyType.Assembly)), assemblies.Count); + Assert.AreEqual(allFilesAndFoldres.Count(i => i.DependencyType.Equals(DependencyType.File)), additionalFiles.Count); + Assert.AreEqual(allFilesAndFoldres.Count(i => i.DependencyType.Equals(DependencyType.Folder)), allFolders.Count + 1); + } + + [Test] + public void RemoveMultipleRootItemsCorrectly() + { + string nodePath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\RootPackageFolder\\PackageWithNodeDocumentation"); + string duplicateNodePath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\RootPackageFolder\\DuplicatePackageWithNodeDocumentation"); + var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList(); + var allDuplicateFiles = Directory.GetFiles(duplicateNodePath, "*", SearchOption.AllDirectories).ToList(); + + // Arrange + var dlgMock = new Mock(); + dlgMock.Setup(m => m.Show(It.IsAny(), It.IsAny(), It.IsAny(), + It.Is(x => x == MessageBoxButton.OKCancel || x == MessageBoxButton.OK), It.IsAny())) + .Returns(MessageBoxResult.OK); + MessageBoxService.OverrideMessageBoxDuringTests(dlgMock.Object); + + var vm = new PublishPackageViewModel(this.ViewModel); + vm.AddAllFilesAfterSelection(allFiles); + vm.AddAllFilesAfterSelection(allDuplicateFiles); + + var packageContents = vm.PackageContents; + Assert.AreEqual(packageContents.Count, 2); // We expect 2 separate root item here + + Assert.DoesNotThrow(() => vm.RemoveItemCommand.Execute(packageContents.First())); + } + + + [Test] + public void AddsFilesAndFoldersFromMultipleFilePathsCorrectly() + { + string nodePath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\RootPackageFolder\\PackageWithNodeDocumentation"); + string duplicateNodePath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\RootPackageFolder\\DuplicatePackageWithNodeDocumentation"); + var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList(); + var allFolders = Directory.GetDirectories(nodePath, "*", SearchOption.AllDirectories).ToList(); + var allDuplicateFiles = Directory.GetFiles(duplicateNodePath, "*", SearchOption.AllDirectories).ToList(); + var allDuplicateFolders = Directory.GetDirectories(duplicateNodePath, "*", SearchOption.AllDirectories).ToList(); + + // Arrange + var dlgMock = new Mock(); + dlgMock.Setup(m => m.Show(It.IsAny(), It.IsAny(), It.IsAny(), + It.Is(x => x == MessageBoxButton.OKCancel || x == MessageBoxButton.OK), It.IsAny())) + .Returns(MessageBoxResult.OK); + MessageBoxService.OverrideMessageBoxDuringTests(dlgMock.Object); + + var vm = new PublishPackageViewModel(this.ViewModel); + vm.AddAllFilesAfterSelection(allFiles); + vm.AddAllFilesAfterSelection(allDuplicateFiles); + + var additionalFiles = vm.AdditionalFiles; + + var packageContents = vm.PackageContents; + Assert.AreEqual(packageContents.Count, 2); // We expect 2 separate root item here + + // Assert + // that the PackageContents contains the correct number of items + var allFilesAndFoldres = PackageItemRootViewModel.GetFiles(packageContents.ToList()); + + // add 2 root folders + Assert.AreEqual(allFilesAndFoldres.Count, allFiles.Count + allFolders.Count + (allDuplicateFiles.Count) + (allDuplicateFolders.Count) + 2); + Assert.AreEqual(allFilesAndFoldres.Count(i => i.DependencyType.Equals(DependencyType.File)), additionalFiles.Count); + + // add 2 root folders + Assert.AreEqual(allFilesAndFoldres.Count(i => i.DependencyType.Equals(DependencyType.Folder)), allFolders.Count + (allDuplicateFolders.Count) + 2); + + // Arrange + // try to add the folder one level above the two root folders + string commonRootPath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\RootPackageFolder"); + var commonRootFiles = Directory.GetFiles(commonRootPath, "*", SearchOption.AllDirectories).ToList(); + var commonRootFolders = Directory.GetDirectories(commonRootPath, "*", SearchOption.AllDirectories).ToList(); + + vm.AddAllFilesAfterSelection(commonRootFiles, commonRootPath); + packageContents = vm.PackageContents; + + Assert.AreEqual(packageContents.Count, 1); // We expect only 1 common root item now + + // Assert + // that the PackageContents still contains the correct number of items + allFilesAndFoldres = PackageItemRootViewModel.GetFiles(packageContents.First()); + + // add 1 root folder + Assert.AreEqual(allFilesAndFoldres.Count, (commonRootFiles.Count) + (commonRootFolders.Count) + 1); + Assert.AreEqual(allFilesAndFoldres.Count(i => i.DependencyType.Equals(DependencyType.File)), additionalFiles.Count); + + // add 1 root folder1 + Assert.AreEqual(allFilesAndFoldres.Count(i => i.DependencyType.Equals(DependencyType.Folder)), (commonRootFolders.Count) + 1); + } + + + [Test] + public void GetAllFilesReturnsEqualsPackageContents() + { + string nodePath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\RootPackageFolder\\PackageWithNodeDocumentation"); + var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList(); + var vm = new PublishPackageViewModel(this.ViewModel); + + ViewModel.OnRequestPackagePublishDialog(vm); + + vm.AddAllFilesAfterSelection(allFiles); + + int packageContentsCount = 0; + + foreach (var rootItem in vm.PackageContents) + { + var items = PackageItemRootViewModel.GetFiles(rootItem).Where(x => !x.DependencyType.Equals(DependencyType.Folder)).ToList(); + packageContentsCount += items.Count; + } + + var files = vm.GetAllFiles(); + + // check if GetAllFiles return the same number of files as stored inside the PackageContents + Assert.AreEqual(packageContentsCount, files.Count()); + } + + [Test] + public void AssertGetPreBuildRootItemViewModelReturnsCorrectItem() + { + string nodePath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\RootPackageFolder\\PackageWithNodeDocumentation"); + var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList(); + var vm = new PublishPackageViewModel(this.ViewModel); + + ViewModel.OnRequestPackagePublishDialog(vm); + + vm.AddAllFilesAfterSelection(allFiles); + + var testPath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\RootPackageFolder\\", "TestPath"); + var testPkgName = @"Test Package"; + + var rootItemPreview = vm.GetPreBuildRootItemViewModel(testPath, testPkgName, allFiles); + var allRootItems = PackageItemRootViewModel.GetFiles(rootItemPreview); + + var folders = allRootItems.Count(x => x.DependencyType.Equals(DependencyType.Folder)); + var files = allRootItems.Count(x => !x.DependencyType.Equals(DependencyType.Folder)); + + Assert.AreEqual(5, folders); + Assert.AreEqual(4, files); + } + + + [Test] + public void AssertGetExistingRootItemViewModelReturnsCorrectItem() + { + string nodePath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\RootPackageFolder\\PackageWithNodeDocumentation"); + var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList(); + var vm = new PublishPackageViewModel(this.ViewModel); + + ViewModel.OnRequestPackagePublishDialog(vm); + + vm.AddAllFilesAfterSelection(allFiles); + + var testPath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\RootPackageFolder\\", "TestPath"); + var testPkgName = @"Test Package"; + + // We expect a single root item for this test + var rootItem = vm.PackageContents.First(); + var allRootItems = PackageItemRootViewModel.GetFiles(vm.PackageContents.First()); + + var rootItemPreview = vm.GetExistingRootItemViewModel(testPath, testPkgName); + var testRootItems = PackageItemRootViewModel.GetFiles(rootItemPreview); + + + Assert.AreNotEqual(testPkgName, rootItem.DisplayName); + Assert.AreEqual(testPkgName, rootItemPreview.DisplayName); + + var foldersCount = allRootItems.Count(x => x.DependencyType.Equals(DependencyType.Folder)); + var filesCount = allRootItems.Count(x => !x.DependencyType.Equals(DependencyType.Folder)); + + var testFoldersCount = testRootItems.Count(x => x.DependencyType.Equals(DependencyType.Folder)); + var testFilesCount = testRootItems.Count(x => !x.DependencyType.Equals(DependencyType.Folder)); + + Assert.AreEqual(foldersCount, testFoldersCount); + Assert.AreEqual(filesCount, testFilesCount); + } + + + [Test] + public void RemoveFilesUpdatesPerviewContentItem() + { + // Arrange + string nodePath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\RootPackageFolder\\PackageWithNodeDocumentation"); + var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList(); + var vm = new PublishPackageViewModel(this.ViewModel); + + ViewModel.OnRequestPackagePublishDialog(vm); + + vm.AddAllFilesAfterSelection(allFiles); + + // Act + Assert.AreEqual(1, vm.PackageContents.Count); + Assert.AreEqual(1, vm.PreviewPackageContents.Count); + var rootItem = vm.PackageContents.First(); + + + // Assert + vm.RemoveItemCommand.Execute(rootItem); + Assert.AreEqual(0, vm.PackageContents.Count); + Assert.AreEqual(0, vm.PreviewPackageContents.Count); + } + + + [Test] + public void RemoveAllChildrenFilesUpdatesContentItem() + { + // Arrange + string nodePath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\RootPackageFolder\\PackageWithNodeDocumentation"); + var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList(); + var vm = new PublishPackageViewModel(this.ViewModel); + + ViewModel.OnRequestPackagePublishDialog(vm); + + vm.AddAllFilesAfterSelection(allFiles); + + // Act + Assert.AreEqual(1, vm.PackageContents.Count); + Assert.AreEqual(1, vm.PreviewPackageContents.Count); + var childItems = vm.PackageContents.First().ChildItems; + + // Assert + foreach (var child in childItems) + { + vm.RemoveItemCommand.Execute(child); + } + + Assert.AreEqual(0, vm.PackageContents.Count); + Assert.AreEqual(0, vm.PreviewPackageContents.Count); + } + + + [Test] + public void CanRemoveCustomDefinitionDependencyTypes() + { + // Arrange + string nodePath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\_AllFileTypesPackageDocs"); + string dyfPath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\_AllFileTypesPackageDocs\\dyf\\3DView by BoundingBox.dyf"); + var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList(); + var vm = new PublishPackageViewModel(this.ViewModel); + + ViewModel.OnRequestPackagePublishDialog(vm); + + vm.AddAllFilesAfterSelection(allFiles); + + // Act + // One root folder, one custom definition + Assert.AreEqual(2, vm.PackageContents.Count); + + var customDefinition = vm.PackageContents.Where(x => x.DependencyType.Equals(DependencyType.CustomNode)); + var rootFolder = vm.PackageContents.Where(x => x.DependencyType.Equals(DependencyType.Folder)); + + Assert.AreEqual(1, customDefinition.Count()); + Assert.AreEqual(1, rootFolder.Count()); + + var childItems = PackageItemRootViewModel.GetFiles(rootFolder.First()); + var customPreviewDefinition = childItems.Where(x => x.DependencyType.Equals(DependencyType.CustomNodePreview)); + + Assert.AreEqual(1, customPreviewDefinition.Count()); + + // Assert + // Remove using the custom definition + vm.RemoveItemCommand.Execute(customDefinition.First()); + + var updatedCustomDefinitionCount = vm.PackageContents.Count(x => x.DependencyType.Equals(DependencyType.CustomNode)); + var updatedCustomPreviewDefinitionCount = PackageItemRootViewModel.GetFiles(rootFolder.First()). + Count(x => x.DependencyType.Equals(DependencyType.CustomNodePreview)); + + Assert.AreEqual(0, updatedCustomDefinitionCount, updatedCustomPreviewDefinitionCount); + + // Add + vm.AddAllFilesAfterSelection(new List() { dyfPath }); + + updatedCustomDefinitionCount = vm.PackageContents.Count(x => x.DependencyType.Equals(DependencyType.CustomNode)); + updatedCustomPreviewDefinitionCount = PackageItemRootViewModel.GetFiles(rootFolder.First()). + Count(x => x.DependencyType.Equals(DependencyType.CustomNodePreview)); + + Assert.AreEqual(1, updatedCustomDefinitionCount, updatedCustomPreviewDefinitionCount); + + // Remove using the preview + vm.RemoveItemCommand.Execute(customPreviewDefinition.First()); + + updatedCustomDefinitionCount = vm.PackageContents.Count(x => x.DependencyType.Equals(DependencyType.CustomNode)); + updatedCustomPreviewDefinitionCount = PackageItemRootViewModel.GetFiles(rootFolder.First()). + Count(x => x.DependencyType.Equals(DependencyType.CustomNodePreview)); + + Assert.AreEqual(0, updatedCustomDefinitionCount, updatedCustomPreviewDefinitionCount); + } + + [Test] + public void CanRemoveAllDependencyTypes() + { + // Arrange + string nodePath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\_AllFileTypesPackageDocs"); + var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList(); + var vm = new PublishPackageViewModel(this.ViewModel); + + ViewModel.OnRequestPackagePublishDialog(vm); + + vm.AddAllFilesAfterSelection(allFiles); + + // Act + var rootFolder = vm.PackageContents.Where(x => x.DependencyType.Equals(DependencyType.Folder)); + + Assert.AreEqual(1, rootFolder.Count()); + + var childItems = PackageItemRootViewModel.GetFiles(rootFolder.First()); + + var files = childItems.Where(x => x.DependencyType.Equals(DependencyType.File)); + var dyfPreviewFiles = childItems.Where(x => x.DependencyType.Equals(DependencyType.CustomNodePreview)); + var folders = childItems.Where(x => x.DependencyType.Equals(DependencyType.Folder)); + + Assert.AreEqual(4, files.Count()); + Assert.AreEqual(1, dyfPreviewFiles.Count()); + Assert.AreEqual(4, folders.Count()); + + // Assert + Assert.DoesNotThrow(() => vm.RemoveItemCommand.Execute(dyfPreviewFiles.First())); + Assert.DoesNotThrow(() => vm.RemoveItemCommand.Execute(files.First(x => x.DisplayName.EndsWith(".json")))); + Assert.DoesNotThrow(() => vm.RemoveItemCommand.Execute(files.First(x => x.DisplayName.EndsWith(".xml")))); + + // At this point, only one root item remains, not the original one but the 'doc' folder + // The original root item no longer contains a file, therefore it was removed + // This makes sense as we don't want to try to establish 'common parent' for folders that maybe too far apart in a tree structure + rootFolder = vm.PackageContents.Where(x => x.DependencyType.Equals(DependencyType.Folder)); + Assert.AreEqual(1, rootFolder.Count()); + Assert.AreEqual(3, PackageItemRootViewModel.GetFiles(rootFolder.First()).Count()); + + Assert.DoesNotThrow(() => vm.RemoveItemCommand.Execute(rootFolder.First())); + Assert.IsFalse(vm.PackageContents.Any()); + } + + + [Test] + public void CancelCommandClearsAllData() + { + // Arrange + string nodePath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\RootPackageFolder\\PackageWithNodeDocumentation"); + var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList(); + var vm = new PublishPackageViewModel(this.ViewModel); + + Assert.AreEqual(0, vm.PackageContents.Count); + Assert.AreEqual(0, vm.PreviewPackageContents.Count); + + ViewModel.OnRequestPackagePublishDialog(vm); + + vm.AddAllFilesAfterSelection(allFiles); + + // Act + Assert.AreEqual(1, vm.PackageContents.Count); + Assert.AreEqual(1, vm.PreviewPackageContents.Count); + + vm.CancelCommand.Execute(); + + // Assert + Assert.AreEqual(0, vm.PackageContents.Count); + Assert.AreEqual(0, vm.PreviewPackageContents.Count); + } + + [Test] + public void AssertPreviewPackageDefaultFolderStructureEqualsPublishLocalPackageResults() + { + var packageName = "SingleFolderPublishPackage"; + var pathManager = this.ViewModel.Model.PathManager as PathManager; + var publishPath = Path.Combine(pathManager.DefaultPackagesDirectory, packageName); + + string nodePath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\SingleFolderPublishPackageDocs"); + var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList(); + + //now lets publish this package. + var newPkgVm = new PublishPackageViewModel(this.ViewModel); + + ViewModel.OnRequestPackagePublishDialog(newPkgVm); + + newPkgVm.AddAllFilesAfterSelection(allFiles); + + var previewFilesAndFolders = PackageItemRootViewModel.GetFiles(newPkgVm.PreviewPackageContents.ToList()); + var previewFiles = previewFilesAndFolders.Where(x => !x.DependencyType.Equals(DependencyType.Folder)); + var previewFolders = previewFilesAndFolders.Where(x => x.DependencyType.Equals(DependencyType.Folder)); + + newPkgVm.Name = "SingleFolderPublishPackage"; + newPkgVm.MajorVersion = "0"; + newPkgVm.MinorVersion = "0"; + newPkgVm.BuildVersion = "1"; + newPkgVm.PublishLocallyCommand.Execute(); + + Assert.IsTrue(Directory.Exists(publishPath)); + + // Arrange + var createdFiles = Directory.GetFiles(publishPath, "*", SearchOption.AllDirectories).ToList(); + var createdFolders = Directory.GetDirectories(publishPath, "*", SearchOption.AllDirectories).ToList(); + + // Assert + Assert.AreEqual(createdFiles.Count(), previewFiles.Count()); + Assert.AreEqual(createdFolders.Count(), previewFolders.Count() - 1); // discount one for the root folder is included + + // Clean up + Directory.Delete(publishPath, true); + } + + [Test] + public void AssertPreviewPackageRetainFolderStructureEqualsPublishLocalPackageResults() + { + var packageName = "SingleFolderPublishPackage"; + var pathManager = this.ViewModel.Model.PathManager as PathManager; + var publishPath = Path.Combine(pathManager.DefaultPackagesDirectory, packageName); + + string nodePath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\SingleFolderPublishPackageDocs"); + var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList(); + + //now lets publish this package. + var newPkgVm = new PublishPackageViewModel(this.ViewModel); + newPkgVm.RetainFolderStructureOverride = true; + + ViewModel.OnRequestPackagePublishDialog(newPkgVm); + + newPkgVm.AddAllFilesAfterSelection(allFiles); + + var previewFilesAndFolders = PackageItemRootViewModel.GetFiles(newPkgVm.PreviewPackageContents.ToList()); + var previewFiles = previewFilesAndFolders.Where(x => !x.DependencyType.Equals(DependencyType.Folder)); + var previewFolders = previewFilesAndFolders.Where(x => x.DependencyType.Equals(DependencyType.Folder)); + + newPkgVm.Name = "SingleFolderPublishPackage"; + newPkgVm.MajorVersion = "0"; + newPkgVm.MinorVersion = "0"; + newPkgVm.BuildVersion = "1"; + newPkgVm.PublishLocallyCommand.Execute(); + + Assert.IsTrue(Directory.Exists(publishPath)); + + // Arrange + var createdFiles = Directory.GetFiles(publishPath, "*", SearchOption.AllDirectories).ToList(); + var createdFolders = Directory.GetDirectories(publishPath, "*", SearchOption.AllDirectories).ToList(); + + // Assert + Assert.AreEqual(createdFiles.Count(), previewFiles.Count() + 1); + Assert.AreEqual(1, createdFolders.Count(), previewFolders.Count()); // One subfolder was created + + // Clean up + Directory.Delete(publishPath, true); + } + + [Test] + public void AssertPublishLocalHandleType() + { + var packageName = "SingleFolderPublishPackage"; + var pathManager = this.ViewModel.Model.PathManager as PathManager; + var publishPath = Path.Combine(pathManager.DefaultPackagesDirectory, packageName); + + string nodePath = Path.Combine(TestDirectory, "core", "docbrowser\\pkgs\\SingleFolderPublishPackageDocs"); + var allFiles = Directory.GetFiles(nodePath, "*", SearchOption.AllDirectories).ToList(); + + //now lets publish this package. + var newPkgVm = new PublishPackageViewModel(this.ViewModel); + newPkgVm.RetainFolderStructureOverride = true; + + ViewModel.OnRequestPackagePublishDialog(newPkgVm); + + newPkgVm.AddAllFilesAfterSelection(allFiles); + + var previewFilesAndFolders = PackageItemRootViewModel.GetFiles(newPkgVm.PreviewPackageContents.ToList()); + var previewFiles = previewFilesAndFolders.Where(x => !x.DependencyType.Equals(DependencyType.Folder)); + var previewFolders = previewFilesAndFolders.Where(x => x.DependencyType.Equals(DependencyType.Folder)); + + newPkgVm.Name = "SingleFolderPublishPackage"; + newPkgVm.MajorVersion = "0"; + newPkgVm.MinorVersion = "0"; + newPkgVm.BuildVersion = "1"; + newPkgVm.PublishLocallyCommand.Execute(); + + // Assert + Assert.AreEqual(PackageUploadHandle.UploadType.Local, newPkgVm.UploadType); + + // Clean up + Directory.Delete(publishPath, true); + } + #endregion } } diff --git a/test/DynamoCoreWpfTests/PublishPackageViewModelTests.cs b/test/DynamoCoreWpfTests/PublishPackageViewModelTests.cs index aacabea0ebe..34067d9d139 100644 --- a/test/DynamoCoreWpfTests/PublishPackageViewModelTests.cs +++ b/test/DynamoCoreWpfTests/PublishPackageViewModelTests.cs @@ -2,15 +2,14 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using Dynamo; using Dynamo.Graph.Nodes.CustomNodes; using Dynamo.Graph.Workspaces; using Dynamo.PackageManager; +using Dynamo.PackageManager.UI; using Dynamo.Tests; -using NUnit.Framework; using Moq; -using Dynamo.PackageManager.UI; +using NUnit.Framework; namespace DynamoCoreWpfTests { diff --git a/test/Libraries/PackageManagerTests/PackageDirectoryBuilderTests.cs b/test/Libraries/PackageManagerTests/PackageDirectoryBuilderTests.cs index c25932ad78c..71b230337f8 100644 --- a/test/Libraries/PackageManagerTests/PackageDirectoryBuilderTests.cs +++ b/test/Libraries/PackageManagerTests/PackageDirectoryBuilderTests.cs @@ -38,6 +38,24 @@ public void BuildPackageDirectory_DoesExpectedNumberOfOperations() Assert.AreEqual(1, fs.NewFilesWritten.Count()); } + [Test] + public void BuildRetainPackageDirectory_DoesExpectedNumberOfOperations() + { + var files = new List>() { new[] { @"C:\folder1\file1.dyf" }, new[] { @"C:\folder2\file2.dyf" } }; + var pkg = new Package(@"C:\pkg", "Foo", "0.1.0", "MIT"); + var fs = new RecordedFileSystem((fn) => files.SelectMany(files => files).ToList().Any((x) => ComparePaths(x, fn))); + var db = new PackageDirectoryBuilder(fs, MockMaker.Empty()); + + var pkgsDir = @"C:\dynamopackages"; + + db.BuildRetainDirectory(pkg, pkgsDir, files, Enumerable.Empty()); + + Assert.AreEqual(1, fs.DirectoriesCreated.Count()); + Assert.AreEqual(2, fs.CopiedFiles.Count()); + Assert.AreEqual(2, fs.DeletedFiles.Count()); + Assert.AreEqual(1, fs.NewFilesWritten.Count()); + } + [Test] public void BuildPackageDirectory_BuildsExpectedDirectories() { @@ -65,6 +83,23 @@ public void BuildPackageDirectory_BuildsExpectedDirectories() Assert.IsTrue(fs.DirectoriesCreated.Any(x => x.FullName == docDir)); } + [Test] + public void BuildRetainPackageDirectory_BuildsExpectedDirectories() + { + var files = new List>() { new[] { @"C:\folder1\file1.dyf" }, new[] { @"C:\folder2\file2.dyf" } }; + var pkg = new Package(@"C:\pkg", "Foo", "0.1.0", "MIT"); + var fs = new RecordedFileSystem((fn) => files.SelectMany(files => files).ToList().Any((x) => ComparePaths(x, fn))); + var db = new PackageDirectoryBuilder(fs, MockMaker.Empty()); + + var pkgsDir = @"C:\dynamopackages"; + + db.BuildRetainDirectory(pkg, pkgsDir, files, Enumerable.Empty()); + + var rootDir = Path.Combine(pkgsDir, pkg.Name); + + Assert.IsTrue(fs.DirectoriesCreated.Any(x => x.FullName == rootDir)); + } + [Test] public void BuildPackageDirectory_FormsPackageHeader() { @@ -87,6 +122,27 @@ public void BuildPackageDirectory_FormsPackageHeader() Assert.IsTrue(fs.NewFilesWritten.Any(x => x.Item1 == Path.Combine(rootDir, PackageDirectoryBuilder.PackageJsonName))); } + [Test] + public void BuildRetainPackageDirectory_FormsPackageHeader() + { + var files = new List>() { new[] { @"C:\folder1\file1.dyf" }, new[] { @"C:\folder2\file2.dyf" } }; + var pkg = new Package(@"C:\pkg", "Foo", "0.1.0", "MIT"); + var fs = new RecordedFileSystem((fn) => files.SelectMany(files => files).ToList().Any((x) => ComparePaths(x, fn))); + + var pr = new Mock(); + var db = new PackageDirectoryBuilder(fs, pr.Object); + + var pkgsDir = @"C:\dynamopackages"; + + // where the magic happens... + db.BuildRetainDirectory(pkg, pkgsDir, files, Enumerable.Empty()); + + var rootDir = Path.Combine(pkgsDir, pkg.Name); + + Assert.AreEqual(1, fs.NewFilesWritten.Count()); + Assert.IsTrue(fs.NewFilesWritten.Any(x => x.Item1 == Path.Combine(rootDir, PackageDirectoryBuilder.PackageJsonName))); + } + [Test] public void BuildPackageDirectory_RemapsCustomNodePaths() { @@ -117,6 +173,35 @@ public void BuildPackageDirectory_RemapsCustomNodePaths() Assert.IsTrue(remappedPaths.Any(x => x.Item1 == files[1] && x.Item2 == dyfDir)); } + [Test] + public void BuildRetainPackageDirectory_RemapsCustomNodePaths() + { + var files = new List>() { new[] { @"C:\folder1\file1.dyf" }, new[] { @"C:\folder2\file2.dyf" } }; + var pkg = new Package(@"C:\pkg", "Foo", "0.1.0", "MIT"); + var fs = new RecordedFileSystem((fn) => files.SelectMany(files => files).ToList().Any((x) => ComparePaths(x, fn))); + + var pr = new Mock(); + var remappedPaths = new List>(); + + pr.Setup(x => x.SetPath(files[0].First(), It.IsAny())) + .Callback((string f, string s) => remappedPaths.Add(new Tuple(f, s))); + + pr.Setup(x => x.SetPath(files[1].First(), It.IsAny())) + .Callback((string f, string s) => remappedPaths.Add(new Tuple(f, s))); + + var db = new PackageDirectoryBuilder(fs, pr.Object); + + var pkgsDir = @"C:\dynamopackages"; + + db.BuildRetainDirectory(pkg, pkgsDir, files, Enumerable.Empty()); + + var dyfDir1 = Path.Combine(pkgsDir, pkg.Name, Path.GetFileName(Path.GetDirectoryName(files[0].First())), Path.GetFileName(files[0].First())); + var dyfDir2 = Path.Combine(pkgsDir, pkg.Name, Path.GetFileName(Path.GetDirectoryName(files[1].First())), Path.GetFileName(files[1].First())); + + Assert.IsTrue(remappedPaths.Any(x => x.Item1 == files[0].First() && x.Item2 == dyfDir1)); + Assert.IsTrue(remappedPaths.Any(x => x.Item1 == files[1].First() && x.Item2 == dyfDir2)); + } + [Test] public void BuildPackageDirectory_UpdatesTheArgumentPackageWithNewDirectories() { @@ -147,6 +232,28 @@ public void BuildPackageDirectory_UpdatesTheArgumentPackageWithNewDirectories() Assert.AreEqual(docDir, pkg.NodeDocumentaionDirectory); } + [Test] + public void BuildRetainPackageDirectory_UpdatesTheArgumentPackageWithNewDirectories() + { + var files = new List>() { new[] { @"C:\folder1\file1.dyf" }, new[] { @"C:\folder2\file2.dyf" } }; + var pkg = new Package(@"C:\pkg", "Foo", "0.1.0", "MIT"); + var fs = new RecordedFileSystem((fn) => files.SelectMany(files => files).ToList().Any((x) => ComparePaths(x, fn))); + + + var pr = new Mock(); + var db = new PackageDirectoryBuilder(fs, pr.Object); + + var pkgsDir = @"C:\dynamopackages"; + + db.BuildRetainDirectory(pkg, pkgsDir, files, Enumerable.Empty()); + + var rootDir = Path.Combine(pkgsDir, pkg.Name); + + // The package itself is updated + + Assert.AreEqual(rootDir, pkg.RootDirectory); + } + [Test] public void BuildPackageDirectory_CopiesTheOriginalFiles() { @@ -172,6 +279,31 @@ public void BuildPackageDirectory_CopiesTheOriginalFiles() Assert.IsTrue(fs.CopiedFiles.Any(x => ComparePaths(x.Item2, Path.Combine(dyfDir, "file2.dyf")))); } + [Test] + public void BuildPackageRetainDirectory_CopiesTheOriginalFiles() + { + var files = new List>() { new[] { @"C:\folder1\file1.dyf" }, new[] { @"C:\folder2\file2.dyf" } }; + var pkg = new Package(@"C:\pkg", "Foo", "0.1.0", "MIT"); + var fs = new RecordedFileSystem((fn) => files.SelectMany(files => files).ToList().Any((x) => ComparePaths(x, fn))); + + var pr = new Mock(); + var db = new PackageDirectoryBuilder(fs, pr.Object); + + var pkgsDir = @"C:\dynamopackages"; + + db.BuildRetainDirectory(pkg, pkgsDir, files, Enumerable.Empty()); + + var dyfDir1 = Path.Combine(pkgsDir, pkg.Name, Path.GetFileName(Path.GetDirectoryName(files[0].First()))); + var dyfDir2 = Path.Combine(pkgsDir, pkg.Name, Path.GetFileName(Path.GetDirectoryName(files[1].First()))); + + Assert.AreEqual(2, fs.CopiedFiles.Count()); + Assert.AreEqual(2, fs.DeletedFiles.Count()); + Assert.AreEqual(0, fs.DeletedDirectories.Count()); + + Assert.IsTrue(fs.CopiedFiles.Any(x => ComparePaths(x.Item2, Path.Combine(dyfDir1, "file1.dyf")))); + Assert.IsTrue(fs.CopiedFiles.Any(x => ComparePaths(x.Item2, Path.Combine(dyfDir2, "file2.dyf")))); + } + [Test] public void BuildPackageDirectory_CopiesMarkDownFiles() { @@ -199,6 +331,32 @@ public void BuildPackageDirectory_CopiesMarkDownFiles() Assert.IsTrue(fs.CopiedFiles.Any(x => ComparePaths(x.Item2, Path.Combine(mdDir, "file3.jpg")))); } + [Test] + public void BuildRetainPackageDirectory_CopiesMarkDownFiles() + { + var files = new List>() { new[] { @"C:\folder1\file1.dyn" }, new[] { @"C:\folder2\file2.dyn" } }; + var markdownFiles = new[] { @"C:\file1.md", @"C:\file2.md", @"C:\image\file3.jpg" }; + var pkg = new Package(@"C:\pkg", "Foo", "0.1.0", "MIT"); + var fs = new RecordedFileSystem((fn) => files.SelectMany(files => files).ToList().Any((x) => ComparePaths(x, fn))); + + var pr = new Mock(); + var db = new PackageDirectoryBuilder(fs, pr.Object); + + var pkgsDir = @"C:\dynamopackages"; + + db.BuildRetainDirectory(pkg, pkgsDir, files, markdownFiles); + + var mdDir = Path.Combine(pkgsDir, pkg.Name, PackageDirectoryBuilder.DocumentationDirectoryName); + + Assert.AreEqual(5, fs.CopiedFiles.Count()); + Assert.AreEqual(0, fs.DeletedFiles.Count()); + Assert.AreEqual(0, fs.DeletedDirectories.Count()); + + Assert.IsTrue(fs.CopiedFiles.Any(x => ComparePaths(x.Item2, Path.Combine(mdDir, "file1.md")))); + Assert.IsTrue(fs.CopiedFiles.Any(x => ComparePaths(x.Item2, Path.Combine(mdDir, "file2.md")))); + Assert.IsTrue(fs.CopiedFiles.Any(x => ComparePaths(x.Item2, Path.Combine(mdDir, "file3.jpg")))); + } + [Test] public void BuildPackageDirectory_DeletesTheOriginalFiles() { @@ -224,6 +382,30 @@ public void BuildPackageDirectory_DeletesTheOriginalFiles() Assert.Contains(files[1], fs.DeletedFiles.ToList()); } + [Test] + public void BuildRetainPackageDirectory_DeletesTheOriginalFiles() + { + var files = new List>() { new[] { @"C:\folder1\file1.dyf" }, new[] { @"C:\folder2\file2.dyf" } }; + var pkg = new Package(@"C:\pkg", "Foo", "0.1.0", "MIT"); + var fs = new RecordedFileSystem((fn) => files.SelectMany(files => files).ToList().Any((x) => ComparePaths(x, fn))); + + var pr = new Mock(); + + var db = new PackageDirectoryBuilder(fs, pr.Object); + + var pkgsDir = @"C:\dynamopackages"; + + db.BuildRetainDirectory(pkg, pkgsDir, files, Enumerable.Empty()); + + // The original files are moved + + Assert.AreEqual(2, fs.DeletedFiles.Count()); + Assert.AreEqual(0, fs.DeletedDirectories.Count()); + + Assert.Contains(files[0].First(), fs.DeletedFiles.ToList()); + Assert.Contains(files[1].First(), fs.DeletedFiles.ToList()); + } + [Test] public void BuildPackageDirectory_DoesNotIncludeUnselectedFiles() { @@ -253,6 +435,36 @@ public void BuildPackageDirectory_DoesNotIncludeUnselectedFiles() Assert.AreEqual(1, fs.NewFilesWritten.Count()); } + [Test] + public void BuildRetainPackageDirectory_DoesNotIncludeUnselectedFiles() + { + // For http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-7676 + + var files = new List>() { new[] { "C:/pkg/bin/file1.dll", "C:/pkg/dyf/file2.dyf", + "C:/pkg/extra/file3.txt", "C:/pkg/extra/subfolder/file4.dwg" } }; + var pkg = new Package(@"C:\pkg", "Foo", "0.1.0", "MIT"); + var fs = new RecordedFileSystem((fn) => files.SelectMany(files => files).ToList().Any((x) => ComparePaths(x, fn))); + + // Specifying directory contents in the disk + fs.SetFiles(new List() { + "C:/pkg/bin/file1.dll", "C:/pkg/dyf/file2.dyf", "C:/pkg/dyf/backup/file2.dyf.0.backup", + "C:/pkg/extra/file3.txt", "C:/pkg/extra/Backup/file3.txt.backup", "C:/pkg/extra/subfolder/file4.dwg" }); + fs.SetDirectories(new List() { + "C:/pkg/bin", "C:/pkg/dyf", "C:/pkg/dyf/backup", "C:/pkg/extra", + "C:/pkg/extra/Backup", "C:/pkg/extra/subfolder" }); + + var db = new PackageDirectoryBuilder(fs, MockMaker.Empty()); + var pkgsDir = @"C:\dynamopackages"; + db.BuildRetainDirectory(pkg, pkgsDir, files, Enumerable.Empty()); + + + Assert.AreEqual(1, fs.DirectoriesCreated.Count()); + Assert.AreEqual(4, fs.CopiedFiles.Count()); + Assert.AreEqual(3, fs.DeletedFiles.Count()); + Assert.AreEqual(2, fs.DeletedDirectories.Count()); + Assert.AreEqual(1, fs.NewFilesWritten.Count()); + } + #endregion #region CopyFilesIntoPackageDirectory diff --git a/test/Libraries/PackageManagerTests/PackageManagerClientTests.cs b/test/Libraries/PackageManagerTests/PackageManagerClientTests.cs index bb70fe0b4cc..f1772e0c0b7 100644 --- a/test/Libraries/PackageManagerTests/PackageManagerClientTests.cs +++ b/test/Libraries/PackageManagerTests/PackageManagerClientTests.cs @@ -440,6 +440,94 @@ public void Publish_SetsErrorStatusWhenResponseIsNull() #endregion + #region PublishRetainingFolderStructure + + [Test] + public void PublishRetain_SetsHandleToDoneWhenNewPackagePublishSucceeds() + { + var gc = new Mock(); + gc.Setup(x => x.ExecuteAndDeserialize(It.IsAny())) + .Returns(new ResponseBody() + { + success = true + }); + + var pc = new PackageManagerClient(gc.Object, MockMaker.Empty(), ""); + + var pkg = new Package("", "Package", "0.1.0", "MIT"); + + var handle = new PackageUploadHandle(PackageUploadBuilder.NewRequestBody(pkg)); + var listOfEmptyEnumerables = Enumerable.Range(1, 5) + .Select(_ => Enumerable.Empty()); + + pc.PublishRetainFolderStructure(pkg, listOfEmptyEnumerables, Enumerable.Empty(), false, handle); + + Assert.AreEqual(PackageUploadHandle.State.Uploaded, handle.UploadState); + } + + [Test] + public void PublishRetain_SetsHandleToDoneWhenNewPackageVersionPublishSucceeds() + { + var gc = new Mock(); + gc.Setup(x => x.ExecuteAndDeserialize(It.IsAny())) + .Returns(new ResponseBody() + { + success = true + }); + + var pc = new PackageManagerClient(gc.Object, MockMaker.Empty(), ""); + + var pkg = new Package("", "Package", "0.1.0", "MIT"); + + var handle = new PackageUploadHandle(PackageUploadBuilder.NewRequestBody(pkg)); + var listOfEmptyEnumerables = Enumerable.Range(1, 5) + .Select(_ => Enumerable.Empty()); + pc.PublishRetainFolderStructure(pkg, listOfEmptyEnumerables, Enumerable.Empty(), false, handle); + + Assert.AreEqual(PackageUploadHandle.State.Uploaded, handle.UploadState); + } + + [Test] + public void PublishRetain_SetsErrorStatusWhenRequestThrowsAnException() + { + var gc = new Mock(); + gc.Setup(x => x.ExecuteAndDeserialize(It.IsAny())).Throws(); + + var pc = new PackageManagerClient(gc.Object, MockMaker.Empty(), ""); + + var pkg = new Package("", "Package", "0.1.0", "MIT"); + + var handle = new PackageUploadHandle(PackageUploadBuilder.NewRequestBody(pkg)); + var listOfEmptyEnumerables = Enumerable.Range(1, 5) + .Select(_ => Enumerable.Empty()); + pc.PublishRetainFolderStructure(pkg, listOfEmptyEnumerables, Enumerable.Empty(), false, handle); + + Assert.AreEqual(PackageUploadHandle.State.Error, handle.UploadState); + } + + [Test] + public void PublishRetain_SetsErrorStatusWhenResponseIsNull() + { + var gc = new Mock(); + var rb = new ResponseBody(); + rb.success = false; + + gc.Setup(x => x.ExecuteAndDeserialize(It.IsAny())).Returns(rb); + + var pc = new PackageManagerClient(gc.Object, MockMaker.Empty(), ""); + + var pkg = new Package("", "Package", "0.1.0", "MIT"); + + var handle = new PackageUploadHandle(PackageUploadBuilder.NewRequestBody(pkg)); + var listOfEmptyEnumerables = Enumerable.Range(1, 5) + .Select(_ => Enumerable.Empty()); + pc.PublishRetainFolderStructure(pkg, listOfEmptyEnumerables, Enumerable.Empty(), true, handle); + + Assert.AreEqual(PackageUploadHandle.State.Error, handle.UploadState); + } + + #endregion + #region Deprecate [Test] diff --git a/test/Libraries/PackageManagerTests/PackageUploadBuilderTests.cs b/test/Libraries/PackageManagerTests/PackageUploadBuilderTests.cs index e8de461b1d9..fdc538869f3 100644 --- a/test/Libraries/PackageManagerTests/PackageUploadBuilderTests.cs +++ b/test/Libraries/PackageManagerTests/PackageUploadBuilderTests.cs @@ -33,6 +33,24 @@ private IPackageUploadBuilder BigPackageUploadBuilderMock() return new PackageUploadBuilder(pdb.Object, zipper.Object); } + private IPackageUploadBuilder BigPackageUploadRetainBuilderMock() + { + // a IFileInfo object that is, by mocking, too large + var bigzip = new Mock(); + bigzip.Setup(x => x.Length).Returns(PackageUploadBuilder.MaximumPackageSize + 1); + + // the zipper returns a big zip + var zipper = new Mock(); + zipper.Setup((x) => x.Zip(It.IsAny())).Returns(bigzip.Object); + + var pdb = new Mock(); + pdb.Setup(x => x.BuildRetainDirectory(It.IsAny(), It.IsAny(), It.IsAny>>(), It.IsAny>())) + .Returns((new Mock()).Object); + + // this package upload builder will try to return a zip that is too big + return new PackageUploadBuilder(pdb.Object, zipper.Object); + } + private class directoryTestClass : IDirectoryInfo { public string FullName { get; set; } @@ -160,6 +178,40 @@ public void NewPackageVersionUpload_ThrowsForNullArguments() #endregion + #region NewPackageUploadRetainFolderStructure + + [Test] + public void NewPackageUploadRetain_ThrowsExceptionWhenPackageIsTooBig() + { + var pub = BigPackageUploadRetainBuilderMock(); + + var files = new List>() { new[] { @"C:\folder1\file1.dyf" }, new[] { @"C:\folder2\file2.dyf" } }; + var pkg = new Package(@"C:\pkg", "Foo", "0.1.0", "MIT"); + var pkgsDir = @"C:\dynamopackages"; + + var handle = new PackageUploadHandle(PackageUploadBuilder.NewRequestBody(pkg)); + + Assert.Throws(() => pub.NewPackageRetainUpload(pkg, pkgsDir, files, Enumerable.Empty(), handle)); + } + + [Test] + public void NewPackageVersionUploadRetain_ThrowsForNullArguments() + { + var files = new List>() { new[] { @"C:\folder1\file1.dyf" }, new[] { @"C:\folder2\file2.dyf" } }; + var pkg = new Package(@"C:\pkg", "Foo", "0.1.0", "MIT"); + var pkgsDir = @"C:\dynamopackages"; + var handle = new PackageUploadHandle(PackageUploadBuilder.NewRequestBody(pkg)); + + var m = new PackageUploadBuilder(MockMaker.Empty(), MockMaker.Empty()); + + Assert.Throws(() => m.NewPackageRetainUpload(null, pkgsDir, files, Enumerable.Empty(), handle)); + Assert.Throws(() => m.NewPackageRetainUpload(pkg, null, files, Enumerable.Empty(), handle)); + Assert.Throws(() => m.NewPackageRetainUpload(pkg, pkgsDir, null, Enumerable.Empty(), handle)); + Assert.Throws(() => m.NewPackageRetainUpload(pkg, pkgsDir, files, Enumerable.Empty(), null)); + } + + #endregion + #region NewPackageVersionUpload [Test] @@ -194,6 +246,40 @@ public void NewPackageUpload_ThrowsForNullArguments() #endregion + #region NewPackageVersionUploadRetainFolderStructure + + [Test] + public void NewPackageVersionUploadRetain_ThrowsExceptionWhenPackageIsTooBig() + { + var pub = BigPackageUploadBuilderMock(); + + var files = new List>() { new[] { @"C:\folder1\file1.dyf" }, new[] { @"C:\folder2\file2.dyf" } }; + var pkg = new Package(@"C:\pkg", "Foo", "0.1.0", "MIT"); + var pkgsDir = @"C:\dynamopackages"; + + var handle = new PackageUploadHandle(PackageUploadBuilder.NewRequestBody(pkg)); + + Assert.Throws(() => pub.NewPackageVersionRetainUpload(pkg, pkgsDir, files, Enumerable.Empty(), handle)); + } + + [Test] + public void NewPackageUploadRetain_ThrowsForNullArguments() + { + var files = new List>() { new[] { @"C:\folder1\file1.dyf" }, new[] { @"C:\folder2\file2.dyf" } }; + var pkg = new Package(@"C:\pkg", "Foo", "0.1.0", "MIT"); + var pkgsDir = @"C:\dynamopackages"; + var handle = new PackageUploadHandle(PackageUploadBuilder.NewRequestBody(pkg)); + + var m = new PackageUploadBuilder(MockMaker.Empty(), MockMaker.Empty()); + + Assert.Throws(() => m.NewPackageVersionRetainUpload(null, pkgsDir, files, Enumerable.Empty(), handle)); + Assert.Throws(() => m.NewPackageVersionRetainUpload(pkg, null, files, Enumerable.Empty(), handle)); + Assert.Throws(() => m.NewPackageVersionRetainUpload(pkg, pkgsDir, null, Enumerable.Empty(), handle)); + Assert.Throws(() => m.NewPackageVersionRetainUpload(pkg, pkgsDir, files, Enumerable.Empty(), null)); + } + + #endregion + #region NewRequestBody [Test] diff --git a/test/core/docbrowser/pkgs/RootPackageFolder/DuplicatePackageWithNodeDocumentation/doc/Random.Doc.md b/test/core/docbrowser/pkgs/RootPackageFolder/DuplicatePackageWithNodeDocumentation/doc/Random.Doc.md new file mode 100644 index 00000000000..c5bcf021670 --- /dev/null +++ b/test/core/docbrowser/pkgs/RootPackageFolder/DuplicatePackageWithNodeDocumentation/doc/Random.Doc.md @@ -0,0 +1,43 @@ +# Hello Dynamo! +This content is from the markdown file created for the `CustomNodeExample` node! + +In Markdown we can create headers simply by using `#`, let's try it: + +# Here's a header 1 `#` +## This is a header 2 `##` +### This is a header 3 `###` +#### This i.. Okay think you got it! + +We can also create cool stuff like tables! Here's an example: + +| column1 | column2 | +| ------- | ------- | +| row_1_1 | row_1_2 | +| row_2_1 | row_2_2 | +| row_3_1 | row_3_2 | + +Here's how you create the above table in markdown: +``` +| column1 | column2 | +| ------- | ------- | +| row_1_1 | row_1_2 | +| row_2_1 | row_2_2 | +| row_3_1 | row_3_2 | +``` + +How about some syntax highlighting in you documentation? +``` csharp +public void HelloDynamo(string message) +{ + System.Console.WriteLine(message); +} +``` + +
``` csharp
+public void HelloDynamo(string message)
+{
+    System.Console.WriteLine(message);
+}
+```
+ +![Dynamo Icon image](./icon.png) diff --git a/test/core/docbrowser/pkgs/RootPackageFolder/DuplicatePackageWithNodeDocumentation/doc/readme.txt b/test/core/docbrowser/pkgs/RootPackageFolder/DuplicatePackageWithNodeDocumentation/doc/readme.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/core/docbrowser/pkgs/RootPackageFolder/DuplicatePackageWithNodeDocumentation/pkg.json b/test/core/docbrowser/pkgs/RootPackageFolder/DuplicatePackageWithNodeDocumentation/pkg.json new file mode 100644 index 00000000000..6a3c2dae084 --- /dev/null +++ b/test/core/docbrowser/pkgs/RootPackageFolder/DuplicatePackageWithNodeDocumentation/pkg.json @@ -0,0 +1 @@ +{"license":"","file_hash":null,"name":"Package","version":"1.0.0","description":"original package","group":"","keywords":null,"dependencies":[],"contents":"","engine_version":"2.1.0.7840","engine":"dynamo","engine_metadata":"","site_url":"","repository_url":"","contains_binaries":true,"node_libraries":["Package, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"]} \ No newline at end of file diff --git a/test/core/docbrowser/pkgs/RootPackageFolder/PackageWithNodeDocumentation/doc/Random.Doc.md b/test/core/docbrowser/pkgs/RootPackageFolder/PackageWithNodeDocumentation/doc/Random.Doc.md new file mode 100644 index 00000000000..c5bcf021670 --- /dev/null +++ b/test/core/docbrowser/pkgs/RootPackageFolder/PackageWithNodeDocumentation/doc/Random.Doc.md @@ -0,0 +1,43 @@ +# Hello Dynamo! +This content is from the markdown file created for the `CustomNodeExample` node! + +In Markdown we can create headers simply by using `#`, let's try it: + +# Here's a header 1 `#` +## This is a header 2 `##` +### This is a header 3 `###` +#### This i.. Okay think you got it! + +We can also create cool stuff like tables! Here's an example: + +| column1 | column2 | +| ------- | ------- | +| row_1_1 | row_1_2 | +| row_2_1 | row_2_2 | +| row_3_1 | row_3_2 | + +Here's how you create the above table in markdown: +``` +| column1 | column2 | +| ------- | ------- | +| row_1_1 | row_1_2 | +| row_2_1 | row_2_2 | +| row_3_1 | row_3_2 | +``` + +How about some syntax highlighting in you documentation? +``` csharp +public void HelloDynamo(string message) +{ + System.Console.WriteLine(message); +} +``` + +
``` csharp
+public void HelloDynamo(string message)
+{
+    System.Console.WriteLine(message);
+}
+```
+ +![Dynamo Icon image](./icon.png) diff --git a/test/core/docbrowser/pkgs/RootPackageFolder/PackageWithNodeDocumentation/doc/readme.txt b/test/core/docbrowser/pkgs/RootPackageFolder/PackageWithNodeDocumentation/doc/readme.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/core/docbrowser/pkgs/RootPackageFolder/PackageWithNodeDocumentation/pkg.json b/test/core/docbrowser/pkgs/RootPackageFolder/PackageWithNodeDocumentation/pkg.json new file mode 100644 index 00000000000..6a3c2dae084 --- /dev/null +++ b/test/core/docbrowser/pkgs/RootPackageFolder/PackageWithNodeDocumentation/pkg.json @@ -0,0 +1 @@ +{"license":"","file_hash":null,"name":"Package","version":"1.0.0","description":"original package","group":"","keywords":null,"dependencies":[],"contents":"","engine_version":"2.1.0.7840","engine":"dynamo","engine_metadata":"","site_url":"","repository_url":"","contains_binaries":true,"node_libraries":["Package, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"]} \ No newline at end of file diff --git a/test/core/docbrowser/pkgs/SingleFolderPublishPackageDocs/doc.md b/test/core/docbrowser/pkgs/SingleFolderPublishPackageDocs/doc.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/core/docbrowser/pkgs/SingleFolderPublishPackageDocs/export.xml b/test/core/docbrowser/pkgs/SingleFolderPublishPackageDocs/export.xml new file mode 100644 index 00000000000..cc49cb77cb1 --- /dev/null +++ b/test/core/docbrowser/pkgs/SingleFolderPublishPackageDocs/export.xml @@ -0,0 +1,144 @@ + + + false + true + 335 + en-US + Millimeters + 0 + true + true + true + true + true + 100 + 70 + BEZIER + + + IsBackgroundPreviewActive + true + + + true + 1 + 0 + 128 + false + true + 245 + 86 + 1539 + 802 + true + f3 + 10 + + P:\Archilizer\Clients\Autodesk\Projects\23 - Q2\Zoom States\zoom-states.dyn + P:\Archilizer\Clients\Autodesk\Projects\23 - Q3\MyPackage\TestPublishMyNode.dyf + P:\Archilizer\Clients\Autodesk\Projects\22 - Q4\Python\test_scipy.dyn + P:\Archilizer\Clients\Autodesk\Projects\22 - Q4\Python Restyle\color code restyle.dyn + P:\Archilizer\Clients\Autodesk\Projects\23 - Q1\DYN-4513 Improvement Allow pin note to node via drag, hover and release\drag&drop.dyn + P:\Archilizer\Clients\Autodesk\Projects\23 - Q1\Background Helpers\Plane Axes\axes.dyn + + C:\Users\DeyanNenov\AppData\Roaming\Dynamo\Dynamo Core\backup + + C:\Users\DeyanNenov\AppData\Roaming\Dynamo\Dynamo Core\backup\backup.DYN + + + C:\Users\DeyanNenov\AppData\Roaming\Dynamo\Dynamo Core\2.19\packages\MyPackage + %BuiltInPackages% + C:\Users\DeyanNenov\AppData\Roaming\Dynamo\Dynamo Core\2.19 + C:\ProgramData\Dynamo\Dynamo Core\2.19\packages + + false + + C:\ProgramData\Autodesk + C:\Program Files\Autodesk + + + + 60000 + 1 + true + false + false + true + false + 10 + 10 + false + true + false + false + + C:\Users\DeyanNenov\AppData\Roaming\Dynamo\Dynamo Core\2.19 + + ProtoGeometry.dll:Autodesk.DesignScript.Geometry.TSpline + + + + Documentation Browser + 68B45FC0-0BD1-435C-BF28-B97CB03C71C8 + DockRight + false + + + Workspace References + A6706BF5-11C2-458F-B7C8-B745A77EF7FD + DockRight + false + + + Package Details + C71CA1B9-BF9F-425A-A12C-53DF56770406 + DockRight + false + + + Graph Node Manager + F76F4274-537D-4782-B1E9-27E8FDE2186F + DockRight + false + + + false + false + Automatic + MLRecommendation + false + + + Actions + B9F9E1 + true + 36 + 4d68be4a-a04d-4945-9dd5-cdf61079d790 + + + Inputs + FFB8D8 + true + 36 + 883066aa-1fe2-44a4-9bd1-c3df86bfe9f6 + + + Outputs + FFC999 + true + 36 + 07655dc1-2d65-4fed-8d6a-37235d3e3a8d + + + Review + A4E1FF + true + 36 + bc688959-ce34-4bf5-90f8-6ddd23f80989 + + + 300 + 2.4.0 + + + \ No newline at end of file diff --git a/test/core/docbrowser/pkgs/SingleFolderPublishPackageDocs/pkg.Migrations.xml b/test/core/docbrowser/pkgs/SingleFolderPublishPackageDocs/pkg.Migrations.xml new file mode 100644 index 00000000000..4f192f6d51e --- /dev/null +++ b/test/core/docbrowser/pkgs/SingleFolderPublishPackageDocs/pkg.Migrations.xml @@ -0,0 +1,1518 @@ + + + + + + + + + lcop_selection_set_tree/Architecture/ART.CurtainWalls;lcop_selection_set_tree/Architecture/ART.Floors;lcop_selection_set_tree/Architecture/ART.Entourage;lcop_selection_set_tree/Architecture/ART.Floors;lcop_selection_set_tree/Architecture/ART.CurtainWalls;lcop_selection_set_tree/Architecture/ART.Floors;lcop_selection_set_tree/Architecture/ART.CurtainWalls + + + + + lcop_selection_set_tree/Structure/STR.Columns + + + + + + + + + lcop_selection_set_tree/Architecture/ART.Walls + + + + + lcop_selection_set_tree/Structure/STR.Columns + + + + + + + + + lcop_selection_set_tree/Architecture/ART.Floors + + + + + lcop_selection_set_tree/Architecture/ART.Site;lcop_selection_set_tree/Architecture/ART.Furniture;lcop_selection_set_tree/Architecture/ART.Doors;lcop_selection_set_tree/Architecture/ART.Furniture + + + + + + + + + lcop_selection_set_tree/Architecture/ART.Furniture;lcop_selection_set_tree/Architecture/ART.Floors;lcop_selection_set_tree/Architecture/ART.Roofs;lcop_selection_set_tree/Architecture/ART.Windows;lcop_selection_set_tree/Architecture/ART.Furniture;lcop_selection_set_tree/Architecture/ART.Floors;lcop_selection_set_tree/Architecture/ART.Doors;lcop_selection_set_tree/Architecture/ART.CurtainWalls;lcop_selection_set_tree/Architecture/ART.Furniture;lcop_selection_set_tree/Architecture/ART.Floors + + + + + lcop_selection_set_tree/MEP/MEP.ElectricalFixtures + + + + + + + + + lcop_selection_set_tree/Architecture + + + + + lcop_selection_set_tree/Structure/STR.Columns + + + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Casework + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Ceilings + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Columns + + + + + Element + + + Category + + + Structural Columns + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Curtain Panels + + + + + Element + + + Category + + + Curtain Systems + + + + + Element + + + Category + + + Curtain Wall Mullions + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Doors + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Entourage + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Floors + + + + + Element + + + Category + + + Slab Edges + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Furniture + + + + + Element + + + Category + + + Furniture Systems + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Furniture Systems + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Generic Models + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Parking + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Parts + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Planting + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Plumbing Fixtures + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Railings + + + + + Element + + + Category + + + Handrails + + + + + Element + + + Category + + + Top Rails + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Ramps + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Roofs + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Shaft Openings + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Site + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Specialty Equipment + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Stairs + + + + + Element + + + Category + + + Landings + + + + + Element + + + Category + + + Runs + + + + + Element + + + Category + + + Gutters + + + + + Element + + + Category + + + Wall Sweeps + + + + + Element + + + Category + + + Duct + + + + + Element + + + Category + + + Supports + + + + + Element + + + Category + + + Telephone Devices + + + + + Element + + + Category + + + Pipe + + + + + Element + + + Category + + + Handrails + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Topography + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Walls + + + + + Element + + + Category + + + Wall Sweeps + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Windows + + + + + + + + + + + Source File + + + -ART- + + + + + Element + + + Category + + + Windows + + + + + + + + + + + + + Source File + + + -STR- + + + + + Element + + + Category + + + Generic Models + + + + + + + + + + + Source File + + + -STR- + + + + + Element + + + Category + + + Slab Edges + + + + + + + + + + + Source File + + + -STR- + + + + + Element + + + Category + + + Beams + + + + + + + + + + + Source File + + + -STR- + + + + + Element + + + Category + + + Columns + + + + + + + + + + + Source File + + + -STR- + + + + + Element + + + Category + + + Structural Connections + + + + + + + + + + + Source File + + + -STR- + + + + + Element + + + Category + + + Structural Foundations + + + + + + + + + + + Source File + + + -STR- + + + + + Element + + + Category + + + Structural Framing + + + + + + + + + + + Source File + + + -STR- + + + + + Element + + + Category + + + Walls + + + + + + + + + + + + + Source File + + + -MEP- + + + + + Element + + + Category + + + Air Terminals + + + + + + + + + + + Source File + + + -MEP- + + + + + Element + + + Category + + + Cable Trays + + + + + Element + + + Category + + + Cable Tray Fittings + + + + + Element + + + Category + + + Cable Tray Runs + + + + + + + + + + + Source File + + + -MEP- + + + + + Element + + + Category + + + Devices + + + + + + + + + + + Source File + + + -MEP- + + + + + Element + + + Category + + + Conduits + + + + + Element + + + Category + + + Conduit Fittings + + + + + Element + + + Category + + + Conduit Runs + + + + + + + + + + + Source File + + + -MEP- + + + + + Element + + + Category + + + Duct + + + + + + + + + + + Source File + + + -MEP- + + + + + Element + + + Category + + + Electrical Equipment + + + + + + + + + + + Source File + + + -MEP- + + + + + Element + + + Category + + + Electrical Fixtures + + + + + + + + + + + Source File + + + -MEP- + + + + + Element + + + Category + + + Generic Models + + + + + + + + + + + Source File + + + -MEP- + + + + + Element + + + Category + + + HVACZones + + + + + + + + + + + Source File + + + -MEP- + + + + + Element + + + Category + + + Lighting Fixtures + + + + + + + + + + + Source File + + + -MEP- + + + + + Element + + + Category + + + Mechanical Equipment + + + + + + + + + + + Source File + + + -MEP- + + + + + Element + + + Category + + + Pipe + + + + + + + + + + + Source File + + + -MEP- + + + + + Element + + + Category + + + Plumbing Fixtures + + + + + + + + + + + Source File + + + -MEP- + + + + + Element + + + Category + + + Specialty Equipment + + + + + + + + + + + Source File + + + -MEP- + + + + + Element + + + Category + + + Sprinklers + + + + + + + + + + + diff --git a/test/core/docbrowser/pkgs/SingleFolderPublishPackageDocs/pkg.json b/test/core/docbrowser/pkgs/SingleFolderPublishPackageDocs/pkg.json new file mode 100644 index 00000000000..5f3fdfb11e8 --- /dev/null +++ b/test/core/docbrowser/pkgs/SingleFolderPublishPackageDocs/pkg.json @@ -0,0 +1 @@ +{"license":"MIT","file_hash":null,"name":"ADSE","version":"0.0.1","description":"Package for doing digital engineering","group":"ADSE","keywords":["adse"],"dependencies":[],"host_dependencies":["Civil 3D","CPython3"],"contents":"ADSE_C3D_Psets_Xlsx2LayerWiseExtendedData - No description provided","engine_version":"2.17.0.3472","engine":"dynamo","engine_metadata":"","site_url":"https://oscarjacobsen.no/dynamo","repository_url":"https://oscarjacobsen.no/dynamo","contains_binaries":false,"node_libraries":[],"copyright_holder":"Oscar Jacobsen","copyright_year":"2023"} \ No newline at end of file diff --git a/test/core/docbrowser/pkgs/SingleFolderPublishPackageDocs/pkg.xml b/test/core/docbrowser/pkgs/SingleFolderPublishPackageDocs/pkg.xml new file mode 100644 index 00000000000..cc49cb77cb1 --- /dev/null +++ b/test/core/docbrowser/pkgs/SingleFolderPublishPackageDocs/pkg.xml @@ -0,0 +1,144 @@ + + + false + true + 335 + en-US + Millimeters + 0 + true + true + true + true + true + 100 + 70 + BEZIER + + + IsBackgroundPreviewActive + true + + + true + 1 + 0 + 128 + false + true + 245 + 86 + 1539 + 802 + true + f3 + 10 + + P:\Archilizer\Clients\Autodesk\Projects\23 - Q2\Zoom States\zoom-states.dyn + P:\Archilizer\Clients\Autodesk\Projects\23 - Q3\MyPackage\TestPublishMyNode.dyf + P:\Archilizer\Clients\Autodesk\Projects\22 - Q4\Python\test_scipy.dyn + P:\Archilizer\Clients\Autodesk\Projects\22 - Q4\Python Restyle\color code restyle.dyn + P:\Archilizer\Clients\Autodesk\Projects\23 - Q1\DYN-4513 Improvement Allow pin note to node via drag, hover and release\drag&drop.dyn + P:\Archilizer\Clients\Autodesk\Projects\23 - Q1\Background Helpers\Plane Axes\axes.dyn + + C:\Users\DeyanNenov\AppData\Roaming\Dynamo\Dynamo Core\backup + + C:\Users\DeyanNenov\AppData\Roaming\Dynamo\Dynamo Core\backup\backup.DYN + + + C:\Users\DeyanNenov\AppData\Roaming\Dynamo\Dynamo Core\2.19\packages\MyPackage + %BuiltInPackages% + C:\Users\DeyanNenov\AppData\Roaming\Dynamo\Dynamo Core\2.19 + C:\ProgramData\Dynamo\Dynamo Core\2.19\packages + + false + + C:\ProgramData\Autodesk + C:\Program Files\Autodesk + + + + 60000 + 1 + true + false + false + true + false + 10 + 10 + false + true + false + false + + C:\Users\DeyanNenov\AppData\Roaming\Dynamo\Dynamo Core\2.19 + + ProtoGeometry.dll:Autodesk.DesignScript.Geometry.TSpline + + + + Documentation Browser + 68B45FC0-0BD1-435C-BF28-B97CB03C71C8 + DockRight + false + + + Workspace References + A6706BF5-11C2-458F-B7C8-B745A77EF7FD + DockRight + false + + + Package Details + C71CA1B9-BF9F-425A-A12C-53DF56770406 + DockRight + false + + + Graph Node Manager + F76F4274-537D-4782-B1E9-27E8FDE2186F + DockRight + false + + + false + false + Automatic + MLRecommendation + false + + + Actions + B9F9E1 + true + 36 + 4d68be4a-a04d-4945-9dd5-cdf61079d790 + + + Inputs + FFB8D8 + true + 36 + 883066aa-1fe2-44a4-9bd1-c3df86bfe9f6 + + + Outputs + FFC999 + true + 36 + 07655dc1-2d65-4fed-8d6a-37235d3e3a8d + + + Review + A4E1FF + true + 36 + bc688959-ce34-4bf5-90f8-6ddd23f80989 + + + 300 + 2.4.0 + + + \ No newline at end of file diff --git a/test/core/docbrowser/pkgs/_AllFileTypesPackageDocs/doc/Random.Doc.md b/test/core/docbrowser/pkgs/_AllFileTypesPackageDocs/doc/Random.Doc.md new file mode 100644 index 00000000000..c5bcf021670 --- /dev/null +++ b/test/core/docbrowser/pkgs/_AllFileTypesPackageDocs/doc/Random.Doc.md @@ -0,0 +1,43 @@ +# Hello Dynamo! +This content is from the markdown file created for the `CustomNodeExample` node! + +In Markdown we can create headers simply by using `#`, let's try it: + +# Here's a header 1 `#` +## This is a header 2 `##` +### This is a header 3 `###` +#### This i.. Okay think you got it! + +We can also create cool stuff like tables! Here's an example: + +| column1 | column2 | +| ------- | ------- | +| row_1_1 | row_1_2 | +| row_2_1 | row_2_2 | +| row_3_1 | row_3_2 | + +Here's how you create the above table in markdown: +``` +| column1 | column2 | +| ------- | ------- | +| row_1_1 | row_1_2 | +| row_2_1 | row_2_2 | +| row_3_1 | row_3_2 | +``` + +How about some syntax highlighting in you documentation? +``` csharp +public void HelloDynamo(string message) +{ + System.Console.WriteLine(message); +} +``` + +
``` csharp
+public void HelloDynamo(string message)
+{
+    System.Console.WriteLine(message);
+}
+```
+ +![Dynamo Icon image](./icon.png) diff --git a/test/core/docbrowser/pkgs/_AllFileTypesPackageDocs/doc/readme.txt b/test/core/docbrowser/pkgs/_AllFileTypesPackageDocs/doc/readme.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/core/docbrowser/pkgs/_AllFileTypesPackageDocs/dyf/3DView by BoundingBox.dyf b/test/core/docbrowser/pkgs/_AllFileTypesPackageDocs/dyf/3DView by BoundingBox.dyf new file mode 100644 index 00000000000..06ebf117688 --- /dev/null +++ b/test/core/docbrowser/pkgs/_AllFileTypesPackageDocs/dyf/3DView by BoundingBox.dyf @@ -0,0 +1,215 @@ +{ + "Uuid": "42548128-8606-41a0-920b-3cfa3a66d961", + "IsCustomNode": true, + "Category": "GeniusLoci.View", + "Description": "Use a boundingbox to create a new 3D View with a specified name.\r\nNote: Use the \"Remove Special Characters from String\" node to obtain a view name without prohibited characters.", + "Name": "3DView by BoundingBox", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Symbol, DynamoCore", + "NodeType": "InputNode", + "Parameter": { + "Name": "boundingBox", + "TypeName": "var", + "TypeRank": -1, + "DefaultValue": null, + "Description": "Future Section box" + }, + "Id": "1f37198f21bd4b82805efb8b8022b4ac", + "Inputs": [], + "Outputs": [ + { + "Id": "68ec359e976f4bdf8e312d869e77a667", + "Name": "", + "Description": "Symbole", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Un paramètre de fonction, utiliser avec des noeuds personnalisés.\r\n\r\nVous pouvez spécifier le type et la valeur par défaut du paramètre. Par exemple,\r\n\r\nentrée: var[]..[]\r\nvaleur: bool = false" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Output, DynamoCore", + "NodeType": "OutputNode", + "ElementResolver": null, + "Symbol": "Views", + "Id": "c965bdcc3e5f45908a096aba97526350", + "Inputs": [ + { + "Id": "dbf7a3b472904bb593e8d0f86be37ef8", + "Name": "", + "Description": "", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [], + "Replication": "Disabled", + "Description": "Sortie de fonction, utiliser avec les noeuds personnalisés" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.CustomNodes.Symbol, DynamoCore", + "NodeType": "InputNode", + "Parameter": { + "Name": "viewName", + "TypeName": "var", + "TypeRank": -1, + "DefaultValue": null, + "Description": "" + }, + "Id": "def2cd54e3cb400d9a4d2919d36027e5", + "Inputs": [], + "Outputs": [ + { + "Id": "308f2190efb948778f276449a97b538d", + "Name": "", + "Description": "Symbole", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Un paramètre de fonction, utiliser avec des noeuds personnalisés.\r\n\r\nVous pouvez spécifier le type et la valeur par défaut du paramètre. Par exemple,\r\n\r\nentrée: var[]..[]\r\nvaleur: bool = false" + }, + { + "ConcreteType": "PythonNodeModels.PythonNode, PythonNodeModels", + "NodeType": "PythonScriptNode", + "Code": "import clr\nclr.AddReference('RevitAPI')\nimport Autodesk\nfrom Autodesk.Revit.DB import *\n\nclr.AddReference('RevitNodes')\nimport Revit\nclr.ImportExtensions(Revit.GeometryConversion)\n\nclr.AddReference('RevitServices')\nimport RevitServices\nfrom RevitServices.Persistence import DocumentManager\nfrom RevitServices.Transactions import TransactionManager\ndoc = DocumentManager.Instance.CurrentDBDocument\n\ndef tolist(obj1):\n if hasattr(obj1,\"__iter__\"): return obj1\n else: return [obj1]\n\nbboxs = tolist(IN[0])\nviewNames = tolist(IN[1])\nviews=[]\n\n#Get 3D View ViewFamilyType\nviewTypeColl = FilteredElementCollector(doc).OfClass(ViewFamilyType)\nfor i in viewTypeColl:\n\tif i.ViewFamily == ViewFamily.ThreeDimensional:\n\t\tviewType = i\n\telse:\n\t\tcontinue\n\nfor bbox,viewName in zip(bboxs,viewNames):\n\tnewmax = UnwrapElement(bbox.MaxPoint).ToRevitType()\n\tnewmin = UnwrapElement(bbox.MinPoint).ToRevitType()\n\tnewbox = BoundingBoxXYZ()\n\tnewbox.Max = newmax\n\tnewbox.Min = newmin\n\ttry:\n\t\tTransactionManager.Instance.EnsureInTransaction(doc)\n\t\tview = View3D.CreateIsometric(doc, viewType.Id)\n\t\tview.Name = viewName\n\t\tview.SetSectionBox(newbox)\n\t\tviews.append(view)\n\t\tTransactionManager.Instance.TransactionTaskDone()\n\texcept Exception, ex:\n\t\tviews.append(ex.message)\n\nOUT = views", + "VariableInputPorts": true, + "Id": "9a773cf94f2544fd86b7a2812569fbad", + "Inputs": [ + { + "Id": "a46192192b9c4057b6e4b5bd823a364d", + "Name": "IN[0]", + "Description": "Input #0", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "20f553569bfd44468fbdcb408899653c", + "Name": "IN[1]", + "Description": "Input #1", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "1e019420186d422ab1e988aa94a08052", + "Name": "OUT", + "Description": "Résultat du script Python", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Exécute un script IronPython intégré." + } + ], + "Connectors": [ + { + "Start": "68ec359e976f4bdf8e312d869e77a667", + "End": "a46192192b9c4057b6e4b5bd823a364d", + "Id": "d4bc75277ea14356a2bb4bf7dbb5381f" + }, + { + "Start": "308f2190efb948778f276449a97b538d", + "End": "20f553569bfd44468fbdcb408899653c", + "Id": "c6e33f1e3fed45f992bfb276166b3a4f" + }, + { + "Start": "1e019420186d422ab1e988aa94a08052", + "End": "dbf7a3b472904bb593e8d0f86be37ef8", + "Id": "0f88d4baf72c4ec7a67efb66b5f20812" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [], + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": false, + "IsVisibleInDynamoLibrary": true, + "Version": "2.6.1.8786", + "RunType": "Manual", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "Aperçu en arrière-plan", + "EyeX": -17.0, + "EyeY": 24.0, + "EyeZ": 50.0, + "LookX": 12.0, + "LookY": -13.0, + "LookZ": -58.0, + "UpX": 0.0, + "UpY": 1.0, + "UpZ": 0.0 + }, + "NodeViews": [ + { + "ShowGeometry": true, + "Name": "Input", + "Id": "1f37198f21bd4b82805efb8b8022b4ac", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 250.705708561732, + "Y": 13.8975315705315 + }, + { + "ShowGeometry": true, + "Name": "Output", + "Id": "c965bdcc3e5f45908a096aba97526350", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 665.115303176804, + "Y": 44.9801991454159 + }, + { + "ShowGeometry": true, + "Name": "Input", + "Id": "def2cd54e3cb400d9a4d2919d36027e5", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 326.086828276943, + "Y": 100.453846562683 + }, + { + "ShowGeometry": true, + "Name": "Python Script", + "Id": "9a773cf94f2544fd86b7a2812569fbad", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 493.462008990311, + "Y": 37.7996033682453 + } + ], + "Annotations": [], + "X": -280.967276858415, + "Y": 265.743005781289, + "Zoom": 1.16438980805626 + } +} \ No newline at end of file diff --git a/test/core/docbrowser/pkgs/_AllFileTypesPackageDocs/extra/Package.Migrations.xml b/test/core/docbrowser/pkgs/_AllFileTypesPackageDocs/extra/Package.Migrations.xml new file mode 100644 index 00000000000..39539b94265 --- /dev/null +++ b/test/core/docbrowser/pkgs/_AllFileTypesPackageDocs/extra/Package.Migrations.xml @@ -0,0 +1,7 @@ + + + + Revit.CurveElement.RemoveDuplicates + Revit.CurveElement.FindDuplicates + + \ No newline at end of file diff --git a/test/core/docbrowser/pkgs/_AllFileTypesPackageDocs/pkg.json b/test/core/docbrowser/pkgs/_AllFileTypesPackageDocs/pkg.json new file mode 100644 index 00000000000..6a3c2dae084 --- /dev/null +++ b/test/core/docbrowser/pkgs/_AllFileTypesPackageDocs/pkg.json @@ -0,0 +1 @@ +{"license":"","file_hash":null,"name":"Package","version":"1.0.0","description":"original package","group":"","keywords":null,"dependencies":[],"contents":"","engine_version":"2.1.0.7840","engine":"dynamo","engine_metadata":"","site_url":"","repository_url":"","contains_binaries":true,"node_libraries":["Package, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"]} \ No newline at end of file