public void Ctor_ArgChecks()
        {
            var validHost             = new ConfigurableHost();
            var bindingArgs           = new BindCommandArgs("key", "name", new ConnectionInformation(new Uri("http://server")));
            var slnBindOp             = new Mock <ISolutionBindingOperation>().Object;
            var nuGetOp               = new Mock <INuGetBindingOperation>().Object;
            var finder                = new ConfigurableUnboundProjectFinder();
            var bindingConfigProvider = new Mock <IBindingConfigProvider>().Object;

            // 1. Null host
            Action act = () => new BindingProcessImpl(null, bindingArgs, slnBindOp, nuGetOp, finder, bindingConfigProvider, SonarLintMode.Connected);

            act.Should().ThrowExactly <ArgumentNullException>().And.ParamName.Should().Be("host");

            // 2. Null binding args
            act = () => new BindingProcessImpl(validHost, null, slnBindOp, nuGetOp, finder, bindingConfigProvider, SonarLintMode.Connected);
            act.Should().ThrowExactly <ArgumentNullException>().And.ParamName.Should().Be("bindingArgs");

            // 3. Null solution binding operation
            act = () => new BindingProcessImpl(validHost, bindingArgs, null, nuGetOp, finder, bindingConfigProvider, SonarLintMode.Connected);
            act.Should().ThrowExactly <ArgumentNullException>().And.ParamName.Should().Be("solutionBindingOperation");

            // 4. Null NuGet operation
            act = () => new BindingProcessImpl(validHost, bindingArgs, slnBindOp, null, finder, bindingConfigProvider, SonarLintMode.Connected);
            act.Should().ThrowExactly <ArgumentNullException>().And.ParamName.Should().Be("nugetBindingOperation");

            // 5. Null binding info provider
            act = () => new BindingProcessImpl(validHost, bindingArgs, slnBindOp, nuGetOp, null, bindingConfigProvider, SonarLintMode.Connected);
            act.Should().ThrowExactly <ArgumentNullException>().And.ParamName.Should().Be("unboundProjectFinder");

            // 6. Null rules configuration provider
            act = () => new BindingProcessImpl(validHost, bindingArgs, slnBindOp, nuGetOp, finder, null, SonarLintMode.Connected);
            act.Should().ThrowExactly <ArgumentNullException>().And.ParamName.Should().Be("bindingConfigProvider");
        }
Пример #2
0
        public NewBindingWorkflow(IHost host, BindCommandArgs bindingArgs, IConfigurationProvider configWriter)
        {
            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }

            if (bindingArgs == null)
            {
                throw new ArgumentNullException(nameof(bindingArgs));
            }

            if (configWriter == null)
            {
                throw new ArgumentNullException(nameof(configWriter));
            }

            Debug.Assert(bindingArgs.ProjectKey != null);
            Debug.Assert(bindingArgs.ProjectName != null);
            Debug.Assert(bindingArgs.Connection != null);

            this.host        = host;
            this.bindingArgs = bindingArgs;
            this.writer      = configWriter;
        }
        public void BindingWorkflow_InstallPackages_Succeeds_SuccessPropertyIsFalse()
        {
            // Arrange
            var bindingArgs = new BindCommandArgs("projectKey", "projectName", new ConnectionInformation(new Uri("http://connected")));

            var slnBindOpMock = new Mock <ISolutionBindingOperation>();
            var nugetMock     = new Mock <INuGetBindingOperation>();

            nugetMock.Setup(x => x.InstallPackages(It.IsAny <ISet <Project> >(),
                                                   It.IsAny <IProgressController>(),
                                                   It.IsAny <IProgressStepExecutionEvents>(),
                                                   It.IsAny <CancellationToken>())).Returns(false);

            var testSubject = new BindingWorkflow(this.host, bindingArgs, slnBindOpMock.Object, nugetMock.Object);

            ProjectMock project1 = new ProjectMock("project1")
            {
                ProjectKind = ProjectSystemHelper.CSharpProjectKind
            };

            testSubject.BindingProjects.Clear();
            testSubject.BindingProjects.Add(project1);

            var progressEvents = new ConfigurableProgressStepExecutionEvents();
            var cts            = new CancellationTokenSource();

            testSubject.BindingOperationSucceeded = true;

            // Act
            testSubject.InstallPackages(new ConfigurableProgressController(), progressEvents, cts.Token);

            // Assert
            testSubject.BindingOperationSucceeded.Should().BeFalse();
        }
        public void BindingWorkflow_ArgChecks()
        {
            var validHost           = new ConfigurableHost();
            var bindingArgs         = new BindCommandArgs("key", "name", new ConnectionInformation(new Uri("http://server")));
            var slnBindOp           = new Mock <ISolutionBindingOperation>().Object;
            var nuGetOp             = new Mock <INuGetBindingOperation>().Object;
            var bindingInfoProvider = new ConfigurableSolutionBindingInformationProvider();

            // 1. Null host
            Action act = () => new BindingWorkflow(null, bindingArgs, slnBindOp, nuGetOp, bindingInfoProvider);

            act.Should().ThrowExactly <ArgumentNullException>().And.ParamName.Should().Be("host");

            // 2. Null binding args
            act = () => new BindingWorkflow(validHost, null, slnBindOp, nuGetOp, bindingInfoProvider);
            act.Should().ThrowExactly <ArgumentNullException>().And.ParamName.Should().Be("bindingArgs");

            // 3. Null solution binding operation
            act = () => new BindingWorkflow(validHost, bindingArgs, null, nuGetOp, bindingInfoProvider);
            act.Should().ThrowExactly <ArgumentNullException>().And.ParamName.Should().Be("solutionBindingOperation");

            // 4. Null NuGet operation
            act = () => new BindingWorkflow(validHost, bindingArgs, slnBindOp, null, bindingInfoProvider);
            act.Should().ThrowExactly <ArgumentNullException>().And.ParamName.Should().Be("nugetBindingOperation");

            // 5. Null binding info provider
            act = () => new BindingWorkflow(validHost, bindingArgs, slnBindOp, nuGetOp, null);
            act.Should().ThrowExactly <ArgumentNullException>().And.ParamName.Should().Be("bindingInformationProvider");
        }
Пример #5
0
        public void BindingController_BindCommand_Status()
        {
            // Arrange
            BindCommandArgs   bindingArgs = CreateBindingArguments("key1", "name1", "http://localhost");
            BindingController testSubject = this.PrepareCommandForExecution();

            // Case 1: All the requirements are set
            // Act + Assert
            testSubject.BindCommand.CanExecute(bindingArgs).Should().BeTrue("All the requirement should be satisfied for the command to be enabled");

            // Case 2: project is null
            // Act + Assert
            testSubject.BindCommand.CanExecute(null)
            .Should().BeFalse("Project is null");

            // Case 3: No connection
            this.host.TestStateManager.IsConnected = false;
            // Act + Assert
            testSubject.BindCommand.CanExecute(bindingArgs)
            .Should().BeFalse("No connection");

            // Case 4: busy
            this.host.TestStateManager.IsConnected = true;
            this.host.VisualStateManager.IsBusy    = true;
            // Act + Assert
            testSubject.BindCommand.CanExecute(bindingArgs)
            .Should().BeFalse("Connecting");
        }
Пример #6
0
        public void BindingController_BindCommand_Status_VsState()
        {
            // Arrange
            BindCommandArgs   bindArgs    = CreateBindingArguments("proj1", "name1", "http://localhost:9000");
            BindingController testSubject = this.PrepareCommandForExecution();
            ProjectMock       project1    = this.solutionMock.Projects.Single();

            // Case 1: SolutionExistsAndFullyLoaded is not active
            this.monitorSelection.SetContext(VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_guid, false);
            // Act + Assert
            testSubject.BindCommand.CanExecute(bindArgs).Should().BeFalse("No UI context: SolutionExistsAndFullyLoaded");

            // Case 2: SolutionExistsAndNotBuildingAndNotDebugging is not active
            this.monitorSelection.SetContext(VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_guid, true);
            this.monitorSelection.SetContext(VSConstants.UICONTEXT.SolutionExistsAndNotBuildingAndNotDebugging_guid, false);
            // Act + Assert
            testSubject.BindCommand.CanExecute(bindArgs).Should().BeFalse("No UI context: SolutionExistsAndNotBuildingAndNotDebugging");

            // Case 3: Non-managed project kind
            this.monitorSelection.SetContext(VSConstants.UICONTEXT.SolutionExistsAndNotBuildingAndNotDebugging_guid, true);
            this.projectSystemHelper.Projects = null;
            // Act + Assert
            testSubject.BindCommand.CanExecute(bindArgs).Should().BeFalse("No managed projects");

            // Case 4: No projects at all
            solutionMock.RemoveProject(project1);
            // Act + Assert
            testSubject.BindCommand.CanExecute(bindArgs).Should().BeFalse("No projects");
        }
Пример #7
0
        public void BindingController_BindingFinished()
        {
            // Arrange
            var bindingArgs = new BindCommandArgs("key1", "name1", new ConnectionInformation(new Uri("http://localhost")));

            BindingController testSubject = this.PrepareCommandForExecution();
            var progressEvents            = new ConfigurableProgressEvents();

            foreach (ProgressControllerResult result in Enum.GetValues(typeof(ProgressControllerResult)).OfType <ProgressControllerResult>())
            {
                // Arrange
                testSubject.SetBindingInProgress(progressEvents, bindingArgs);
                testSubject.IsBindingInProgress.Should().BeTrue();

                // Act
                progressEvents.SimulateFinished(result);

                // Assert
                testSubject.IsBindingInProgress.Should().BeFalse();

                if (result == ProgressControllerResult.Succeeded)
                {
                    this.host.TestStateManager.AssignedProjectKey.Should().Be("key1");
                }
                else
                {
                    this.host.TestStateManager.AssignedProjectKey.Should().BeNull();
                }
            }
        }
            private void ExecuteBindCommand()
            {
                if (this.host.ActiveSection == null)
                {
                    this.OnFinished(BindingRequestResult.NoActiveSection);
                    return;
                }

                ProjectViewModel boundProject = this.FindProject(this.binding.ServerUri, binding.ProjectKey);

                if (boundProject == null)
                {
                    // The user change binding
                    this.OnFinished(BindingRequestResult.RequestIsIrrelevant);
                    return;
                }

                BindCommandArgs bindingArgs = new BindCommandArgs(boundProject.Project?.Key, boundProject.Project?.Name, binding.CreateConnectionInformation());

                if (this.host.ActiveSection.BindCommand.CanExecute(bindingArgs))
                {
                    this.host.ActiveSection.BindCommand.Execute(bindingArgs);
                    this.OnFinished(BindingRequestResult.StartedUpdating);
                }
                else
                {
                    this.OnFinished(BindingRequestResult.CommandIsBusy);
                }
            }
        public void BindingWorkflow_ArgChecks()
        {
            var validHost   = new ConfigurableHost();
            var bindingArgs = new BindCommandArgs("key", "name", new ConnectionInformation(new Uri("http://server")));

            Exceptions.Expect <ArgumentNullException>(() => new BindingWorkflow(null, bindingArgs));
            Exceptions.Expect <ArgumentNullException>(() => new BindingWorkflow(validHost, null));
        }
        private BindingWorkflow CreateTestSubject(string projectKey = "anykey", string projectName = "anyname")
        {
            this.host.SonarQubeService = this.sonarQubeServiceMock.Object;

            var bindingArgs = new BindCommandArgs(projectKey, projectName, new ConnectionInformation(new Uri("http://connected")));

            return(new BindingWorkflow(this.host, bindingArgs));
        }
        public async Task DownloadQualityProfile_Success()
        {
            var configPersister = new ConfigurableConfigurationProvider();

            this.serviceProvider.RegisterService(typeof(IConfigurationPersister), configPersister);

            // Arrange
            const string QualityProfileName = "SQQualityProfileName";
            const string ProjectName        = "SQProjectName";

            Mock <INuGetBindingOperation> nuGetOpMock = new Mock <INuGetBindingOperation>();

            var notifications   = new ConfigurableProgressStepExecutionEvents();
            var progressAdapter = new FixedStepsProgressAdapter(notifications);

            var bindingConfig = new Mock <IBindingConfig>().Object;

            var language = Language.VBNET;
            SonarQubeQualityProfile profile = this.ConfigureQualityProfile(language, QualityProfileName);

            var configProviderMock = new Mock <IBindingConfigProvider>();

            configProviderMock.Setup(x => x.GetConfigurationAsync(profile, language, BindingConfiguration.Standalone, CancellationToken.None))
            .ReturnsAsync(bindingConfig);

            var bindingArgs = new BindCommandArgs("key", ProjectName, new ConnectionInformation(new Uri("http://connected")));
            var testSubject = this.CreateTestSubject(bindingArgs, nuGetOpMock.Object, configProviderMock.Object);

            ConfigureSupportedBindingProject(testSubject.InternalState, language);

            // Act
            var result = await testSubject.DownloadQualityProfileAsync(progressAdapter, CancellationToken.None);

            // Assert
            result.Should().BeTrue();
            testSubject.InternalState.BindingConfigs.Should().ContainKey(language);
            testSubject.InternalState.BindingConfigs[language].Should().Be(bindingConfig);
            testSubject.InternalState.BindingConfigs.Count().Should().Be(1);

            testSubject.InternalState.QualityProfiles[language].Should().Be(profile);

            notifications.AssertProgress(0.0, 1.0);
            notifications.AssertProgressMessages(Strings.DownloadingQualityProfileProgressMessage, string.Empty);

            this.outputWindowPane.AssertOutputStrings(1);
            var expectedOutput = string.Format(Strings.SubTextPaddingFormat,
                                               string.Format(Strings.QualityProfileDownloadSuccessfulMessageFormat, QualityProfileName, string.Empty, language.Name));

            this.outputWindowPane.AssertOutputStrings(expectedOutput);
        }
        private BindingProcessImpl CreateTestSubject(string projectKey = "anykey", string projectName = "anyname",
                                                     INuGetBindingOperation nuGetBindingOperation = null,
                                                     IBindingConfigProvider configProvider        = null)
        {
            nuGetBindingOperation = nuGetBindingOperation ?? new NoOpNuGetBindingOperation(this.host.Logger);
            configProvider        = configProvider ?? new Mock <IBindingConfigProvider>().Object;

            this.host.SonarQubeService = this.sonarQubeServiceMock.Object;
            var bindingArgs = new BindCommandArgs(projectKey, projectName, new ConnectionInformation(new Uri("http://connected")));

            var slnBindOperation = new SolutionBindingOperation(this.host, bindingArgs.Connection, projectKey, "projectName", SonarLintMode.LegacyConnected, this.host.Logger);
            var finder           = new ConfigurableUnboundProjectFinder();

            return(new BindingProcessImpl(this.host, bindingArgs, slnBindOperation, nuGetBindingOperation, finder, configProvider));
        }
        private BindingWorkflow CreateTestSubject(string projectKey = "anykey", string projectName = "anyname",
                                                  INuGetBindingOperation nuGetBindingOperation = null)
        {
            this.host.SonarQubeService = this.sonarQubeServiceMock.Object;

            var bindingArgs = new BindCommandArgs(projectKey, projectName, new ConnectionInformation(new Uri("http://connected")));

            var slnBindOperation = new SolutionBindingOperation(this.host, bindingArgs.Connection, projectKey, SonarLintMode.LegacyConnected);

            if (nuGetBindingOperation == null)
            {
                return(new BindingWorkflow(this.host, bindingArgs, slnBindOperation, new NoOpNuGetBindingOperation(this.host.Logger)));
            }
            return(new BindingWorkflow(this.host, bindingArgs, slnBindOperation, nuGetBindingOperation));
        }
Пример #14
0
        public void BindingController_BindingFinished_Navigation()
        {
            // Arrange
            var bindingArgs = new BindCommandArgs("key2", "", new ConnectionInformation(new Uri("http://myUri")));

            BindingController testSubject = this.PrepareCommandForExecution();
            var progressEvents            = new ConfigurableProgressEvents();
            var teController = new ConfigurableTeamExplorerController();

            var mefExports = MefTestHelpers.CreateExport <ITeamExplorerController>(teController);
            var mefModel   = ConfigurableComponentModel.CreateWithExports(mefExports);

            serviceProvider.RegisterService(typeof(SComponentModel), mefModel, replaceExisting: true);

            // Case 1: On non-successful binding no navigation will occur
            foreach (ProgressControllerResult nonSuccuess in new[] { ProgressControllerResult.Cancelled, ProgressControllerResult.Failed })
            {
                // Act
                testSubject.SetBindingInProgress(progressEvents, bindingArgs);
                progressEvents.SimulateFinished(nonSuccuess);

                // Assert
                teController.ShowConnectionsPageCallsCount.Should().Be(0);
                this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeFalse();
            }

            // Case 2: Has conflicts (should navigate to team explorer page)
            this.conflictsController.HasConflicts = true;

            // Act
            testSubject.SetBindingInProgress(progressEvents, bindingArgs);
            progressEvents.SimulateFinished(ProgressControllerResult.Succeeded);

            // Assert
            teController.ShowConnectionsPageCallsCount.Should().Be(1);
            this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeFalse();

            // Case 3: Has no conflicts (should navigate to solution explorer)
            this.conflictsController.HasConflicts = false;

            // Act
            testSubject.SetBindingInProgress(progressEvents, bindingArgs);
            progressEvents.SimulateFinished(ProgressControllerResult.Succeeded);

            // Assert
            teController.ShowConnectionsPageCallsCount.Should().Be(1);
            this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeTrue();
        }
        private BindingProcessImpl CreateTestSubject(BindCommandArgs bindingArgs = null,
                                                     INuGetBindingOperation nuGetBindingOperation = null,
                                                     IBindingConfigProvider configProvider        = null,
                                                     SonarLintMode mode = SonarLintMode.Connected)
        {
            bindingArgs           = bindingArgs ?? new BindCommandArgs("key", "name", new ConnectionInformation(new Uri("http://connected")));
            nuGetBindingOperation = nuGetBindingOperation ?? new NoOpNuGetBindingOperation(this.host.Logger);
            configProvider        = configProvider ?? new Mock <IBindingConfigProvider>().Object;

            this.host.SonarQubeService = this.sonarQubeServiceMock.Object;

            var slnBindOperation = new SolutionBindingOperation(this.host, SonarLintMode.LegacyConnected, this.host.Logger);
            var finder           = new ConfigurableUnboundProjectFinder();

            return(new BindingProcessImpl(this.host, bindingArgs, slnBindOperation, nuGetBindingOperation, finder, configProvider, mode));
        }
        public async Task DownloadQualityProfile_SavesConfiguration()
        {
            var configPersister = new ConfigurableConfigurationProvider();

            this.serviceProvider.RegisterService(typeof(IConfigurationPersister), configPersister);

            // Arrange
            const string QualityProfileName = "SQQualityProfileName";
            const string ProjectName        = "SQProjectName";

            Mock <INuGetBindingOperation> nuGetOpMock = new Mock <INuGetBindingOperation>();

            var notifications   = new ConfigurableProgressStepExecutionEvents();
            var progressAdapter = new FixedStepsProgressAdapter(notifications);

            var bindingConfig = new Mock <IBindingConfig>().Object;

            var language = Language.VBNET;
            SonarQubeQualityProfile profile = this.ConfigureQualityProfile(language, QualityProfileName);

            var configProviderMock = new Mock <IBindingConfigProvider>();

            configProviderMock.Setup(x => x.GetConfigurationAsync(profile, language, It.IsAny <BindingConfiguration>(), CancellationToken.None))
            .ReturnsAsync(bindingConfig);

            var bindingArgs = new BindCommandArgs("key", ProjectName, new ConnectionInformation(new Uri("http://connected")));
            var testSubject = this.CreateTestSubject(bindingArgs, nuGetOpMock.Object, configProviderMock.Object);

            ConfigureSupportedBindingProject(testSubject.InternalState, language);

            // Act
            await testSubject.DownloadQualityProfileAsync(progressAdapter, CancellationToken.None);

            // Assert
            configPersister.SavedProject.Should().NotBeNull();
            configPersister.SavedMode.Should().Be(SonarLintMode.Connected);

            var savedProject = configPersister.SavedProject;

            savedProject.ServerUri.Should().Be(bindingArgs.Connection.ServerUri);
            savedProject.Profiles.Should().HaveCount(1);
            savedProject.Profiles[Language.VBNET].ProfileKey.Should().Be(profile.Key);
            savedProject.Profiles[Language.VBNET].ProfileTimestamp.Should().Be(profile.TimeStamp);
        }
Пример #17
0
        public void BindingController_SetBindingInProgress()
        {
            // Arrange
            BindCommandArgs       bindingArgs           = CreateBindingArguments("key1", "name1", "http://localhost");
            ConnectionInformation otherConnection       = new ConnectionInformation(new Uri("http://otherConnection"));
            BindCommandArgs       bindingInProgressArgs = new BindCommandArgs("another.key", "another.name", otherConnection);

            BindingController testSubject = this.PrepareCommandForExecution();
            var progressEvents            = new ConfigurableProgressEvents();

            foreach (var controllerResult in (ProgressControllerResult[])Enum.GetValues(typeof(ProgressControllerResult)))
            {
                this.dteMock.ToolWindows.SolutionExplorer.Window.Active = false;

                // Sanity
                testSubject.BindCommand.CanExecute(bindingArgs).Should().BeTrue();

                // Act - disable
                testSubject.SetBindingInProgress(progressEvents, bindingInProgressArgs);

                // Assert
                testSubject.BindCommand.CanExecute(bindingArgs).Should().BeFalse("Binding is in progress so should not be enabled");

                // Act - finish
                progressEvents.SimulateFinished(controllerResult);

                // Assert
                testSubject.BindCommand.CanExecute(bindingArgs).Should().BeTrue("Binding is finished with result: {0}", controllerResult);
                if (controllerResult == ProgressControllerResult.Succeeded)
                {
                    this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeTrue("SolutionExplorer window supposed to be activated");
                }
                else
                {
                    this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeFalse("SolutionExplorer window is not supposed to be activated");
                }
            }
        }
Пример #18
0
        public void BindingController_BindCommand_Execution()
        {
            // Arrange
            BindingController testSubject = this.PrepareCommandForExecution();

            // Act
            BindCommandArgs bindingArgs1 = CreateBindingArguments("1", "name1", "http://localhost");

            testSubject.BindCommand.Execute(bindingArgs1);

            // Assert
            this.workflow.BindingArgs.ProjectKey.Should().Be("1");
            this.workflow.BindingArgs.ProjectName.Should().Be("name1");

            // Act, bind a different project
            BindCommandArgs bingingArgs2 = CreateBindingArguments("2", "name2", "http://localhost");

            testSubject.BindCommand.Execute(bingingArgs2);

            // Assert
            this.workflow.BindingArgs.ProjectKey.Should().Be("2");
            this.workflow.BindingArgs.ProjectName.Should().Be("name2");
        }
Пример #19
0
        public void BindingController_SetBindingInProgress_Notifications()
        {
            // Arrange
            var bindingArgs = new BindCommandArgs("key2", "", new ConnectionInformation(new Uri("http://myUri")));

            BindingController testSubject = this.PrepareCommandForExecution();
            var section = ConfigurableSectionController.CreateDefault();

            this.host.SetActiveSection(section);
            var progressEvents = new ConfigurableProgressEvents();

            this.host.ActiveSection.UserNotifications.ShowNotificationError("Need to make sure that this is clear once started", NotificationIds.FailedToBindId, new RelayCommand(() => { }));
            ConfigurableUserNotification userNotifications = (ConfigurableUserNotification)section.UserNotifications;

            foreach (ProgressControllerResult result in Enum.GetValues(typeof(ProgressControllerResult)).OfType <ProgressControllerResult>())
            {
                // Act - start
                testSubject.SetBindingInProgress(progressEvents, bindingArgs);

                // Assert
                userNotifications.AssertNoNotification(NotificationIds.FailedToBindId);

                // Act - finish
                progressEvents.SimulateFinished(result);

                // Assert
                if (result == ProgressControllerResult.Succeeded)
                {
                    userNotifications.AssertNoNotification(NotificationIds.FailedToBindId);
                }
                else
                {
                    userNotifications.AssertNotification(NotificationIds.FailedToBindId, Strings.FailedToToBindSolution);
                }
            }
        }
        public void InstallPackages_Succeeds_SuccessPropertyIsFalse()
        {
            // Arrange
            var bindingArgs = new BindCommandArgs("projectKey", "projectName", new ConnectionInformation(new Uri("http://connected")));

            var slnBindOpMock = new Mock <ISolutionBindingOperation>();
            var nugetMock     = new Mock <INuGetBindingOperation>();

            nugetMock.Setup(x => x.InstallPackages(It.IsAny <ISet <Project> >(),
                                                   It.IsAny <IProgress <FixedStepsProgress> >(),
                                                   It.IsAny <CancellationToken>())).Returns(false);
            var finder         = new ConfigurableUnboundProjectFinder();
            var configProvider = new Mock <IBindingConfigProvider>();

            var testSubject = new BindingProcessImpl(this.host, bindingArgs, slnBindOpMock.Object, nugetMock.Object, finder, configProvider.Object, SonarLintMode.Connected);

            ProjectMock project1 = new ProjectMock("project1")
            {
                ProjectKind = ProjectSystemHelper.CSharpProjectKind
            };

            testSubject.InternalState.BindingProjects.Clear();
            testSubject.InternalState.BindingProjects.Add(project1);

            var progressEvents  = new ConfigurableProgressStepExecutionEvents();
            var progressAdapter = new FixedStepsProgressAdapter(progressEvents);
            var cts             = new CancellationTokenSource();

            testSubject.InternalState.BindingOperationSucceeded = true;

            // Act
            testSubject.InstallPackages(progressAdapter, cts.Token);

            // Assert
            testSubject.InternalState.BindingOperationSucceeded.Should().BeFalse();
        }
Пример #21
0
 void IBindingWorkflowExecutor.BindProject(BindCommandArgs bindingArgs)
 {
     bindingArgs.Should().NotBeNull();
     this.BindingArgs = bindingArgs;
 }