public void OnConnectWithoutSolutionOpenShouldNotAssociate() { mockConfiguration.Setup(x => x.ReadSetting(It.IsAny <Context>(), It.IsAny <string>(), It.IsAny <string>())).Returns(new SonarQubeProperties { Value = "dummy" }); mockRest.Setup(x => x.GetProjectsList(It.IsAny <ISonarConfiguration>())).Returns(this.CreatProjects()); mockRest.Setup(x => x.AuthenticateUser(It.IsAny <ISonarConfiguration>())).Returns(true); AuthtenticationHelper.EstablishAConnection(mockRest.Object, "as", "asda", "asd"); var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, locaAnalyser: mockAnalyser.Object, pluginManager: mockPluginManager.Object); associationModel.VsHelper = mockVsHelper.Object; associationModel.OnConnectToSonar(false); WaitForCompletionOrTimeout(associationModel); Assert.That(associationModel.AvailableProjects.Count, Is.EqualTo(2)); Assert.That(associationModel.AssociationModule.IsAssociated, Is.False); Assert.That(associationModel.SelectedProjectInView, Is.Null); Assert.That(associationModel.SelectedProjectName, Is.Null); Assert.That(associationModel.SelectedProjectKey, Is.Null); Assert.That(associationModel.SelectedProjectVersion, Is.Null); Assert.That(associationModel.IsConnected, Is.True); }
public void OnConnectWithSolutionOpenShouldAssociateToANormalProject() { mockConfiguration.Setup(x => x.ReadSetting(It.IsAny <Context>(), It.IsAny <string>(), It.IsAny <string>())).Returns(new SonarQubeProperties { Value = "tekla.utilities:project" }); mockRest.Setup(x => x.GetProjectsList(It.IsAny <ISonarConfiguration>())).Returns(this.CreatProjects()); mockRest.Setup(x => x.AuthenticateUser(It.IsAny <ISonarConfiguration>())).Returns(true); mockVsHelper.Setup(x => x.ActiveSolutionName()).Returns("solutionaname"); mockVsHelper.Setup(x => x.ActiveSolutionPath()).Returns("solutionapath"); AuthtenticationHelper.EstablishAConnection(mockRest.Object, "as", "asda", "asd"); var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, mockSourceProvider.Object, mockPlugin.Object, mockAnalyser.Object); associationModel.VsHelper = mockVsHelper.Object; associationModel.IsSolutionOpen = true; associationModel.OnConnectToSonar(false); WaitForCompletionOrTimeout(associationModel); Assert.That(associationModel.AssociationModule.IsAssociated, Is.True); Assert.That(associationModel.ErrorIsFound, Is.False); Assert.That(associationModel.ShowRightFlyout, Is.False); Assert.That(associationModel.StatusMessage, Is.EqualTo("successfully associated with : project")); Assert.That(associationModel.IsConnected, Is.True); Assert.That(associationModel.AssociationModule.AssociatedProject.Name, Is.EqualTo("project")); Assert.That(associationModel.AssociationModule.AssociatedProject.Key, Is.EqualTo("tekla.utilities:project")); }
public void OnConnectWithSolutionOpenShouldAssociateToBranchWhenBranchIsAvailableInServer() { mockConfiguration.Setup(x => x.ReadSetting(It.IsAny <Context>(), It.IsAny <string>(), It.IsAny <string>())).Returns(new SonarQubeProperties { Value = "project_Main" }); mockRest.Setup(x => x.GetProjectsList(It.IsAny <ISonarConfiguration>())).Returns(this.CreatProjects()); mockRest.Setup(x => x.AuthenticateUser(It.IsAny <ISonarConfiguration>())).Returns(true); mockVsHelper.Setup(x => x.ActiveSolutionName()).Returns("solutionaname"); mockVsHelper.Setup(x => x.ActiveSolutionPath()).Returns("solutionapath"); mockSourceProvider.Setup(x => x.GetBranch()).Returns("feature_A"); AuthtenticationHelper.EstablishAConnection(mockRest.Object, "as", "asda", "asd"); var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, mockSourceProvider.Object, mockPlugin.Object, mockAnalyser.Object); associationModel.VsHelper = mockVsHelper.Object; associationModel.IsSolutionOpen = true; associationModel.OnConnectToSonar(false); WaitForCompletionOrTimeout(associationModel); Assert.That(associationModel.AssociationModule.IsAssociated, Is.True); Assert.That(associationModel.AssociationModule.AssociatedProject.Name, Is.EqualTo("project feature_A")); Assert.That(associationModel.AssociationModule.AssociatedProject.Key, Is.EqualTo("tekla.utilities:project:feature_A")); Assert.That(associationModel.IsConnected, Is.True); }
/// <summary> /// Called when [connect to sonar]. /// </summary> public void OnConnectToSonar() { foreach (IModelBase model in modelPool) { try { model.OnConnectToSonar(AuthtenticationHelper.AuthToken, this.model.AvailableProjects, this.pluginManager.IssueTrackerPlugins); } catch (Exception ex) { this.logger.ReportMessage(new Message { Id = "Association Model", Data = "Exception for model while connecting : " + model.ToString() }); this.logger.ReportException(ex); } } }
public void OnConnectToSonarIfAssociationIsMadeItShouldResetItIfProjectNotFound() { mockRest.Setup(x => x.GetProjectsList(It.IsAny <ISonarConfiguration>())).Returns(this.CreatProjects()); mockRest.Setup(x => x.AuthenticateUser(It.IsAny <ISonarConfiguration>())).Returns(true); mockVsHelper.Setup(x => x.ActiveSolutionName()).Returns("solutionaname"); mockVsHelper.Setup(x => x.ActiveSolutionPath()).Returns("solutionapath"); AuthtenticationHelper.EstablishAConnection(mockRest.Object, "as", "asda", "asd"); var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, mockSourceProvider.Object, mockPlugin.Object, locaAnalyser: mockAnalyser.Object); associationModel.VsHelper = mockVsHelper.Object; associationModel.IsSolutionOpen = true; associationModel.OnConnectToSonar(false); WaitForCompletionOrTimeout(associationModel); Assert.That(associationModel.AssociationModule.IsAssociated, Is.False); Assert.That(associationModel.IsConnected, Is.True); Assert.That(associationModel.ErrorIsFound, Is.True); Assert.That(associationModel.ShowRightFlyout, Is.True); Assert.That(associationModel.StatusMessage, Is.EqualTo("Was unable to associate with sonar project, use project association dialog to choose a project or to provision project")); Assert.That(associationModel.AssociationModule.AssociatedProject, Is.Null); }
public void OnConnectWithSolutionOpenShouldAssociateToMasterWhenBranchIsNotAvailableInServer() { mockConfiguration.Setup(x => x.ReadSetting(It.IsAny<Context>(), It.IsAny<string>(), It.IsAny<string>())).Returns(new SonarQubeProperties { Value = "project_Main" }); mockRest.Setup(x => x.GetProjectsList(It.IsAny<ISonarConfiguration>())).Returns(this.CreatProjects()); mockRest.Setup(x => x.AuthenticateUser(It.IsAny<ISonarConfiguration>())).Returns(true); mockVsHelper.Setup(x => x.ActiveSolutionName()).Returns("solutionaname"); mockVsHelper.Setup(x => x.ActiveSolutionPath()).Returns("solutionapath"); mockSourceProvider.Setup(x => x.GetBranch()).Returns("feature/1234-asdas"); AuthtenticationHelper.EstablishAConnection(mockRest.Object, "as", "asda", "asd"); var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, mockSourceProvider.Object, mockPlugin.Object, mockAnalyser.Object); associationModel.VsHelper = mockVsHelper.Object; associationModel.IsSolutionOpen = true; associationModel.OnConnectToSonar(false); WaitForCompletionOrTimeout(associationModel); Assert.That(associationModel.AssociationModule.IsAssociated, Is.True); Assert.That(associationModel.AssociationModule.AssociatedProject.Name, Is.EqualTo("project master")); Assert.That(associationModel.AssociationModule.AssociatedProject.Key, Is.EqualTo("tekla.utilities:project:master")); Assert.That(associationModel.IsConnected, Is.True); }
public void OnConnectWithSolutionOpenShouldAssociateToANormalProject() { mockConfiguration.Setup(x => x.ReadSetting(It.IsAny<Context>(), It.IsAny<string>(), It.IsAny<string>())).Returns(new SonarQubeProperties { Value = "tekla.utilities:project" }); mockRest.Setup(x => x.GetProjectsList(It.IsAny<ISonarConfiguration>())).Returns(this.CreatProjects()); mockRest.Setup(x => x.AuthenticateUser(It.IsAny<ISonarConfiguration>())).Returns(true); mockVsHelper.Setup(x => x.ActiveSolutionName()).Returns("solutionaname"); mockVsHelper.Setup(x => x.ActiveSolutionPath()).Returns("solutionapath"); AuthtenticationHelper.EstablishAConnection(mockRest.Object, "as", "asda", "asd"); var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, mockSourceProvider.Object, mockPlugin.Object, mockAnalyser.Object); associationModel.VsHelper = mockVsHelper.Object; associationModel.IsSolutionOpen = true; associationModel.OnConnectToSonar(false); WaitForCompletionOrTimeout(associationModel); Assert.That(associationModel.AssociationModule.IsAssociated, Is.True); Assert.That(associationModel.ErrorIsFound, Is.False); Assert.That(associationModel.ShowRightFlyout, Is.False); Assert.That(associationModel.StatusMessage, Is.EqualTo("successfully associated with : project")); Assert.That(associationModel.IsConnected, Is.True); Assert.That(associationModel.AssociationModule.AssociatedProject.Name, Is.EqualTo("project")); Assert.That(associationModel.AssociationModule.AssociatedProject.Key, Is.EqualTo("tekla.utilities:project")); }
public void OnConnectWithoutSolutionOpenShouldNotAssociate() { mockConfiguration.Setup(x => x.ReadSetting(It.IsAny<Context>(), It.IsAny<string>(), It.IsAny<string>())).Returns(new SonarQubeProperties { Value = "dummy" }); mockRest.Setup(x => x.GetProjectsList(It.IsAny<ISonarConfiguration>())).Returns(this.CreatProjects()); mockRest.Setup(x => x.AuthenticateUser(It.IsAny<ISonarConfiguration>())).Returns(true); AuthtenticationHelper.EstablishAConnection(mockRest.Object, "as", "asda", "asd"); var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, locaAnalyser: mockAnalyser.Object, pluginManager:mockPluginManager.Object); associationModel.VsHelper = mockVsHelper.Object; associationModel.OnConnectToSonar(false); WaitForCompletionOrTimeout(associationModel); Assert.That(associationModel.AvailableProjects.Count, Is.EqualTo(2)); Assert.That(associationModel.AssociationModule.IsAssociated, Is.False); Assert.That(associationModel.SelectedProjectInView, Is.Null); Assert.That(associationModel.SelectedProjectName, Is.Null); Assert.That(associationModel.SelectedProjectKey, Is.Null); Assert.That(associationModel.SelectedProjectVersion, Is.Null); Assert.That(associationModel.IsConnected, Is.True); }
public void OnConnectToSonarIfAssociationIsMadeItShouldResetItIfProjectNotFound() { mockRest.Setup(x => x.GetProjectsList(It.IsAny<ISonarConfiguration>())).Returns(this.CreatProjects()); mockRest.Setup(x => x.AuthenticateUser(It.IsAny<ISonarConfiguration>())).Returns(true); mockVsHelper.Setup(x => x.ActiveSolutionName()).Returns("solutionaname"); mockVsHelper.Setup(x => x.ActiveSolutionPath()).Returns("solutionapath"); AuthtenticationHelper.EstablishAConnection(mockRest.Object, "as", "asda", "asd"); var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, mockSourceProvider.Object, mockPlugin.Object, locaAnalyser: mockAnalyser.Object); associationModel.VsHelper = mockVsHelper.Object; associationModel.IsSolutionOpen = true; associationModel.OnConnectToSonar(false); WaitForCompletionOrTimeout(associationModel); Assert.That(associationModel.AssociationModule.IsAssociated, Is.False); Assert.That(associationModel.IsConnected, Is.True); Assert.That(associationModel.ErrorIsFound, Is.True); Assert.That(associationModel.ShowRightFlyout, Is.True); Assert.That(associationModel.StatusMessage, Is.EqualTo("Was unable to associate with sonar project, use project association dialog to choose a project or to provision project")); Assert.That(associationModel.AssociationModule.AssociatedProject, Is.Null); }