Example #1
0
        public SettingsViewModel(IConfiguration configuration, Action saveMethod, IUserIdentityList userIdentityList)
        {
            _saveMethod            = saveMethod;
            _userIdentityList      = userIdentityList;
            _configuration         = configuration;
            EditConnectionsCommand = new DelegateCommand(EditConnections);

            Language                      = new LanguageOptionViewModel(configuration.Language);
            AnimationsMode                = new EnumOptionViewModel <AnimationMode>(StringLocalizer.Keys.AnimationSpeed, configuration.AnimationSpeed);
            AutoStartMode                 = new EnumOptionViewModel <AutostartMode>(StringLocalizer.Keys.Autostart, configuration.Autostart);
            CanceledBuildNotify           = new EnumOptionViewModel <BuildNotificationModes>(StringLocalizer.Keys.CanceledBuildNotifyConfig, configuration.CanceledBuildNotifyConfig);
            FailedBuildNotify             = new EnumOptionViewModel <BuildNotificationModes>(StringLocalizer.Keys.FailedBuildNotifyConfig, configuration.FailedBuildNotifyConfig);
            SucceededBuildNotify          = new EnumOptionViewModel <BuildNotificationModes>(StringLocalizer.Keys.SucceededBuildNotifyConfig, configuration.SucceededBuildNotifyConfig);
            PartialSucceededTreatmentMode = new EnumOptionViewModel <PartialSucceededTreatmentMode>(StringLocalizer.Keys.PartialSucceededTreatmentMode, configuration.PartialSucceededTreatmentMode);
            BuildsPerGroup                = new NumberOptionViewModel(configuration.BuildsToShow, 1, 100, StringLocalizer.Keys.BuildsToShow);
            ShowBusyIndicatorDuringUpdate = new BooleanOptionViewModel(configuration.ShowBusyIndicatorOnDeltaUpdates, StringLocalizer.Keys.ShowBusyIndicatorOnDeltaUpdates);
            UpdateInterval                = new NumberOptionViewModel(configuration.UpdateInterval, 30, int.MaxValue, StringLocalizer.Keys.UpdateInterval);
            UpdateToPreReleases           = new BooleanOptionViewModel(configuration.UsePreReleases, StringLocalizer.Keys.UsePreReleases);

            foreach (var option in Options)
            {
                option.ValueChanged += Option_ValueChanged;
            }

            UpdateUser();
        }
        public ProjectViewModel(IProjectConfiguration model, IConfiguration configuration)
        {
            _configuration = configuration;
            Model          = model;

            Name      = new TextOptionViewModel(model.ProjectName, StringLocalizer.ProjectName);
            IsEnabled = new BooleanOptionViewModel(model.IsEnabled, StringLocalizer.IsEnabled);
            PullRequestDisplayMode    = new EnumOptionViewModel <PullRequestDisplayMode>(StringLocalizer.ShowPullRequests, model.PullRequestDisplay);
            DefaultCompareBranch      = new TextOptionViewModel(model.DefaultCompareBranch, StringLocalizer.DefaultCompareBranch);
            HideCompletedPullRequests = new BooleanOptionViewModel(model.HideCompletedPullRequests, StringLocalizer.HideCompletedPullRequests);

            BranchBlacklist          = new StringCollectionOptionViewModel(StringLocalizer.BranchBlacklist, model.BranchBlacklist);
            BranchWhitelist          = new StringCollectionOptionViewModel(StringLocalizer.BranchWhitelist, model.BranchWhitelist);
            BuildDefinitionBlacklist = new StringCollectionOptionViewModel(StringLocalizer.BuildDefinitionBlacklist, model.BuildDefinitionBlacklist);
            BuildDefinitionWhitelist = new StringCollectionOptionViewModel(StringLocalizer.BuildDefinitionWhitelist, model.BuildDefinitionWhitelist);

            var connections = configuration.Connections.Where(c => c.ConnectionType == ConnectionPluginType.SourceControl).ToList();
            var connection  = connections.FirstOrDefault(c => c.Name == model.SourceControlConnectionName) ?? new ConnectionData();

            SourceControlConnection = new ConnectionOptionViewModel(StringLocalizer.SourceControlConnectionNames, connections, connection);

            connections     = configuration.Connections.Where(c => c.ConnectionType == ConnectionPluginType.Build).ToList();
            connection      = connections.FirstOrDefault(c => c.Name == model.BuildConnectionNames.FirstOrDefault()) ?? new ConnectionData();
            BuildConnection = new ConnectionOptionViewModel(StringLocalizer.BuildConnectionNames, connections, connection);

            foreach (var option in Options)
            {
                option.ValueChanged += Option_ValueChanged;
            }
        }
        public void DisplayNameShouldUseToStringWhenNotLocalizable()
        {
            // Arrange
            var sut = new EnumOptionViewModel <TestEnumWithoutLocalization>("displayName");

            // Act
            var actual = sut.AvailableValues.First().DisplayName;

            // Assert
            Assert.Equal("NonLocalizableOne", actual);
        }