示例#1
0
        public void RefreshView()
        {
            _config = _configurationService.LoadConfiguration();

            _view.UserName     = _config.UserName;
            _view.EmailAddress = _config.EmailAddress;
            _view.DefaultRepositoryLocation = _config.DefaultRepositoryLocation;
        }
示例#2
0
        public void CanCreateUpdateDeleteSourceControlConfiguration()
        {
            ClusterInfo cluster = new ClusterInfo(
                name: "azure-arc5",
                type: ClusterInfo.ClusterType.connectedClusters,
                location: "eastus2euap",
                resourceGroup: "haikudevtesting"
                );

            SourceControlConfiguration configuration = new SourceControlConfiguration(
                name: "netsdktestconfig01a",
                type: SourceControlConfigurationTestBase.ConfigurationType,
                repositoryUrl: "git://github.com/anubhav929/flux-get-started",
                operatorNamespace: "netsdktestconfig01a-opns",
                operatorInstanceName: "netsdktestconfig01a-opin",
                operatorParams: "--git-readonly",
                operatorScope: "namespace",
                enableHelmOperator: "true"
                );

            using (var context = MockContext.Start(this.GetType()))
            {
                using (var testFixture = new SourceControlConfigurationTestBase(context))
                {
                    testFixture.Cluster = cluster;
                    testFixture.SourceControlConfiguration = configuration;

                    // List configurations and get count
                    var configurations = testFixture.ListSourceControlConfigurations();
                    int configCount    = configurations.Count();

                    // Create a configuration
                    var newConfig = testFixture.CreateSourceControlConfiguration();
                    Assert.NotNull(newConfig);

                    // Get the configuration and verify
                    var config = testFixture.GetSourceControlConfiguration();
                    Assert.Equal(configuration.Name, config.Name);
                    Assert.True((config.ComplianceStatus.ComplianceState.ToString() == "Pending") || (config.ComplianceStatus.ComplianceState.ToString() == "Installed"));

                    // List configurations and get count to confirm it is up by one
                    configurations = testFixture.ListSourceControlConfigurations();
                    Assert.True(configurations.Count() == configCount + 1);

                    // Delete the configuration created
                    testFixture.DeleteSourceControlConfiguration();

                    // List configurations and get count to confirm it is what we started with
                    configurations = testFixture.ListSourceControlConfigurations();
                    Assert.True(configurations.Count() == configCount);
                }
            }
        }
示例#3
0
        public void Initialize()
        {
            _config = new SourceControlConfiguration(Name, Email, RepoLocation, new List <Repository>());

            _configService = new Mock <IConfigurationService <SourceControlConfiguration> >();
            _configService.Setup(s => s.LoadConfiguration()).Returns(_config);

            _folderBrowser        = new Mock <IFolderBrowser>();
            _folderBrowserFactory = new Mock <IFolderBrowserFactory>();
            _folderBrowserFactory.Setup(f => f.CreateFolderBrowser(It.IsAny <string>())).Returns(_folderBrowser.Object);
            _folderBrowserFactory.Setup(f => f.CreateFolderBrowser(It.IsAny <string>(), false)).Returns(_folderBrowser.Object);
        }
示例#4
0
        private void OnSave(object sender, EventArgs e)
        {
            if (_config == null)
            {
                _config = _configurationService.LoadConfiguration();
            }

            _config.EmailAddress = _view.EmailAddress;
            _config.UserName     = _view.UserName;
            _config.DefaultRepositoryLocation = _view.DefaultRepositoryLocation;

            _configurationService.SaveConfiguration(_config);
        }
        public SourceControlPresenter(
            VBE vbe, AddIn addin,
            IConfigurationService <SourceControlConfiguration> configService,
            ISourceControlView view,
            IChangesPresenter changesPresenter,
            IBranchesPresenter branchesPresenter,
            ISettingsPresenter settingsPresenter,
            IUnsyncedCommitsPresenter unsyncedPresenter,
            IFolderBrowserFactory folderBrowserFactory,
            ISourceControlProviderFactory providerFactory,
            IFailedMessageView failedMessageView,
            ILoginView loginView
            )
            : base(vbe, addin, view)
        {
            _configService = configService;
            _config        = _configService.LoadConfiguration();

            _changesPresenter = changesPresenter;
            _changesPresenter.ActionFailed += OnActionFailed;

            _branchesPresenter = branchesPresenter;
            _branchesPresenter.ActionFailed += OnActionFailed;

            _settingsPresenter = settingsPresenter;
            _settingsPresenter.ActionFailed += OnActionFailed;

            _unsyncedPresenter = unsyncedPresenter;
            _unsyncedPresenter.ActionFailed += OnActionFailed;

            _folderBrowserFactory             = folderBrowserFactory;
            _providerFactory                  = providerFactory;
            _branchesPresenter.BranchChanged += _branchesPresenter_BranchChanged;

            _loginView          = loginView;
            _loginView.Confirm += _loginView_Confirm;

            _failedMessageView = failedMessageView;
            _failedMessageView.DismissSecondaryPanel += DismissSecondaryPanel;

            _view = view;
            _view.SecondaryPanel = _failedMessageView;

            _view.RefreshData             += OnRefreshChildren;
            _view.OpenWorkingDirectory    += OnOpenWorkingDirectory;
            _view.InitializeNewRepository += OnInitNewRepository;
        }
        public void Initialize()
        {
            _view = new Mock <ISettingsView>();
            _view.SetupProperty(v => v.UserName, string.Empty);
            _view.SetupProperty(v => v.EmailAddress, string.Empty);
            _view.SetupProperty(v => v.DefaultRepositoryLocation, string.Empty);

            _config = new SourceControlConfiguration(Name, Email, RepoLocation, new List <Repository>());

            _configService = new Mock <IConfigurationService <SourceControlConfiguration> >();
            _configService.Setup(s => s.LoadConfiguration()).Returns(_config);

            _folderBrowser        = new Mock <IFolderBrowser>();
            _folderBrowserFactory = new Mock <IFolderBrowserFactory>();
            _folderBrowserFactory.Setup(f => f.CreateFolderBrowser(It.IsAny <string>())).Returns(_folderBrowser.Object);
            _folderBrowserFactory.Setup(f => f.CreateFolderBrowser(It.IsAny <string>(), false)).Returns(_folderBrowser.Object);
        }
        public SettingsViewViewModel(
            IConfigurationService <SourceControlConfiguration> configService,
            IFolderBrowserFactory folderBrowserFactory)
        {
            _configService        = configService;
            _folderBrowserFactory = folderBrowserFactory;
            _config = _configService.LoadConfiguration();

            UserName     = _config.UserName;
            EmailAddress = _config.EmailAddress;
            DefaultRepositoryLocation = _config.DefaultRepositoryLocation;

            _showFilePickerCommand        = new DelegateCommand(_ => ShowFilePicker());
            _cancelSettingsChangesCommand = new DelegateCommand(_ => CancelSettingsChanges());
            _updateSettingsCommand        = new DelegateCommand(_ => UpdateSettings());
            _showGitIgnoreCommand         = new DelegateCommand(_ => ShowGitIgnore(), _ => Provider != null);
            _showGitAttributesCommand     = new DelegateCommand(_ => ShowGitAttributes(), _ => Provider != null);
        }
示例#8
0
        public SourceControlViewViewModel(
            VBE vbe,
            ISourceControlProviderFactory providerFactory,
            IFolderBrowserFactory folderBrowserFactory,
            IConfigurationService <SourceControlConfiguration> configService,
            [Named("changesView")] IControlView changesView,
            [Named("branchesView")] IControlView branchesView,
            [Named("unsyncedCommitsView")] IControlView unsyncedCommitsView,
            [Named("settingsView")] IControlView settingsView,
            ICodePaneWrapperFactory wrapperFactory)
        {
            _vbe                  = vbe;
            _providerFactory      = providerFactory;
            _folderBrowserFactory = folderBrowserFactory;

            _configService  = configService;
            _config         = _configService.LoadConfiguration();
            _wrapperFactory = wrapperFactory;

            _initRepoCommand            = new DelegateCommand(_ => InitRepo());
            _openRepoCommand            = new DelegateCommand(_ => OpenRepo());
            _cloneRepoCommand           = new DelegateCommand(_ => ShowCloneRepoGrid());
            _refreshCommand             = new DelegateCommand(_ => Refresh());
            _dismissErrorMessageCommand = new DelegateCommand(_ => DismissErrorMessage());
            _showFilePickerCommand      = new DelegateCommand(_ => ShowFilePicker());
            _closeLoginGridCommand      = new DelegateCommand(_ => CloseLoginGrid());

            _cloneRepoOkButtonCommand     = new DelegateCommand(_ => CloneRepo(), _ => !IsNotValidRemotePath);
            _cloneRepoCancelButtonCommand = new DelegateCommand(_ => CloseCloneRepoGrid());

            TabItems = new ObservableCollection <IControlView>
            {
                changesView,
                branchesView,
                unsyncedCommitsView,
                settingsView
            };
            Status = RubberduckUI.Offline;

            ListenForErrors();
        }
        public void Save()
        {
            var repo = new Repository
                       (
                "SourceControlTest",
                @"C:\Users\Christopher\Documents\SourceControlTest",
                @"https://github.com/ckuhn203/SourceControlTest.git"
                       );

            var config = new SourceControlConfiguration(
                "Chris McClellan",
                "*****@*****.**",
                @"C:\users\christopher\documents\",
                new List <Repository>()
            {
                repo
            }
                );

            var service = new SourceControlConfigurationService();

            service.SaveConfiguration(config);
        }
 /// <summary>
 /// Create a new Kubernetes Source Control Configuration.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='clusterRp'>
 /// The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS
 /// clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Possible
 /// values include: 'Microsoft.ContainerService', 'Microsoft.Kubernetes'
 /// </param>
 /// <param name='clusterResourceName'>
 /// The Kubernetes cluster resource name - either managedClusters (for AKS
 /// clusters) or connectedClusters (for OnPrem K8S clusters). Possible values
 /// include: 'managedClusters', 'connectedClusters'
 /// </param>
 /// <param name='clusterName'>
 /// The name of the kubernetes cluster.
 /// </param>
 /// <param name='sourceControlConfigurationName'>
 /// Name of the Source Control Configuration.
 /// </param>
 /// <param name='sourceControlConfiguration'>
 /// Properties necessary to Create KubernetesConfiguration.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <SourceControlConfiguration> CreateOrUpdateAsync(this ISourceControlConfigurationsOperations operations, string resourceGroupName, string clusterRp, string clusterResourceName, string clusterName, string sourceControlConfigurationName, SourceControlConfiguration sourceControlConfiguration, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, clusterRp, clusterResourceName, clusterName, sourceControlConfigurationName, sourceControlConfiguration, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Create a new Kubernetes Source Control Configuration.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='clusterRp'>
 /// The Kubernetes cluster RP - either Microsoft.ContainerService (for AKS
 /// clusters) or Microsoft.Kubernetes (for OnPrem K8S clusters). Possible
 /// values include: 'Microsoft.ContainerService', 'Microsoft.Kubernetes'
 /// </param>
 /// <param name='clusterResourceName'>
 /// The Kubernetes cluster resource name - either managedClusters (for AKS
 /// clusters) or connectedClusters (for OnPrem K8S clusters). Possible values
 /// include: 'managedClusters', 'connectedClusters'
 /// </param>
 /// <param name='clusterName'>
 /// The name of the kubernetes cluster.
 /// </param>
 /// <param name='sourceControlConfigurationName'>
 /// Name of the Source Control Configuration.
 /// </param>
 /// <param name='sourceControlConfiguration'>
 /// Properties necessary to Create KubernetesConfiguration.
 /// </param>
 public static SourceControlConfiguration CreateOrUpdate(this ISourceControlConfigurationsOperations operations, string resourceGroupName, string clusterRp, string clusterResourceName, string clusterName, string sourceControlConfigurationName, SourceControlConfiguration sourceControlConfiguration)
 {
     return(operations.CreateOrUpdateAsync(resourceGroupName, clusterRp, clusterResourceName, clusterName, sourceControlConfigurationName, sourceControlConfiguration).GetAwaiter().GetResult());
 }
        public void CanCreateUpdateDeleteSourceControlConfiguration()
        {
            ClusterInfo cluster = new ClusterInfo(
                name: "kctestcluster",
                type: ClusterInfo.ClusterType.connectedClusters,
                location: "eastus2euap",
                resourceGroup: "kubernetesconfiguration"
                );

            SourceControlConfiguration configuration = new SourceControlConfiguration(
                name: "netsdktestconfig01a",
                type: SourceControlConfigurationTestBase.ConfigurationType,
                repositoryUrl: "git://github.com/anubhav929/flux-get-started",
                operatorNamespace: "netsdktestconfig01a-opns",
                operatorInstanceName: "netsdktestconfig01a-opin",
                operatorParams: "--git-readonly",
                operatorScope: "namespace",
                enableHelmOperator: true,
                helmOperatorProperties: new HelmOperatorProperties(
                    chartVersion: "1.2.0",
                    chartValues: "--set helm.versions=v3"
                    ),
                configurationProtectedSettings: new Dictionary <string, string>()
            {
                { "dummyArg", "ZHVtbXlQYXJhbQ==" }
            }
                );

            using (var context = MockContext.Start(this.GetType()))
            {
                using (var testFixture = new SourceControlConfigurationTestBase(context))
                {
                    testFixture.Cluster = cluster;
                    testFixture.SourceControlConfiguration = configuration;

                    // List configurations and get count
                    var configurations = testFixture.ListSourceControlConfigurations();
                    int configCount    = configurations.Count();

                    // Create a configuration
                    var newConfig = testFixture.CreateSourceControlConfiguration();
                    Assert.NotNull(newConfig);

                    // Get the configuration and verify
                    var config = testFixture.GetSourceControlConfiguration();
                    Assert.Equal(configuration.Name, config.Name);
                    Assert.True((config.ComplianceStatus.ComplianceState.ToString() == "Pending") || (config.ComplianceStatus.ComplianceState.ToString() == "Installed"));

                    // List configurations and get count to confirm it is up by one
                    configurations = testFixture.ListSourceControlConfigurations();
                    Assert.True(configurations.Count() == configCount + 1);

                    // Delete the configuration created
                    testFixture.DeleteSourceControlConfiguration();

                    // List configurations and get count to confirm it is what we started with
                    configurations = testFixture.ListSourceControlConfigurations();
                    Assert.True(configurations.Count() == configCount);
                }
            }
        }