/// <summary> /// Initializes a new instance of the <see cref="AnalysisOptionsViewModel" /> class. /// </summary> /// <param name="viewModel">The view Model.</param> /// <param name="configurationHelper">The configuration helper.</param> public AnalysisOptionsViewModel( VSonarQubeOptionsViewModel viewModel, IConfigurationHelper configurationHelper) { this.configurationHelper = configurationHelper; this.viewModel = viewModel; this.TimeoutValue = 10; this.IsSolutionAnalysisChecked = true; this.IsProjectAnalysisChecked = true; this.Header = "Analysis Options"; this.ForeGroundColor = Colors.Black; this.BackGroundColor = Colors.White; this.DownloadWrapperCommand = new RelayCommand(this.OnDownloadWrapperCommand); SonarQubeViewModel.RegisterNewViewModelInPool(this); AssociationModel.RegisterNewModelInPool(this); try { this.ReloadDataFromDisk(null); } catch (Exception ex) { Debug.WriteLine("Failed to reload from disk : " + ex.Message); } }
/// <summary> /// Initializes a new instance of the <see cref="LicenseViewerViewModel" /> class. /// </summary> /// <param name="plugincontroller">The plugincontroller.</param> /// <param name="helper">The helper.</param> public LicenseViewerViewModel( PluginManagerModel plugincontroller, IConfigurationHelper helper) { this.Header = "License Manager"; this.pluginModel = plugincontroller; this.confHelper = helper; this.ForeGroundColor = Colors.Black; this.ForeGroundColor = Colors.Black; this.AvailableLicenses = new ObservableCollection <VsLicense>(); this.RefreshCommand = new RelayCommand(this.GetLicensesFromServer); this.GenerateTokenCommand = new RelayCommand(this.OnGenerateTokenCommand, () => this.SelectedLicense != null); try { this.GetLicensesFromServer(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } // register model so it can be updated AssociationModel.RegisterNewModelInPool(this); SonarQubeViewModel.RegisterNewViewModelInPool(this); }
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> /// Initializes a new instance of the <see cref="GeneralConfigurationViewModel" /> class. /// </summary> /// <param name="viewModel">The view model.</param> /// <param name="restService">The rest service.</param> /// <param name="configurationHelper">The configuration helper.</param> /// <param name="notificationManager">The notification manager.</param> public GeneralConfigurationViewModel( VSonarQubeOptionsViewModel viewModel, ISonarRestService restService, IConfigurationHelper configurationHelper, INotificationManager notificationManager) { this.Header = "General Settings"; this.UserName = string.Empty; this.Password = string.Empty; this.viewModel = viewModel; this.restService = restService; this.configurationHelper = configurationHelper; this.notificationManager = notificationManager; this.ClearCacheCommand = new RelayCommand(this.OnClearCacheCommand); this.TestConnectionCommand = new RelayCommand <object>(this.OnTestAndSavePassword); this.ClearCredentials = new RelayCommand(this.OnClearCredentials); this.BackGroundColor = Colors.White; this.ForeGroundColor = Colors.Black; this.GetCredentials(); this.ReloadDataFromDisk(null); // register model AssociationModel.RegisterNewModelInPool(this); SonarQubeViewModel.RegisterNewViewModelInPool(this); }
public void OnSolutionOpenButProjectNotFoundItShouldNotAssociate() { 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"); mockPlugin.Setup(x => x.SourceCodePlugins).Returns(new List <ISourceVersionPlugin>()); 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.AssociationModule.AssociatedProject = new Resource(); associationModel.SelectedProjectKey = "jasd"; associationModel.SelectedProjectName = "jasd"; associationModel.SelectedProjectVersion = "jasd"; associationModel.VsHelper = mockVsHelper.Object; associationModel.IsSolutionOpen = true; associationModel.IsConnected = true; associationModel.OnSolutionOpen("abc", "dfc", "sds"); 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); Assert.That(associationModel.SelectedProjectName, Is.Null); Assert.That(associationModel.SelectedProjectKey, Is.Null); Assert.That(associationModel.SelectedProjectVersion, Is.Null); }
/// <summary> /// Initializes a new instance of the <see cref="IssuesSearchViewModel" /> class. /// </summary> /// <param name="searchModel">The search model.</param> /// <param name="notificationManager">The notification manager.</param> /// <param name="configurationHelper">The configuration helper.</param> /// <param name="restService">The rest service.</param> /// <param name="translator">The translator.</param> /// <param name="analyser">The analyser.</param> public IssuesSearchViewModel( IssuesSearchModel searchModel, INotificationManager notificationManager, IConfigurationHelper configurationHelper, ISonarRestService restService, ISQKeyTranslator translator, ISonarLocalAnalyser analyser, IList <IIssueTrackerPlugin> plugins) { this.restService = restService; this.notificationManager = notificationManager; this.configurationHelper = configurationHelper; this.searchModel = searchModel; this.Header = "Issues Search"; this.AvailableProjects = new List <Resource>(); this.AssigneeList = new ObservableCollection <User>(); this.AvailableSearches = new ObservableCollection <string>(); this.IssuesGridView = new IssueGridViewModel("SearchView", false, configurationHelper, restService, notificationManager, translator); this.savedSearchModel = new SearchModel(this.AvailableSearches); this.IssuesGridView.ContextMenuItems = this.CreateRowContextMenu(restService, translator, analyser, plugins); this.IssuesGridView.ShowContextMenu = true; this.IssuesGridView.ShowLeftFlyoutEvent += this.ShowHideLeftFlyout; this.SizeOfFlyout = 0; this.InitCommanding(); this.ForeGroundColor = Colors.Black; this.BackGroundColor = Colors.White; this.CreatedBeforeDate = DateTime.Now; this.CreatedSinceDate = DateTime.Now; SonarQubeViewModel.RegisterNewViewModelInPool(this); }
/// <summary> /// Initializes a new instance of the <see cref="IssuesSearchViewModel" /> class. /// </summary> /// <param name="searchModel">The search model.</param> /// <param name="notificationManager">The notification manager.</param> /// <param name="configurationHelper">The configuration helper.</param> /// <param name="restService">The rest service.</param> /// <param name="translator">The translator.</param> public IssuesSearchViewModel( IssuesSearchModel searchModel, INotificationManager notificationManager, IConfigurationHelper configurationHelper, ISonarRestService restService, ISQKeyTranslator translator) { this.notificationManager = notificationManager; this.configurationHelper = configurationHelper; this.searchModel = searchModel; this.Header = "Issues Search"; this.AvailableActionPlans = new ObservableCollection <SonarActionPlan>(); this.UsersList = new ObservableCollection <User>(); this.IssuesGridView = new IssueGridViewModel(true, "SearchView", false, configurationHelper, restService, notificationManager, translator); this.IssuesGridView.ShowLeftFlyoutEvent += this.ShowHideLeftFlyout; this.SizeOfFlyout = 0; this.InitCommanding(); this.ForeGroundColor = Colors.Black; this.BackGroundColor = Colors.White; this.CreatedBeforeDate = DateTime.Now; this.CreatedSinceDate = DateTime.Now; SonarQubeViewModel.RegisterNewViewModelInPool(this); }
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); }
/// <summary> /// The update data context. /// </summary> /// <param name="dataModelIn"> /// The data model in. /// </param> public void UpdateDataContext(SonarQubeViewModel dataModelIn) { // bind data with view model this.dataModel = dataModelIn; this.DataContext = null; this.DataContext = dataModelIn; }
public void CreatesASingleProjectWhenOnlyBranches() { var mockTranslator = new Mock<ISQKeyTranslator>(); var mockRest = new Mock<ISonarRestService>(); var mockLogger = new Mock<INotificationManager>(); var mockConfiguration = new Mock<IConfigurationHelper>(); var mockPlugin = new Mock<IPluginManager>(); var mockSourceProvider = new Mock<ISourceControlProvider>(); var mockVsHelper = new Mock<IVsEnvironmentHelper>(); mockConfiguration.Setup(x => x.ReadSetting(It.IsAny<Context>(), It.IsAny<string>(), It.IsAny<string>())).Returns(new SonarQubeProperties() { Value = "dummy" }); var mockObj = mockConfiguration.Object; var brancheData = new List<Resource>(); brancheData.Add(new Resource() { Key = "tekla.utilities:project:master", Name = "project master", BranchName = "master", IsBranch = true }); brancheData.Add(new Resource() { Key = "tekla.utilities:project:feature_A", Name = "project feature_A", BranchName = "feature_A", IsBranch = true }); brancheData.Add(new Resource() { Key = "tekla.utilities:project:feature_B", Name = "project feature_B", BranchName = "feature_B", IsBranch = true }); mockRest.Setup(x => x.GetProjectsList(It.IsAny<ISonarConfiguration>())).Returns(brancheData); var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, locaAnalyser: mockAnalyser.Object); associationModel.RefreshProjectList(false); Assert.That(associationModel.AvailableProjects.Count, Is.EqualTo(1)); Assert.That(associationModel.AvailableProjects[0].BranchResources.Count, Is.EqualTo(3)); Assert.That(associationModel.AvailableProjects[0].Name, Is.EqualTo("project")); Assert.That(associationModel.AvailableProjects[0].BranchResources[0].BranchName, Is.EqualTo("master")); Assert.That(associationModel.AvailableProjects[0].BranchResources[1].BranchName, Is.EqualTo("feature_A")); Assert.That(associationModel.AvailableProjects[0].BranchResources[2].BranchName, Is.EqualTo("feature_B")); }
/// <summary> /// Initializes a new instance of the <see cref="PluginManagerModel" /> class. /// </summary> /// <param name="controller">The controller.</param> /// <param name="configurationHelper">The configuration helper.</param> /// <param name="notifyManager">The notify manager.</param> /// <param name="helper">The helper.</param> public PluginManagerModel( IPluginController controller, IConfigurationHelper configurationHelper, INotificationManager notifyManager, IVsEnvironmentHelper helper) { this.notificationManager = notifyManager; this.Header = "Plugin Manager"; this.configurationHelper = configurationHelper; this.controller = controller; this.vshelper = helper; this.userPluginInstallPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "vssonarextension", vshelper.VsVersion(), "plugins"); if (!Directory.Exists(this.userPluginInstallPath)) { Directory.CreateDirectory(this.userPluginInstallPath); } this.plugins = new List <IPlugin>(); this.MenuPlugins = new List <IMenuCommandPlugin>(); this.AnalysisPlugins = new List <IAnalysisPlugin>(); this.SourceCodePlugins = new List <ISourceVersionPlugin>(); this.IssueTrackerPlugins = new List <IIssueTrackerPlugin>(); var defaultPluginsFolder = Path.Combine(this.controller.ExtensionFolder, "plugins"); this.InitPluginList(helper, null, defaultPluginsFolder); this.InitPluginList(helper, null, this.userPluginInstallPath); this.InitCommanding(); SonarQubeViewModel.RegisterNewViewModelInPool(this); }
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")); }
/// <summary> /// Startups the model with vs version. /// </summary> /// <param name="version">The version.</param> /// <returns>returns model</returns> public static SonarQubeViewModel StartupModelWithVsVersion(string version, IServiceProvider provider) { if (model == null) { model = new SonarQubeViewModel(version, new VsConfigurationHelper(version)); } return(model); }
/// <summary> /// Startups the model with vs version. /// </summary> /// <param name="version">The version.</param> /// <returns>returns model</returns> public static SonarQubeViewModel StartupModelWithVsVersion(string version) { if (model == null) { model = new VSSonarExtensionUi.ViewModel.SonarQubeViewModel(version); } return(model); }
public AssociationViewModel(AssociationModel model) { this.model = model; this.AssignProjectCommand = new RelayCommand(this.OnAssignProjectCommand); this.AvailableProjects = new ObservableCollection <Resource>(); this.Header = "Association Dialog"; SonarQubeViewModel.RegisterNewViewModelInPool(this); }
public AssociationViewModel() { this.AssignProjectCommand = new RelayCommand(this.OnAssignProjectCommand); this.AvailableProjects = new ObservableCollection <Resource>(); this.Header = "Association Dialog"; this.BackGroundColor = Colors.White; this.ForeGroundColor = Colors.Black; SonarQubeViewModel.RegisterNewViewModelInPool(this); }
public void WhenSettingNullProjectItShouldClearData() { var mockTranslator = new Mock <ISQKeyTranslator>(); var mockRest = new Mock <ISonarRestService>(); var mockLogger = new Mock <INotificationManager>(); var mockConfiguration = new Mock <IConfigurationHelper>(); var mockPlugin = new Mock <IPluginManager>(); var mockSourceProvider = new Mock <ISourceControlProvider>(); var mockVsHelper = new Mock <IVsEnvironmentHelper>(); mockConfiguration.Setup(x => x.ReadSetting(It.IsAny <Context>(), It.IsAny <string>(), It.IsAny <string>())).Returns(new SonarQubeProperties() { Value = "dummy" }); var mockObj = mockConfiguration.Object; var brancheData = new List <Resource>(); brancheData.Add(new Resource() { Key = "tekla.utilities:project:feature_A", Name = "project feature_A", BranchName = "feature_A", IsBranch = true }); brancheData.Add(new Resource() { Key = "org.apache.xbean:xbean", Name = "Apache XBean" }); brancheData.Add(new Resource() { Key = "org.apache.activemq:activemq-parent", Name = "ActiveMQ" }); brancheData.Add(new Resource() { Key = "org.apache.maven:maven", Name = "Apache Maven", Version = "Work" }); mockRest.Setup(x => x.GetProjectsList(It.IsAny <ISonarConfiguration>())).Returns(brancheData); mockSourceProvider.Setup(x => x.GetBranch()).Returns(string.Empty); var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, locaAnalyser: mockAnalyser.Object); associationModel.RefreshProjectList(false); Assert.That(associationModel.AvailableProjects.Count, Is.EqualTo(4)); associationModel.SelectedProjectInView = associationModel.AvailableProjects[1]; Assert.That(associationModel.SelectedProjectName, Is.EqualTo("Apache Maven")); Assert.That(associationModel.SelectedProjectKey, Is.EqualTo("org.apache.maven:maven")); Assert.That(associationModel.SelectedProjectVersion, Is.EqualTo("Work")); Assert.That(associationModel.SelectedBranchProject, Is.Null); Assert.That(associationModel.StatusMessageAssociation, Is.EqualTo("Normal project type. Press associate to confirm.")); associationModel.SelectedProjectInView = null; Assert.That(associationModel.SelectedBranchProject, Is.Null); Assert.That(associationModel.StatusMessageAssociation, Is.EqualTo("No project selected, select from above.")); }
public void CreatesBranchesAndNormalProjects() { var mockTranslator = new Mock <ISQKeyTranslator>(); var mockRest = new Mock <ISonarRestService>(); var mockLogger = new Mock <INotificationManager>(); var mockConfiguration = new Mock <IConfigurationHelper>(); var mockPlugin = new Mock <IPluginManager>(); var mockSourceProvider = new Mock <ISourceControlProvider>(); var mockVsHelper = new Mock <IVsEnvironmentHelper>(); mockConfiguration.Setup(x => x.ReadSetting(It.IsAny <Context>(), It.IsAny <string>(), It.IsAny <string>())).Returns(new SonarQubeProperties() { Value = "dummy" }); var mockObj = mockConfiguration.Object; var brancheData = new List <Resource>(); brancheData.Add(new Resource() { Key = "tekla.utilities:project:master", Name = "project master", BranchName = "master", IsBranch = true }); brancheData.Add(new Resource() { Key = "tekla.utilities:project:feature_A", Name = "project feature_A", BranchName = "feature_A", IsBranch = true }); brancheData.Add(new Resource() { Key = "org.apache.xbean:xbean", Name = "Apache XBean" }); brancheData.Add(new Resource() { Key = "org.apache.activemq:activemq-parent", Name = "ActiveMQ" }); brancheData.Add(new Resource() { Key = "org.apache.maven:maven", Name = "Apache Maven" }); mockRest.Setup(x => x.GetProjectsList(It.IsAny <ISonarConfiguration>())).Returns(brancheData); var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, locaAnalyser: mockAnalyser.Object); associationModel.RefreshProjectList(false); Assert.That(associationModel.AvailableProjects.Count, Is.EqualTo(4)); Assert.That(associationModel.AvailableProjects[0].Name, Is.EqualTo("ActiveMQ")); Assert.That(associationModel.AvailableProjects[0].IsBranch, Is.False); Assert.That(associationModel.AvailableProjects[1].Name, Is.EqualTo("Apache Maven")); Assert.That(associationModel.AvailableProjects[1].IsBranch, Is.False); Assert.That(associationModel.AvailableProjects[2].Name, Is.EqualTo("Apache XBean")); Assert.That(associationModel.AvailableProjects[2].IsBranch, Is.False); Assert.That(associationModel.AvailableProjects[3].BranchResources.Count, Is.EqualTo(2)); Assert.That(associationModel.AvailableProjects[3].BranchResources[0].BranchName, Is.EqualTo("master")); Assert.That(associationModel.AvailableProjects[3].BranchResources[1].BranchName, Is.EqualTo("feature_A")); }
/// <summary> /// Initializes a new instance of the <see cref="SonarQubeUserControlVs"/> class. /// </summary> /// <param name="model"> /// The model. /// </param> public SonarQubeUserControlVs(SonarQubeViewModel model) { this.DataContext = model; try { this.InitializeComponent(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
public void GetsMasterBranchIfBranchIsNotDetected() { var mockTranslator = new Mock <ISQKeyTranslator>(); var mockRest = new Mock <ISonarRestService>(); var mockLogger = new Mock <INotificationManager>(); var mockConfiguration = new Mock <IConfigurationHelper>(); var mockPlugin = new Mock <IPluginManager>(); var mockSourceProvider = new Mock <ISourceControlProvider>(); var mockVsHelper = new Mock <IVsEnvironmentHelper>(); mockConfiguration.Setup(x => x.ReadSetting(It.IsAny <Context>(), It.IsAny <string>(), It.IsAny <string>())).Returns(new SonarQubeProperties() { Value = "dummy" }); var mockObj = mockConfiguration.Object; var brancheData = new List <Resource>(); brancheData.Add(new Resource() { Key = "tekla.utilities:project:master", Name = "project master", BranchName = "master", IsBranch = true }); brancheData.Add(new Resource() { Key = "tekla.utilities:project:feature_A", Name = "project feature_A", BranchName = "feature_A", IsBranch = true }); brancheData.Add(new Resource() { Key = "org.apache.xbean:xbean", Name = "Apache XBean" }); brancheData.Add(new Resource() { Key = "org.apache.activemq:activemq-parent", Name = "ActiveMQ" }); brancheData.Add(new Resource() { Key = "org.apache.maven:maven", Name = "Apache Maven" }); mockRest.Setup(x => x.GetProjectsList(It.IsAny <ISonarConfiguration>())).Returns(brancheData); mockSourceProvider.Setup(x => x.GetBranch()).Returns("feature-x"); var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, mockSourceProvider.Object, locaAnalyser: mockAnalyser.Object); associationModel.RefreshProjectList(false); Assert.That(associationModel.AvailableProjects.Count, Is.EqualTo(4)); associationModel.SelectedProjectInView = associationModel.AvailableProjects[3]; Assert.That(associationModel.SelectedBranchProject.Name, Is.EqualTo("project master")); Assert.That(associationModel.SelectedBranchProject.BranchName, Is.EqualTo("master")); Assert.That(associationModel.SelectedBranchProject.Key, Is.EqualTo("tekla.utilities:project:master")); Assert.That(associationModel.StatusMessageAssociation, Is.EqualTo("Using master branch, because current branch does not exist or source control not supported. Press associate to confirm.")); }
/// <summary> /// Initializes a new instance of the <see cref="VSonarQubeOptionsViewModel" /> class. /// </summary> /// <param name="service">The service.</param> /// <param name="configurationHelper">The configuration helper.</param> /// <param name="notifier">The notifier.</param> public VSonarQubeOptionsViewModel( ISonarRestService service, IConfigurationHelper configurationHelper, INotificationManager notifier) { this.notificationManager = notifier; this.restService = service; this.configurationHelper = configurationHelper; this.InitModels(); this.InitCommanding(); AssociationModel.RegisterNewModelInPool(this); SonarQubeViewModel.RegisterNewViewModelInPool(this); }
public RoslynManagerViewModel(RoslynManagerModel model) { this.Header = "Roslyn Manager"; this.model = model; this.BackGroundColor = Colors.White; this.ForeGroundColor = Colors.Black; this.AvailableDllDiagnostics = new ObservableCollection <VSSonarExtensionDiagnostic>(); this.AvailableChecksInDll = new ObservableCollection <RoslynDiagnosticInterpretation>(); foreach (var item in model.ExtensionDiagnostics) { AvailableDllDiagnostics.Add(item.Value); } SonarQubeViewModel.RegisterNewViewModelInPool(this); }
public void DoesNotGetBranchIfCannotDetectBranch() { var mockTranslator = new Mock <ISQKeyTranslator>(); var mockRest = new Mock <ISonarRestService>(); var mockLogger = new Mock <INotificationManager>(); var mockConfiguration = new Mock <IConfigurationHelper>(); var mockPlugin = new Mock <IPluginManager>(); var mockSourceProvider = new Mock <ISourceControlProvider>(); var mockVsHelper = new Mock <IVsEnvironmentHelper>(); mockConfiguration.Setup(x => x.ReadSetting(It.IsAny <Context>(), It.IsAny <string>(), It.IsAny <string>())).Returns(new SonarQubeProperties() { Value = "dummy" }); var mockObj = mockConfiguration.Object; var brancheData = new List <Resource>(); brancheData.Add(new Resource() { Key = "tekla.utilities:project:feature_A", Name = "project feature_A", BranchName = "feature_A", IsBranch = true }); brancheData.Add(new Resource() { Key = "org.apache.xbean:xbean", Name = "Apache XBean" }); brancheData.Add(new Resource() { Key = "org.apache.activemq:activemq-parent", Name = "ActiveMQ" }); brancheData.Add(new Resource() { Key = "org.apache.maven:maven", Name = "Apache Maven" }); mockRest.Setup(x => x.GetProjectsList(It.IsAny <ISonarConfiguration>())).Returns(brancheData); mockSourceProvider.Setup(x => x.GetBranch()).Returns(string.Empty); var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, mockSourceProvider.Object, locaAnalyser: mockAnalyser.Object); associationModel.RefreshProjectList(false); Assert.That(associationModel.AvailableProjects.Count, Is.EqualTo(4)); associationModel.SelectedProjectInView = associationModel.AvailableProjects[3]; Assert.That(associationModel.SelectedBranchProject, Is.Null); Assert.That(associationModel.StatusMessageAssociation, Is.EqualTo("Unable to find branch, please manually choose one from list and confirm.")); }
/// <summary> /// Waits for completion or timeout. /// </summary> /// <param name="associationModel">The association model.</param> private static void WaitForCompletionOrTimeout(SonarQubeViewModel associationModel) { int timeout = 20; bool controlFound = false; for (int i = 0; i < timeout; i++) { if (!associationModel.IsExtensionBusy) { break; } else { System.Threading.Thread.Sleep(500); } } }
/// <summary> /// Initializes a new instance of the <see cref="RoslynManagerViewModel"/> class. /// </summary> /// <param name="model">The model.</param> public RoslynManagerViewModel(RoslynManagerModel model) { this.Header = "Roslyn Manager"; this.model = model; this.BackGroundColor = Colors.White; this.ForeGroundColor = Colors.Black; this.AvailableDllDiagnostics = new ObservableCollection <VSSonarExtensionDiagnostic>(); foreach (var item in model.ExtensionDiagnostics) { AvailableDllDiagnostics.Add(item.Value); } SonarQubeViewModel.RegisterNewViewModelInPool(this); this.InstallNewDllCommand = new RelayCommand(this.OnInstallNewDllCommand); this.RemoveDllCommand = new RelayCommand(this.OnRemoveDllCommand); }
/// <summary> /// Initializes a new instance of the <see cref="AnalysisOptionsViewModel" /> class. /// </summary> /// <param name="viewModel">The view Model.</param> /// <param name="configurationHelper">The configuration helper.</param> public AnalysisOptionsViewModel( VSonarQubeOptionsViewModel viewModel, IConfigurationHelper configurationHelper) { this.configurationHelper = configurationHelper; this.viewModel = viewModel; this.TimeoutValue = 10; this.IsSolutionAnalysisChecked = true; this.IsProjectAnalysisChecked = true; this.Header = "Analysis Options"; this.ForeGroundColor = Colors.Black; this.BackGroundColor = Colors.White; this.BrowseForJavaTrigger = new RelayCommand(this.OnBrowseForJavaTrigger); this.BrowseForSonarRunnerQubeTrigger = new RelayCommand(this.OnBrowseForSonarRunnerQubeTrigger); SonarQubeViewModel.RegisterNewViewModelInPool(this); AssociationModel.RegisterNewModelInPool(this); }
/// <summary> /// Initializes a new instance of the <see cref="AssociationModel" /> class. /// </summary> /// <param name="logger">The logger.</param> /// <param name="service">The service.</param> /// <param name="configurationHelper">The configuration helper.</param> /// <param name="translator">The translator.</param> /// <param name="pluginManager">The plugin manager.</param> /// <param name="model">The model.</param> public AssociationModel( INotificationManager logger, ISonarRestService service, IConfigurationHelper configurationHelper, ISQKeyTranslator translator, IPluginManager pluginManager, SonarQubeViewModel model) { this.keyTranslator = translator; this.pluginManager = pluginManager; this.model = model; this.configurationHelper = configurationHelper; this.logger = logger; this.sonarService = service; // start view model this.associationViewModel = new AssociationViewModel(this); }
/// <summary> /// Initializes a new instance of the <see cref="NotifyCationManager" /> class. /// </summary> /// <param name="model">The model.</param> /// <param name="visualStudioVersion">The visual studio version.</param> public NotifyCationManager(SonarQubeViewModel model, string visualStudioVersion) { this.model = model; this.userRoamingFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "VSSonarExtension\\debug.log." + visualStudioVersion); try { if (File.Exists(this.userRoamingFile)) { File.Delete(this.userRoamingFile); } } catch (Exception error) { Debug.WriteLine(error.Message); } AssociationModel.RegisterNewModelInPool(this); }
public void OnDisconectInNotAssociatedShouldClearAllData() { 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()); var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, locaAnalyser: mockAnalyser.Object); associationModel.RefreshProjectList(false); Assert.That(associationModel.AvailableProjects.Count, Is.EqualTo(2)); associationModel.OnDisconnectToSonar(); Assert.That(associationModel.AvailableProjects.Count, Is.EqualTo(0)); Assert.That(associationModel.SelectedProjectInView, Is.Null); Assert.That(associationModel.SelectedProjectName, Is.EqualTo("")); Assert.That(associationModel.SelectedProjectKey, Is.EqualTo("")); Assert.That(associationModel.SelectedProjectVersion, Is.EqualTo("")); Assert.That(associationModel.IsConnected, Is.False); }
/// <summary> /// Initializes a new instance of the <see cref="AssociationModel" /> class. /// </summary> /// <param name="logger">The logger.</param> /// <param name="service">The service.</param> /// <param name="configurationHelper">The configuration helper.</param> /// <param name="translator">The translator.</param> /// <param name="pluginManager">The plugin manager.</param> /// <param name="model">The </param> public AssociationModel( INotificationManager logger, ISonarRestService service, IConfigurationHelper configurationHelper, ISQKeyTranslator translator, IPluginManager pluginManager, SonarQubeViewModel model, ISonarLocalAnalyser localAnalyeser, string vsVersion) { this.vsVersion = vsVersion; this.keyTranslator = translator; this.pluginManager = pluginManager; this.model = model; this.configurationHelper = configurationHelper; this.logger = logger; this.sonarService = service; this.localAnalyserModule = localAnalyeser; this.localAnalyserModule.AssociateCommandCompeted += this.LocalAssociationCompleted; }
/// <summary> /// Initializes a new instance of the <see cref="PluginManagerModel" /> class. /// </summary> /// <param name="controller">The controller.</param> /// <param name="configurationHelper">The configuration helper.</param> /// <param name="notifyManager">The notify manager.</param> /// <param name="helper">The helper.</param> public PluginManagerModel( IPluginController controller, IConfigurationHelper configurationHelper, INotificationManager notifyManager, IVsEnvironmentHelper helper) { this.notificationManager = notifyManager; this.Header = "Plugin Manager"; this.configurationHelper = configurationHelper; this.controller = controller; this.vshelper = helper; this.plugins = new List <IPlugin>(); this.MenuPlugins = new List <IMenuCommandPlugin>(); this.AnalysisPlugins = new List <IAnalysisPlugin>(); this.SourceCodePlugins = new List <ISourceVersionPlugin>(); this.IssueTrackerPlugins = new List <IIssueTrackerPlugin>(); this.InitPluginList(helper, null); this.InitCommanding(); SonarQubeViewModel.RegisterNewViewModelInPool(this); }
public void OnSolutionOpenButProjectNotFoundItShouldNotAssociate() { 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"); mockPlugin.Setup(x => x.SourceCodePlugins).Returns(new List<ISourceVersionPlugin>()); 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.AssociationModule.AssociatedProject = new Resource(); associationModel.SelectedProjectKey = "jasd"; associationModel.SelectedProjectName = "jasd"; associationModel.SelectedProjectVersion = "jasd"; associationModel.VsHelper = mockVsHelper.Object; associationModel.IsSolutionOpen = true; associationModel.IsConnected = true; associationModel.OnSolutionOpen("abc", "dfc", "sds"); 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); Assert.That(associationModel.SelectedProjectName, Is.Null); Assert.That(associationModel.SelectedProjectKey, Is.Null); Assert.That(associationModel.SelectedProjectVersion, 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 OnDisconectInNotAssociatedShouldClearAllData() { 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()); var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, locaAnalyser: mockAnalyser.Object); associationModel.RefreshProjectList(false); Assert.That(associationModel.AvailableProjects.Count, Is.EqualTo(2)); associationModel.OnDisconnectToSonar(); Assert.That(associationModel.AvailableProjects.Count, Is.EqualTo(0)); Assert.That(associationModel.SelectedProjectInView, Is.Null); Assert.That(associationModel.SelectedProjectName, Is.EqualTo("")); Assert.That(associationModel.SelectedProjectKey, Is.EqualTo("")); Assert.That(associationModel.SelectedProjectVersion, Is.EqualTo("")); Assert.That(associationModel.IsConnected, Is.False); }
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 GetsMasterBranchIfBranchIsNotDetected() { var mockTranslator = new Mock<ISQKeyTranslator>(); var mockRest = new Mock<ISonarRestService>(); var mockLogger = new Mock<INotificationManager>(); var mockConfiguration = new Mock<IConfigurationHelper>(); var mockPlugin = new Mock<IPluginManager>(); var mockSourceProvider = new Mock<ISourceControlProvider>(); var mockVsHelper = new Mock<IVsEnvironmentHelper>(); mockConfiguration.Setup(x => x.ReadSetting(It.IsAny<Context>(), It.IsAny<string>(), It.IsAny<string>())).Returns(new SonarQubeProperties() { Value = "dummy" }); var mockObj = mockConfiguration.Object; var brancheData = new List<Resource>(); brancheData.Add(new Resource() { Key = "tekla.utilities:project:master", Name = "project master", BranchName = "master", IsBranch = true }); brancheData.Add(new Resource() { Key = "tekla.utilities:project:feature_A", Name = "project feature_A", BranchName = "feature_A", IsBranch = true }); brancheData.Add(new Resource() { Key = "org.apache.xbean:xbean", Name = "Apache XBean" }); brancheData.Add(new Resource() { Key = "org.apache.activemq:activemq-parent", Name = "ActiveMQ" }); brancheData.Add(new Resource() { Key = "org.apache.maven:maven", Name = "Apache Maven" }); mockRest.Setup(x => x.GetProjectsList(It.IsAny<ISonarConfiguration>())).Returns(brancheData); mockSourceProvider.Setup(x => x.GetBranch()).Returns("feature-x"); var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, mockSourceProvider.Object, locaAnalyser: mockAnalyser.Object); associationModel.RefreshProjectList(false); Assert.That(associationModel.AvailableProjects.Count, Is.EqualTo(4)); associationModel.SelectedProjectInView = associationModel.AvailableProjects[3]; Assert.That(associationModel.SelectedBranchProject.Name, Is.EqualTo("project master")); Assert.That(associationModel.SelectedBranchProject.BranchName, Is.EqualTo("master")); Assert.That(associationModel.SelectedBranchProject.Key, Is.EqualTo("tekla.utilities:project:master")); Assert.That(associationModel.StatusMessageAssociation, Is.EqualTo("Using master branch, because current branch does not exist or source control not supported. Press associate to confirm.")); }
public void DoesNotGetBranchIfCannotDetectBranch() { var mockTranslator = new Mock<ISQKeyTranslator>(); var mockRest = new Mock<ISonarRestService>(); var mockLogger = new Mock<INotificationManager>(); var mockConfiguration = new Mock<IConfigurationHelper>(); var mockPlugin = new Mock<IPluginManager>(); var mockSourceProvider = new Mock<ISourceControlProvider>(); var mockVsHelper = new Mock<IVsEnvironmentHelper>(); mockConfiguration.Setup(x => x.ReadSetting(It.IsAny<Context>(), It.IsAny<string>(), It.IsAny<string>())).Returns(new SonarQubeProperties() { Value = "dummy" }); var mockObj = mockConfiguration.Object; var brancheData = new List<Resource>(); brancheData.Add(new Resource() { Key = "tekla.utilities:project:feature_A", Name = "project feature_A", BranchName = "feature_A", IsBranch = true }); brancheData.Add(new Resource() { Key = "org.apache.xbean:xbean", Name = "Apache XBean" }); brancheData.Add(new Resource() { Key = "org.apache.activemq:activemq-parent", Name = "ActiveMQ" }); brancheData.Add(new Resource() { Key = "org.apache.maven:maven", Name = "Apache Maven" }); mockRest.Setup(x => x.GetProjectsList(It.IsAny<ISonarConfiguration>())).Returns(brancheData); mockSourceProvider.Setup(x => x.GetBranch()).Returns(string.Empty); var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, mockSourceProvider.Object, locaAnalyser: mockAnalyser.Object); associationModel.RefreshProjectList(false); Assert.That(associationModel.AvailableProjects.Count, Is.EqualTo(4)); associationModel.SelectedProjectInView = associationModel.AvailableProjects[3]; Assert.That(associationModel.SelectedBranchProject, Is.Null); Assert.That(associationModel.StatusMessageAssociation, Is.EqualTo("Unable to find branch, please manually choose one from list and confirm.")); }
public void WhenSettingNullProjectItShouldClearData() { var mockTranslator = new Mock<ISQKeyTranslator>(); var mockRest = new Mock<ISonarRestService>(); var mockLogger = new Mock<INotificationManager>(); var mockConfiguration = new Mock<IConfigurationHelper>(); var mockPlugin = new Mock<IPluginManager>(); var mockSourceProvider = new Mock<ISourceControlProvider>(); var mockVsHelper = new Mock<IVsEnvironmentHelper>(); mockConfiguration.Setup(x => x.ReadSetting(It.IsAny<Context>(), It.IsAny<string>(), It.IsAny<string>())).Returns(new SonarQubeProperties() { Value = "dummy" }); var mockObj = mockConfiguration.Object; var brancheData = new List<Resource>(); brancheData.Add(new Resource() { Key = "tekla.utilities:project:feature_A", Name = "project feature_A", BranchName = "feature_A", IsBranch = true }); brancheData.Add(new Resource() { Key = "org.apache.xbean:xbean", Name = "Apache XBean" }); brancheData.Add(new Resource() { Key = "org.apache.activemq:activemq-parent", Name = "ActiveMQ" }); brancheData.Add(new Resource() { Key = "org.apache.maven:maven", Name = "Apache Maven", Version = "Work" }); mockRest.Setup(x => x.GetProjectsList(It.IsAny<ISonarConfiguration>())).Returns(brancheData); mockSourceProvider.Setup(x => x.GetBranch()).Returns(string.Empty); var associationModel = new SonarQubeViewModel("test", mockConfiguration.Object, mockLogger.Object, mockTranslator.Object, mockRest.Object, locaAnalyser: mockAnalyser.Object); associationModel.RefreshProjectList(false); Assert.That(associationModel.AvailableProjects.Count, Is.EqualTo(4)); associationModel.SelectedProjectInView = associationModel.AvailableProjects[1]; Assert.That(associationModel.SelectedProjectName, Is.EqualTo("Apache Maven")); Assert.That(associationModel.SelectedProjectKey, Is.EqualTo("org.apache.maven:maven")); Assert.That(associationModel.SelectedProjectVersion, Is.EqualTo("Work")); Assert.That(associationModel.SelectedBranchProject, Is.Null); Assert.That(associationModel.StatusMessageAssociation, Is.EqualTo("Normal project type. Press associate to confirm.")); associationModel.SelectedProjectInView = null; Assert.That(associationModel.SelectedBranchProject, Is.Null); Assert.That(associationModel.StatusMessageAssociation, Is.EqualTo("No project selected, select from above.")); }