예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }