/// <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="LocalViewModel" /> class.
        /// </summary>
        /// <param name="pluginsIn">The plugins in. TODO they must be also updatetable</param>
        /// <param name="service">The service.</param>
        /// <param name="configurationHelper">The configuration helper.</param>
        /// <param name="notificationManager">The notification manager.</param>
        /// <param name="translator">The translator.</param>
        public LocalViewModel(
            List <IAnalysisPlugin> pluginsIn,
            ISonarRestService service,
            IConfigurationHelper configurationHelper,
            INotificationManager notificationManager,
            ISQKeyTranslator translator)
        {
            this.keyTranslator       = translator;
            this.notificationManager = notificationManager;
            this.restService         = service;
            this.configurationHelper = configurationHelper;

            this.plugins        = pluginsIn;
            this.Header         = "Local Analysis";
            this.IssuesGridView = new IssueGridViewModel(false, "LocalView", false, this.configurationHelper, service, notificationManager, translator);
            this.OuputLogLines  = new PaginatedObservableCollection <string>(300);
            this.AllLog         = new List <string>();

            this.InitCommanding();
            this.InitFileAnalysis();

            this.localAnalyserModule                           = new SonarLocalAnalyser(this.plugins, this.restService, this.configurationHelper, this.notificationManager);
            this.localAnalyserModule.StdOutEvent              += this.UpdateOutputMessagesFromPlugin;
            this.localAnalyserModule.LocalAnalysisCompleted   += this.UpdateLocalIssues;
            this.localAnalyserModule.AssociateCommandCompeted += this.UpdateAssociateCommand;

            this.ShowFlyouts  = false;
            this.SizeOfFlyout = 0;

            this.ForeGroundColor = Colors.Black;
            this.BackGroundColor = Colors.White;

            // register model
            AssociationModel.RegisterNewModelInPool(this);
        }
        /// <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);
        }
Exemplo n.º 4
0
        /// <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);
        }
Exemplo n.º 5
0
        public void AssignProjectIsNotMainReturnsTrue()
        {
            var mockTranslator     = new Mock <ISQKeyTranslator>();
            var mockRest           = new Mock <ISonarRestService>();
            var mockLogger         = new Mock <INotificationManager>();
            var mockPlugin         = new Mock <IPluginManager>();
            var mockConfiguration  = new Mock <IConfigurationHelper>();
            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;

            AssociationModel associationModel;

            associationModel = new AssociationModel(mockLogger.Object, mockRest.Object, mockObj, mockTranslator.Object, mockPlugin.Object, new SonarQubeViewModel("test", mockObj));
            associationModel.UpdateServicesInModels(mockVsHelper.Object, null, null);

            Assert.That(associationModel.AssignASonarProjectToSolution(new Resource()
            {
                IsBranch = false
            }, null), Is.True);
            Assert.That(associationModel.IsAssociated, Is.True);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RoslynManagerModel" /> class.
        /// </summary>
        /// <param name="pluginsIn">The plugins in.</param>
        /// <param name="notificationManagerIn">The notification manager in.</param>
        /// <param name="configHelper">The configuration helper.</param>
        public RoslynManagerModel(
            IEnumerable <IAnalysisPlugin> pluginsIn,
            INotificationManager notificationManagerIn,
            IConfigurationHelper configHelper,
            ISonarRestService rest)
        {
            this.roslynHomePath             = Path.Combine(configHelper.ApplicationPath, "Diagnostics");
            this.roslynExternalUserDiagPath = Path.Combine(this.roslynHomePath, "UserDiagnostics");
            this.roslynEmbbedDiagPath       = Path.Combine(this.roslynHomePath, "InternalDiagnostics");

            if (!Directory.Exists(this.roslynHomePath))
            {
                Directory.CreateDirectory(this.roslynHomePath);
            }

            if (!Directory.Exists(this.roslynExternalUserDiagPath))
            {
                Directory.CreateDirectory(this.roslynExternalUserDiagPath);
            }

            if (!Directory.Exists(this.roslynEmbbedDiagPath))
            {
                Directory.CreateDirectory(this.roslynEmbbedDiagPath);
            }

            this.rest                   = rest;
            this.confHelper             = configHelper;
            this.plugins                = pluginsIn;
            this.notificationManager    = notificationManagerIn;
            this.ExtensionDiagnostics   = new Dictionary <string, VSSonarExtensionDiagnostic>();
            this.embedVersionController = new EmbbedVersionController(this.notificationManager, rest, configHelper, this.roslynEmbbedDiagPath);

            // register model
            AssociationModel.RegisterNewModelInPool(this);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ServerViewModel" /> class.
        /// </summary>
        /// <param name="vsenvironmenthelper">The vsenvironmenthelper.</param>
        /// <param name="configurationHelper">The configuration helper.</param>
        /// <param name="restservice">The restservice.</param>
        /// <param name="notificationManager">The notification manager.</param>
        /// <param name="translator">The translator.</param>
        /// <param name="analyser">The analyser.</param>
        public ServerViewModel(
            IVsEnvironmentHelper vsenvironmenthelper,
            IConfigurationHelper configurationHelper,
            ISonarRestService restservice,
            INotificationManager notificationManager,
            ISQKeyTranslator translator,
            ISonarLocalAnalyser analyser,
            IList <IIssueTrackerPlugin> issuetracketplugins)
        {
            this.analyser            = analyser;
            this.notificationMan     = notificationManager;
            this.vsenvironmenthelper = vsenvironmenthelper;
            this.configurationHelper = configurationHelper;
            this.restservice         = restservice;

            this.Header           = "Server Analysis";
            this.AlreadyOpenDiffs = new SortedSet <string>();
            this.IssuesGridView   = new IssueGridViewModel("ServerView", true, this.configurationHelper, this.restservice, this.notificationMan, translator);
            this.IssuesGridView.ContextMenuItems     = this.CreateRowContextMenu(restservice, translator, issuetracketplugins);
            this.IssuesGridView.ShowContextMenu      = true;
            this.IssuesGridView.ShowLeftFlyoutEvent += this.ShowHideLeftFlyout;
            this.InitCommanding();

            this.ForeGroundColor = Colors.Black;
            this.BackGroundColor = Colors.White;
            this.SizeOfFlyout    = 0;
            // register model
            AssociationModel.RegisterNewModelInPool(this);
        }
Exemplo n.º 8
0
        public void AssociateProjectFailesIfPathNotDefined()
        {
            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>();
            var mockanalyser       = new Mock <ISonarLocalAnalyser>();

            mockConfiguration.Setup(x => x.ReadSetting(It.IsAny <Context>(), It.IsAny <string>(), It.IsAny <string>())).Returns(new SonarQubeProperties()
            {
                Value = "dummy"
            });
            var mockObj = mockConfiguration.Object;

            AssociationModel associationModel;

            associationModel = new AssociationModel(mockLogger.Object, mockRest.Object, mockObj, mockTranslator.Object, mockPlugin.Object, new SonarQubeViewModel("test", mockObj), mockanalyser.Object, "14.0");
            associationModel.UpdateServicesInModels(mockVsHelper.Object, null, null);
            Assert.IsFalse(associationModel.AssignASonarProjectToSolution(new Resource()
            {
                IsBranch = false
            }, new Resource()
            {
                Default = true
            }, mockSourceProvider.Object));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ServerViewModel" /> class.
        /// </summary>
        /// <param name="vsenvironmenthelper">The vsenvironmenthelper.</param>
        /// <param name="configurationHelper">The configuration helper.</param>
        /// <param name="restservice">The restservice.</param>
        /// <param name="notificationManager">The notification manager.</param>
        /// <param name="translator">The translator.</param>
        public ServerViewModel(
            IVsEnvironmentHelper vsenvironmenthelper,
            IConfigurationHelper configurationHelper,
            ISonarRestService restservice,
            INotificationManager notificationManager,
            ISQKeyTranslator translator)
        {
            this.notificationMan     = notificationManager;
            this.vsenvironmenthelper = vsenvironmenthelper;
            this.configurationHelper = configurationHelper;
            this.restservice         = restservice;

            this.Header = "Server Analysis";
            this.AvailableActionPlans = new ObservableCollection <SonarActionPlan>();
            this.AlreadyOpenDiffs     = new SortedSet <string>();
            this.IssuesGridView       = new IssueGridViewModel(true, "ServerView", true, this.configurationHelper, this.restservice, this.notificationMan, translator);
            this.IssuesGridView.ShowLeftFlyoutEvent += this.ShowHideLeftFlyout;
            this.InitCommanding();

            this.ForeGroundColor = Colors.Black;
            this.BackGroundColor = Colors.White;
            this.SizeOfFlyout    = 0;
            // register model
            AssociationModel.RegisterNewModelInPool(this);
        }
Exemplo n.º 10
0
        public void CreateResourcePathFileIsNull()
        {
            AssociationModel associationModel;

            associationModel =
                new AssociationModel(null, null, null, null, null, null);
            Assert.That(associationModel.CreateResourcePathFile(null, null), Is.Null);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OpenResourceMenu" /> class.
        /// Initializes a new instance of the <see cref="ChangeStatusMenu" /> class.
        /// </summary>
        /// <param name="rest">The rest.</param>
        /// <param name="model">The model.</param>
        private OpenResourceMenu(ISonarRestService rest, IssueGridViewModel model)
        {
            this.model          = model;
            this.rest           = rest;
            this.ExecuteCommand = new RelayCommand(this.OnAssociateCommand);
            this.SubItems       = new ObservableCollection <IMenuItem>();

            // register menu for data sync
            AssociationModel.RegisterNewModelInPool(this);
        }
Exemplo n.º 13
0
        public void CreateResourcePathFileThrowsNotImplementedException170()
        {
            AssociationModel   associationModel;
            Resource           resource;
            StandAloneVsHelper s0 = new StandAloneVsHelper();

            associationModel = new AssociationModel(null, null, null, null, null, null);
            associationModel.UpdateServicesInModels(s0, null, null);
            Assert.Throws <NotImplementedException>(() => resource = associationModel.CreateResourcePathFile((string)null, (Resource)null));
        }
Exemplo n.º 14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssignMenu" /> class.
        /// </summary>
        /// <param name="rest">The rest.</param>
        /// <param name="model">The model.</param>
        /// <param name="notmanager">The notmanager.</param>
        private AssignMenu(ISonarRestService rest, IssueGridViewModel model, INotificationManager notmanager)
        {
            this.model          = model;
            this.rest           = rest;
            this.manager        = notmanager;
            this.ExecuteCommand = new RelayCommand(this.OnAssociateCommand);
            this.SubItems       = new ObservableCollection <IMenuItem>();

            // register menu for data sync
            AssociationModel.RegisterNewModelInPool(this);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ShowHideIssueColumn"/> class.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="helper">
        /// The helper.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="gridKey">
        /// The grid key.
        /// </param>
        public ShowHideIssueColumn(IssueGridViewModel model, IConfigurationHelper helper, string name, string gridKey)
        {
            this.gridKey        = gridKey;
            this.helper         = helper;
            this.name           = name;
            this.model          = model;
            this.CommandText    = "Columns";
            this.IsEnabled      = true;
            this.ExecuteCommand = new RelayCommand(this.OnAssociateCommand);
            this.SubItems       = new ObservableCollection <IMenuItem>();

            AssociationModel.RegisterNewModelInPool(this);
        }
Exemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IssuesSearchModel" /> class.
 /// </summary>
 /// <param name="configurationHelper">The configuration helper.</param>
 /// <param name="restService">The rest service.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="translator">The translator.</param>
 public IssuesSearchModel(
     IConfigurationHelper configurationHelper,
     ISonarRestService restService,
     INotificationManager manager,
     ISQKeyTranslator translator)
 {
     this.keyTranslator         = translator;
     this.notificationmanager   = manager;
     this.configurationHelper   = configurationHelper;
     this.restService           = restService;
     this.issuesSearchViewModel = new IssuesSearchViewModel(this, manager, this.configurationHelper, restService, translator);
     AssociationModel.RegisterNewModelInPool(this);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SourceControlMenu" /> class.
        /// </summary>
        /// <param name="rest">The rest.</param>
        /// <param name="model">The model.</param>
        /// <param name="manager">The manager.</param>
        /// <param name="translator">The translator.</param>
        public SourceControlMenu(ISonarRestService rest, IssueGridViewModel model, INotificationManager manager, ISQKeyTranslator translator)
        {
            this.rest      = rest;
            this.model     = model;
            this.manager   = manager;
            this.tranlator = translator;

            this.ExecuteCommand = new RelayCommand(this.OnSourceControlCommand);
            this.SubItems       = new ObservableCollection <IMenuItem>();

            // register menu for data sync
            AssociationModel.RegisterNewModelInPool(this);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlanMenu" /> class.
        /// </summary>
        /// <param name="rest">The rest.</param>
        /// <param name="model">The model.</param>
        /// <param name="manager">The manager.</param>
        /// <param name="registerPool">if set to <c>true</c> [register pool].</param>
        private PlanMenu(ISonarRestService rest, IssueGridViewModel model, INotificationManager manager, bool registerPool = true)
        {
            this.manager = manager;
            this.model   = model;
            this.rest    = rest;

            this.ExecuteCommand = new RelayCommand(this.OnPlanCommand);
            this.SubItems       = new ObservableCollection <IMenuItem>();

            if (registerPool)
            {
                AssociationModel.RegisterNewModelInPool(this);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RoslynManagerModel" /> class.
        /// </summary>
        /// <param name="pluginsIn">The plugins in.</param>
        /// <param name="notificationManagerIn">The notification manager in.</param>
        /// <param name="configHelper">The configuration helper.</param>
        public RoslynManagerModel(
            IEnumerable <IAnalysisPlugin> pluginsIn,
            INotificationManager notificationManagerIn,
            IConfigurationHelper configHelper)
        {
            this.confHelper           = configHelper;
            this.plugins              = pluginsIn;
            this.notificationManager  = notificationManagerIn;
            this.ExtensionDiagnostics = new Dictionary <string, VSSonarExtensionDiagnostic>();
            this.InitializedInstalledDiagnostics();

            // register model
            AssociationModel.RegisterNewModelInPool(this);
        }
Exemplo n.º 20
0
        /// <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);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="IssueTrackerMenu" /> class.
        /// </summary>
        /// <param name="rest">The rest.</param>
        /// <param name="model">The model.</param>
        /// <param name="manager">The manager.</param>
        /// <param name="translator">The translator.</param>
        /// <param name="parent">The parent.</param>
        /// <param name="registerPool">if set to <c>true</c> [register pool].</param>
        private IssueTrackerMenu(ISonarRestService rest, IssueGridViewModel model, INotificationManager manager, ISQKeyTranslator translator, IssueTrackerMenu parent = null, bool registerPool = true)
        {
            this.translator = translator;
            this.manager    = manager;
            this.model      = model;
            this.rest       = rest;
            this.parent     = parent;

            this.ExecuteCommand = new RelayCommand(this.OnAttachToIssueTracker);
            this.SubItems       = new ObservableCollection <IMenuItem>();

            if (registerPool)
            {
                AssociationModel.RegisterNewModelInPool(this);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="IssuesSearchModel" /> class.
 /// </summary>
 /// <param name="configurationHelper">The configuration helper.</param>
 /// <param name="restService">The rest service.</param>
 /// <param name="manager">The manager.</param>
 /// <param name="translator">The translator.</param>
 /// <param name="analyser">The analyser.</param>
 public IssuesSearchModel(
     IConfigurationHelper configurationHelper,
     ISonarRestService restService,
     INotificationManager manager,
     ISQKeyTranslator translator,
     ISonarLocalAnalyser analyser,
     IList <IIssueTrackerPlugin> issuetrackerplugins)
 {
     this.keyTranslator         = translator;
     this.notificationmanager   = manager;
     this.configurationHelper   = configurationHelper;
     this.restService           = restService;
     this.issuesSearchViewModel = new IssuesSearchViewModel(this, manager, this.configurationHelper, restService, translator, analyser, issuetrackerplugins);
     this.restSourceModel       = new RestSourceControlModel(manager, restService);
     AssociationModel.RegisterNewModelInPool(this);
 }
        public void AssignWhenNoProjectDefinedReturnsFalse()
        {
            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>();

            AssociationModel associationModel;
            associationModel = new AssociationModel(mockLogger.Object, mockRest.Object, mockConfiguration.Object, mockTranslator.Object, mockPlugin.Object, null);
            associationModel.UpdateServicesInModels(mockVsHelper.Object, null, null);

            Assert.That(associationModel.AssignASonarProjectToSolution(null, null), Is.False);
        }
Exemplo n.º 24
0
        public void AssignWhenNoProjectDefinedReturnsFalse()
        {
            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>();

            AssociationModel associationModel;

            associationModel = new AssociationModel(mockLogger.Object, mockRest.Object, mockConfiguration.Object, mockTranslator.Object, mockPlugin.Object, null);
            associationModel.UpdateServicesInModels(mockVsHelper.Object, null, null);

            Assert.That(associationModel.AssignASonarProjectToSolution(null, null), Is.False);
        }
Exemplo n.º 25
0
        /// <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="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);
        }
Exemplo n.º 27
0
        public void AssignWhenProjectIsMainAndBranchIsNullReturnsFalse()
        {
            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>();

            AssociationModel associationModel;

            associationModel = new AssociationModel(mockLogger.Object, mockRest.Object, mockConfiguration.Object, mockTranslator.Object, mockPlugin.Object, new SonarQubeViewModel("test"));
            associationModel.UpdateServicesInModels(mockVsHelper.Object, null, null);

            Assert.That(associationModel.AssignASonarProjectToSolution(new Resource()
            {
                IsBranch = true
            }, null), Is.False);
        }
        public void AssignProjectIsNotMainReturnsTrue()
        {
            var mockTranslator = new Mock<ISQKeyTranslator>();
            var mockRest = new Mock<ISonarRestService>();
            var mockLogger = new Mock<INotificationManager>();
            var mockPlugin = new Mock<IPluginManager>();
            var mockConfiguration = new Mock<IConfigurationHelper>();
            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;

            AssociationModel associationModel;
            associationModel = new AssociationModel(mockLogger.Object, mockRest.Object, mockObj, mockTranslator.Object, mockPlugin.Object, new SonarQubeViewModel("test", mockObj));
            associationModel.UpdateServicesInModels(mockVsHelper.Object, null, null);

            Assert.That(associationModel.AssignASonarProjectToSolution(new Resource() { IsBranch = false }, null), Is.True);
            Assert.That(associationModel.IsAssociated, Is.True);
        }
Exemplo n.º 29
0
        public static RelationshipType GetRelationshipType(this AssociationModel association)
        {
            if ((association.SourceEnd.Multiplicity == Multiplicity.One || association.SourceEnd.Multiplicity == Multiplicity.ZeroToOne) && (association.TargetEnd.Multiplicity == Multiplicity.One || association.TargetEnd.Multiplicity == Multiplicity.ZeroToOne))
            {
                return(RelationshipType.OneToOne);
            }
            if ((association.SourceEnd.Multiplicity == Multiplicity.One || association.SourceEnd.Multiplicity == Multiplicity.ZeroToOne) && association.TargetEnd.Multiplicity == Multiplicity.Many)
            {
                return(RelationshipType.OneToMany);
            }
            if (association.SourceEnd.Multiplicity == Multiplicity.Many && (association.TargetEnd.Multiplicity == Multiplicity.One || association.TargetEnd.Multiplicity == Multiplicity.ZeroToOne))
            {
                return(RelationshipType.ManyToOne);
            }
            if (association.SourceEnd.Multiplicity == Multiplicity.Many && association.TargetEnd.Multiplicity == Multiplicity.Many)
            {
                return(RelationshipType.ManyToMany);
            }

            throw new Exception($"The relationship type from [{association.SourceEnd.Class.Name}] to [{association.TargetEnd.Class.Name}] could not be determined.");
        }
Exemplo n.º 30
0
        // not used for the trousers

        private Dictionary <string, ContentReference> GetAggregatedAssocciations(EntryContentBase currentContent)
        {
            // cannot get to the ContentLink with @Html.
            // should return a chunk for each Assicciation
            IEnumerable <EPiServer.Commerce.Catalog.Linking.Association> assoc = currentContent.GetAssociations();
            Dictionary <string, ContentReference> localStuff = new Dictionary <string, ContentReference>();

            if (assoc.Count() > 0)
            {
                foreach (var item in assoc)
                {
                    localStuff.Add(GetAssociationMetaDataSingle(item), GetAssociatedEntry(item)); // need to refactor the returntypes and the
                }
            }
            else
            {
                localStuff.Add("Nothing", ContentReference.SelfReference); // just to some back... for now
            }
            return(localStuff);

            // may need theese
            AssociationModel        otherModel  = new AssociationModel();
            List <AssociationModel> otherModels = new List <AssociationModel>();
        }
Exemplo n.º 31
0
 public static string RelationshipString(this AssociationModel association)
 {
     return($"{association.SourceEnd.MultiplicityString()}->{association.TargetEnd.MultiplicityString()}");
 }
 public void CreateResourcePathFileThrowsNotImplementedException170()
 {
     AssociationModel associationModel;
     Resource resource;
     StandAloneVsHelper s0 = new StandAloneVsHelper();
     associationModel = new AssociationModel(null, null, null, null, null, null);
     associationModel.UpdateServicesInModels(s0, null, null);
     Assert.Throws<NotImplementedException>(() => resource = associationModel.CreateResourcePathFile((string)null, (Resource)null));
 }
Exemplo n.º 33
0
 /// <summary>
 /// Using this method user could modify association code generation options:
 /// <list type="bullet">
 /// <item>Metadata for both sides of association: <see cref="AssociationModel.SourceMetadata"/> and <see cref="AssociationModel.TargetMetadata"/></item>
 /// <item>Configure association properties in entity classes: <see cref="AssociationModel.Property"/> and <see cref="AssociationModel.BackreferenceProperty"/></item>
 /// <item>Configure association extension methods: <see cref="AssociationModel.Extension"/> and <see cref="AssociationModel.BackreferenceExtension"/></item>
 /// <item>Association cardinality: <see cref="AssociationModel.ManyToOne"/></item>
 /// </list>
 /// Also it is possible to modify set of columns, used by association, but it is probably not very useful.
 /// </summary>
 /// <param name="typeParser">Type parser service to create type tokens.</param>
 /// <param name="associationModel">Association model descriptor.</param>
 public virtual void PreprocessAssociation(ITypeParser typeParser, AssociationModel associationModel)
 {
 }
 public void CreateResourcePathFileIsNull()
 {
     AssociationModel associationModel;
     associationModel =
       new AssociationModel(null, null, null, null, null, null);
     Assert.That(associationModel.CreateResourcePathFile(null, null), Is.Null);
 }
        public void AssignWhenProjectIsMainAndBranchIsNullReturnsFalse()
        {
            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>();

            AssociationModel associationModel;
            associationModel = new AssociationModel(mockLogger.Object, mockRest.Object, mockConfiguration.Object, mockTranslator.Object, mockPlugin.Object, new SonarQubeViewModel("test"));
            associationModel.UpdateServicesInModels(mockVsHelper.Object, null, null);

            Assert.That(associationModel.AssignASonarProjectToSolution(new Resource() { IsBranch = true}, null), Is.False);
        }