public NuGetSearchTask(NuGetSearchProvider provider, uint cookie, IVsSearchQuery searchQuery, IVsSearchProviderCallback searchCallback, OleMenuCommand managePackageDialogCommand, OleMenuCommand managePackageForSolutionDialogCommand)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }
            if (searchQuery == null)
            {
                throw new ArgumentNullException("searchQuery");
            }
            if (searchCallback == null)
            {
                throw new ArgumentNullException("searchCallback");
            }
            if (managePackageDialogCommand == null)
            {
                throw new ArgumentNullException("managePackageDialogCommand");
            }
            if (managePackageForSolutionDialogCommand == null)
            {
                throw new ArgumentNullException("managePackageForSolutionDialogCommand");
            }
            _provider = provider;
            _searchCallback = searchCallback;
            _managePackageDialogCommand = managePackageDialogCommand;
            _managePackageForSolutionDialogCommand = managePackageForSolutionDialogCommand;

            SearchQuery = searchQuery;
            Id = cookie;
            ErrorCode = 0;

            SetStatus(VsSearchTaskStatus.Created);
        }
        public NuGetSearchTask(NuGetSearchProvider provider, uint cookie, IVsSearchQuery searchQuery, IVsSearchProviderCallback searchCallback, OleMenuCommand managePackageDialogCommand, OleMenuCommand managePackageForSolutionDialogCommand)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }
            if (searchQuery == null)
            {
                throw new ArgumentNullException("searchQuery");
            }
            if (searchCallback == null)
            {
                throw new ArgumentNullException("searchCallback");
            }
            if (managePackageDialogCommand == null)
            {
                throw new ArgumentNullException("managePackageDialogCommand");
            }
            if (managePackageForSolutionDialogCommand == null)
            {
                throw new ArgumentNullException("managePackageForSolutionDialogCommand");
            }
            _provider                              = provider;
            _searchCallback                        = searchCallback;
            _managePackageDialogCommand            = managePackageDialogCommand;
            _managePackageForSolutionDialogCommand = managePackageForSolutionDialogCommand;

            SearchQuery = searchQuery;
            Id          = cookie;
            ErrorCode   = 0;

            SetStatus(VsSearchTaskStatus.Created);
        }
        public NuGetStaticSearchResult(DTE dte, string searchText, NuGetSearchProvider provider)
        {
            _dte = dte;
            _searchText = searchText;

            DisplayText = String.Format(CultureInfo.CurrentCulture, Resources.NuGetStaticResult_DisplayText, searchText);
            PersistenceData = searchText;
            SearchProvider = provider;
        }
        public NuGetStaticSearchResult(DTE dte, string searchText, NuGetSearchProvider provider)
        {
            _dte        = dte;
            _searchText = searchText;

            DisplayText     = String.Format(CultureInfo.CurrentCulture, Resources.NuGetStaticResult_DisplayText, searchText);
            PersistenceData = searchText;
            SearchProvider  = provider;
        }
Exemple #5
0
        public NuGetSearchTask(DTE dte, NuGetSearchProvider provider, uint cookie, IVsSearchQuery searchQuery, IVsSearchProviderCallback searchCallback)
        {
            _provider       = provider;
            _dte            = dte;
            _searchCallback = searchCallback;

            SearchQuery = searchQuery;
            Id          = cookie;
            ErrorCode   = 0;

            SetStatus(VsSearchTaskStatus.Created);
        }
        public void NuGetSearchTaskValidateStop()
        {
            // Arrange
            Mock<IVsSearchQuery> searchQuery = new Mock<IVsSearchQuery>();
            Mock<IVsSearchProviderCallback> searchCallback = new Mock<IVsSearchProviderCallback>();
            Mock<OleMenuCommand> managePackageCommand = new Mock<OleMenuCommand>(null, null);
            Mock<OleMenuCommandService> menuCommandService = new Mock<OleMenuCommandService>(new Mock<IServiceProvider>().Object);
            NuGetSearchProvider provider = new NuGetSearchProvider(menuCommandService.Object, managePackageCommand.Object, managePackageCommand.Object);
            NuGetSearchTask searchTask = new NuGetSearchTask(provider, 1, searchQuery.Object, searchCallback.Object, managePackageCommand.Object, managePackageCommand.Object);

            // Act
            searchTask.Stop();

            // Assert
            Assert.Equal((uint)__VSSEARCHTASKSTATUS.STS_STOPPED, searchTask.Status);
        }
        public void NuGetSearchTaskCtorNullParameterThrows()
        {
            // Arrange
            Mock<IVsSearchQuery> searchQuery = new Mock<IVsSearchQuery>();
            Mock<IVsSearchProviderCallback> searchCallback = new Mock<IVsSearchProviderCallback>();
            Mock<OleMenuCommand> managePackageCommand = new Mock<OleMenuCommand>(null, null);
            Mock<OleMenuCommandService> menuCommandService = new Mock<OleMenuCommandService>(new Mock<IServiceProvider>().Object);
            NuGetSearchProvider provider = new NuGetSearchProvider(menuCommandService.Object, managePackageCommand.Object, managePackageCommand.Object);

            // Act & Assert
            ExceptionAssert.ThrowsArgNull(() => new NuGetSearchTask(null, 1, searchQuery.Object, searchCallback.Object, managePackageCommand.Object, managePackageCommand.Object), "provider");
            ExceptionAssert.ThrowsArgNull(() => new NuGetSearchTask(provider, 1, null, searchCallback.Object, managePackageCommand.Object, managePackageCommand.Object), "searchQuery");
            ExceptionAssert.ThrowsArgNull(() => new NuGetSearchTask(provider, 1, searchQuery.Object, null, managePackageCommand.Object, managePackageCommand.Object), "searchCallback");
            ExceptionAssert.ThrowsArgNull(() => new NuGetSearchTask(provider, 1, searchQuery.Object, searchCallback.Object, null, managePackageCommand.Object), "managePackageDialogCommand");
            ExceptionAssert.ThrowsArgNull(() => new NuGetSearchTask(provider, 1, searchQuery.Object, searchCallback.Object, managePackageCommand.Object, null), "managePackageForSolutionDialogCommand");
        }
        public void NuGetSearchTaskValidateStart()
        {
            // Arrange
            Mock<IVsSearchQuery> searchQuery = new Mock<IVsSearchQuery>();
            Mock<IVsSearchProviderCallback> searchCallback = new Mock<IVsSearchProviderCallback>();
            searchCallback.Setup(s => s.ReportComplete(It.IsAny<IVsSearchTask>(), It.IsAny<uint>()));
            OleMenuCommand managePackageCommand = new OleMenuCommand(null, new System.ComponentModel.Design.CommandID(Guid.Empty, 0));
            Mock<OleMenuCommandService> menuCommandService = new Mock<OleMenuCommandService>(new Mock<IServiceProvider>().Object);
            NuGetSearchProvider provider = new NuGetSearchProvider(menuCommandService.Object, managePackageCommand, managePackageCommand);
            NuGetSearchTask searchTask = new NuGetSearchTask(provider, 1, searchQuery.Object, searchCallback.Object, managePackageCommand, managePackageCommand);

            // Act
            searchTask.Start();

            // Assert
            Assert.Equal(__VSSEARCHTASKSTATUS.STS_COMPLETED, (__VSSEARCHTASKSTATUS)searchTask.Status);
        }
        public NuGetStaticSearchResult(string searchText, NuGetSearchProvider provider, OleMenuCommand supportedManagePackageCommand)
        {
            if (searchText == null)
            {
                throw new ArgumentNullException("searchText");
            }
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }
            if (supportedManagePackageCommand == null)
            {
                throw new ArgumentNullException("supportedManagePackageCommand");
            }

            _searchText = searchText;
            _supportedManagePackageCommand = supportedManagePackageCommand;

            DisplayText = String.Format(CultureInfo.CurrentCulture, VsResources.NuGetStaticResult_DisplayText, searchText);
            _searchProvider = provider;
        }
        public NuGetStaticSearchResult(string searchText, NuGetSearchProvider provider, OleMenuCommand supportedManagePackageCommand)
        {
            if (searchText == null)
            {
                throw new ArgumentNullException("searchText");
            }
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }
            if (supportedManagePackageCommand == null)
            {
                throw new ArgumentNullException("supportedManagePackageCommand");
            }

            _searchText = searchText;
            _supportedManagePackageCommand = supportedManagePackageCommand;

            DisplayText     = String.Format(CultureInfo.CurrentCulture, VsResources.NuGetStaticResult_DisplayText, searchText);
            _searchProvider = provider;
        }
        public void NuGetSearchTaskValidatePublicPropertiesGet()
        {
            // Arrange
            var searchQuery = new Mock<IVsSearchQuery>();
            searchQuery.Setup(s => s.SearchString).Returns(DummyText);
            searchQuery.Setup(s => s.ParseError).Returns(0);
            Mock<IVsSearchProviderCallback> searchCallback = new Mock<IVsSearchProviderCallback>();
            Mock<OleMenuCommand> managePackageCommand = new Mock<OleMenuCommand>(null, null);
            Mock<OleMenuCommandService> menuCommandService = new Mock<OleMenuCommandService>(new Mock<IServiceProvider>().Object);
            NuGetSearchProvider provider = new NuGetSearchProvider(menuCommandService.Object, managePackageCommand.Object, managePackageCommand.Object);
            uint cookie = 1;

            // Act
            NuGetSearchTask searchTask = new NuGetSearchTask(provider, cookie, searchQuery.Object, searchCallback.Object, managePackageCommand.Object, managePackageCommand.Object);

            // Assert
            Assert.Equal(0 /* No Error */, searchTask.ErrorCode);
            Assert.Equal(cookie, searchTask.Id);
            Assert.Equal(DummyText, searchTask.SearchQuery.SearchString);
            Assert.Equal(0u /* No Error */, searchTask.SearchQuery.ParseError);
            Assert.Equal((uint)__VSSEARCHTASKSTATUS.STS_CREATED, searchTask.Status);
        }