示例#1
0
        private void ExecutedPackageCommand(object sender, ExecutedRoutedEventArgs e)
        {
            if (OperationCoordinator.IsBusy)
            {
                return;
            }

            VSExtensionsExplorerCtl control = e.Source as VSExtensionsExplorerCtl;

            if (control == null)
            {
                return;
            }

            PackageItem selectedItem = control.SelectedExtension as PackageItem;

            if (selectedItem == null)
            {
                return;
            }

            PackagesProviderBase provider = control.SelectedProvider as PackagesProviderBase;

            if (provider != null)
            {
                try {
                    provider.Execute(selectedItem);
                }
                catch (Exception exception) {
                    MessageHelper.ShowErrorMessage(exception, NuGet.Dialog.Resources.Dialog_MessageBoxTitle);

                    ExceptionHelper.WriteToActivityLog(exception);
                }
            }
        }
        public void ExtensionsTreeIsNotNull()
        {
            // Arrange
            PackagesProviderBase provider = CreatePackagesProviderBase();

            // Act && Assert
            Assert.NotNull(provider.ExtensionsTree);
        }
        public void PropertyRefreshOnNodeSelectionIsFalse()
        {
            // Arrange
            PackagesProviderBase provider = CreatePackagesProviderBase();

            // Act & Assert
            Assert.False(provider.RefreshOnNodeSelection);
        }
        public void DetailViewDataTemplate()
        {
            // Arrange
            PackagesProviderBase provider = CreatePackagesProviderBase();

            // Act && Assert
            Assert.NotNull(provider.DetailViewDataTemplate);
        }
        public void MediumIconDataTemplate()
        {
            // Arrange
            PackagesProviderBase provider = CreatePackagesProviderBase();

            // Act && Assert
            Assert.NotNull(provider.MediumIconDataTemplate);
        }
        public void ExtensionsTreeIsPopulatedWithOneNode()
        {
            // Arrange
            PackagesProviderBase provider = CreatePackagesProviderBase();

            // Act && Assert
            Assert.Equal(1, provider.ExtensionsTree.Nodes.Count);
            Assert.IsType(typeof(SimpleTreeNode), provider.ExtensionsTree.Nodes[0]);
            Assert.Equal("All", provider.ExtensionsTree.Nodes[0].Name);
        }
        public void ToStringMethodReturnsNameValue()
        {
            // Arrange
            PackagesProviderBase provider = CreatePackagesProviderBase();

            // act
            string providerName = provider.ToString();

            // Assert
            Assert.Equal("Test Provider", providerName);
        }
        public void SearchMethodDoNotCreateNewSearchNodeWhenSearchTextChanges()
        {
            // Arrange
            PackagesProviderBase provider = CreatePackagesProviderBase();

            provider.SelectedNode = (PackagesTreeNodeBase)provider.ExtensionsTree.Nodes[0];

            // Act
            IVsExtensionsTreeNode searchNode       = provider.Search("hello");
            IVsExtensionsTreeNode secondSearchNode = provider.Search("hellop");

            // Assert
            Assert.Same(searchNode, secondSearchNode);
        }
示例#9
0
        public void SearchMethodCreatesNewTreeNode()
        {
            // Arrange
            PackagesProviderBase provider = CreatePackagesProviderBase();

            provider.SelectedNode = (PackagesTreeNodeBase)provider.ExtensionsTree.Nodes[0];

            // Act
            var searchNode = provider.Search("hello") as PackagesSearchNode;

            // Assert
            Assert.NotNull(searchNode);
            Assert.True(searchNode.BaseNode.Nodes.Contains(searchNode));
        }
        public void SearchMethodReturnsNullForNullOrEmptySearchText()
        {
            // Arrange
            PackagesProviderBase provider = CreatePackagesProviderBase();

            provider.SelectedNode = (PackagesTreeNodeBase)provider.ExtensionsTree.Nodes[0];

            // Act
            IVsExtensionsTreeNode searchNode       = provider.Search(null);
            IVsExtensionsTreeNode secondSearchNode = provider.Search("");

            // Assert
            Assert.Null(searchNode);
            Assert.Null(secondSearchNode);
        }
示例#11
0
        public void SearchMethodCreatesNewTreeNode()
        {
            // Arrange
            PackagesProviderBase provider = CreatePackagesProviderBase();

            provider.SelectedNode = (PackagesTreeNodeBase)provider.ExtensionsTree.Nodes[0];

            // Act
            IVsExtensionsTreeNode searchNode = provider.Search("hello");

            // Assert
            Assert.IsNotNull(searchNode);
            Assert.IsInstanceOfType(searchNode, typeof(PackagesSearchNode));
            Assert.IsTrue(provider.ExtensionsTree.Nodes.Contains(searchNode));
        }
        public void AfterSearchIsDoneTheOriginalNodeIsResetToTheFirstPage()
        {
            // Arrange
            PackagesProviderBase provider = CreatePackagesProviderBase();

            provider.SelectedNode = (PackagesTreeNodeBase)provider.ExtensionsTree.Nodes[0];

            // Act
            provider.SelectedNode.CurrentPage = 2;

            // Assert
            Assert.Equal(2, provider.SelectedNode.CurrentPage);

            // Act
            provider.Search("hello");
            // clear the search
            provider.Search("");

            // Assert
            Assert.NotNull(provider.SelectedNode);
            Assert.Equal(1, provider.SelectedNode.CurrentPage);
        }
示例#13
0
 public MockTreeNode(IVsExtensionsTreeNode parent, PackagesProviderBase provider, IEnumerable <IPackage> packages, bool collapseVersions, bool supportsPrereleasePackages = true)
     : base(parent, provider, collapseVersions)
 {
     _supportsPrereleasePackages = supportsPrereleasePackages;
     _packages = packages;
 }
示例#14
0
 public MockTreeNode(IVsExtensionsTreeNode parent, PackagesProviderBase provider, int numberOfPackages, bool collapseVersions, bool supportsPrereleasePackages = true)
     : base(parent, provider, collapseVersions)
 {
     _numberOfPackages           = numberOfPackages;
     _supportsPrereleasePackages = supportsPrereleasePackages;
 }
示例#15
0
 public MockTreeNode(IVsExtensionsTreeNode parent, PackagesProviderBase provider, IEnumerable <IPackage> packages)
     : base(parent, provider)
 {
     _packages = packages;
 }
示例#16
0
 public MockTreeNode(IVsExtensionsTreeNode parent, PackagesProviderBase provider, int numberOfPackages)
     : base(parent, provider)
 {
     _numberOfPackages = numberOfPackages;
 }