Esempio n. 1
0
        public void SaveSettings()
        {
            var settings = ConfigurationSerializer.Load();

            settings.Font = SelectedFont.Source;
            ConfigurationSerializer.Save(settings);
        }
 public ReadLaterListViewModel()
 {
     readLaterManager = ServiceLocator.Current.GetInstance <IReadLaterManager>();
     dataLoader       = ServiceLocator.Current.GetInstance <IDataLoader>();
     settings         = ConfigurationSerializer.Load();
     recommendations  = new ObservableCollection <RecommendationViewModel>();
 }
Esempio n. 3
0
 private void LoadViewModels()
 {
     Items.Add(new HomeViewModel());
     Items.Add(new ReadLaterListViewModel());
     Items.Add(new ConfigurationViewModel());
     ActivateItem(Items.First());
     DisplayName = string.Format("NewsStand - {0}", ConfigurationSerializer.Load().Username);
 }
Esempio n. 4
0
        public ConfigurationViewModel()
        {
            DisplayName    = "CFG";
            InstalledFonts = new ObservableCollection <FontFamily>(Fonts.SystemFontFamilies.OrderBy(c => c.Source));
            var settings = ConfigurationSerializer.Load();

            SelectedFont = string.IsNullOrEmpty(settings.Font) ? InstalledFonts.First() : InstalledFonts.Single(c => c.Source == settings.Font);
        }
Esempio n. 5
0
        protected override void OnActivate()
        {
            base.OnActivate();

            settings = ConfigurationSerializer.Load();

            Username = settings.Username;

            LoadRecommendations();
        }
Esempio n. 6
0
        public void LoadShouldNotCrashWhenFileDoesNotExist()
        {
            // Arrange
            const string fileName   = "non.existing";
            var          serializer = Substitute.For <ISerializer>();
            var          sut        = new ConfigurationSerializer(serializer);

            // Act
            var config = sut.Load(fileName);

            // Assert
            Assert.NotNull(config);
        }
Esempio n. 7
0
        private static void Run(UpdateOptions options)
        {
            string configFile = Path.Combine(Environment.CurrentDirectory, options.ConfigFile);

            // If the file doesn't exist, alert the user.
            if (!File.Exists(options.ConfigFile))
            {
                throw new Exception($"The configuration file '{options.ConfigFile}' does not exist.");
            }

            Configuration config = ConfigurationSerializer.Load(configFile);

            // Runs the update process
            new ProcessOrchestrator(Directory.GetCurrentDirectory(), config).Execute();
        }
Esempio n. 8
0
        public void LoadShouldSetBuildAndSourceControlFunctionsOfPluginRepo()
        {
            // Arrange
            const string fileName   = "non.existing";
            var          serializer = Substitute.For <ISerializer>();
            var          pluginRepo = Substitute.For <IPluginRepository>();

            pluginRepo.Build.Returns(new List <IBuildPlugin> {
                Substitute.For <IBuildPlugin>()
            });
            var sut = new ConfigurationSerializer(serializer, pluginRepo);

            // Act
            var config = sut.Load(fileName);

            // Assert
            Assert.True(((Configuration)config).PossibleBuildPlugins().Any());
        }
        public void LoadShouldNotCreateFileWhenFileDoesNotExist()
        {
            // Arrange
            const string fileName   = "non.existing";
            var          serializer = Substitute.For <ISerializer>();

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            var sut = new ConfigurationSerializer(serializer);

            // Act
            var actual = sut.Load(fileName);

            // Assert
            Assert.NotNull(actual);
            Assert.False(File.Exists(fileName));
        }
Esempio n. 10
0
 public ShellViewModel()
 {
     if (ConfigurationSerializer.Load() == null)
     {
         DisplayName = "NewsStand";
         var usernameModel = new UsernameViewModel();
         usernameModel.Closed += (o, e) =>
         {
             ConfigurationSerializer.Save(new Settings()
             {
                 Username = e.Username
             });
             usernameModel.TryClose();
             LoadViewModels();
         };
         ActivateItem(usernameModel);
     }
     else
     {
         LoadViewModels();
     }
 }
        public void LoadShouldReadSameValuesAsSaveWrote()
        {
            // Arrange
            const string fileName   = nameof(LoadShouldReadSameValuesAsSaveWrote) + ".json";
            var          serializer = new Serializer();

            var sut = new ConfigurationSerializer(serializer);

            var expected = new Configuration
            {
                BuildsToShow = 2,
                CanceledBuildNotifyConfig = BuildNotificationModes.RequestedByMe,
                Connections = new List <ConnectionData>
                {
                    new ConnectionData
                    {
                        PluginConfiguration = "Test123",
                        PluginType          = "BuildPlugin",
                        Name = "ConnectionName"
                    }
                },
                FailedBuildNotifyConfig = BuildNotificationModes.RequestedByOrForMe,
                GroupDefinition         = new BuildTreeGroupDefinition(GroupDefinition.Branch, GroupDefinition.Status),
                UsePreReleases          = true,
                Language                   = "language",
                SortingDefinition          = new BuildTreeSortingDefinition(SortingDefinition.DateAscending, SortingDefinition.StatusDescending),
                UpdateInterval             = 3,
                SucceededBuildNotifyConfig = BuildNotificationModes.RequestedForMe,
                Projects                   = new List <IProjectConfiguration>
                {
                    new ProjectConfiguration
                    {
                        ProjectName          = "Project",
                        DefaultCompareBranch = "compare",
                        PullRequestDisplay   = PullRequestDisplayMode.Number,
                        BuildConnectionNames = new List <string>
                        {
                            "BCN1"
                        },
                        SourceControlConnectionName = "SCN1",
                        BranchBlacklist             = new List <string>
                        {
                            "Black1"
                        },
                        BranchWhitelist = new List <string>
                        {
                            "White1"
                        },
                        BuildDefinitionBlacklist = new List <string>
                        {
                            "BlackDef1"
                        },
                        BuildDefinitionWhitelist = new List <string>
                        {
                            "WhiteDef1"
                        },
                        HideCompletedPullRequests = true
                    }
                }
            };

            // Act
            sut.Save(expected, fileName);
            var actual = sut.Load(fileName);

            // Assert
            Assert.Equal(expected.BuildsToShow, actual.BuildsToShow);
            Assert.Equal(expected.UpdateInterval, actual.UpdateInterval);
            Assert.Equal(expected.Language, actual.Language);
            Assert.Equal(expected.FailedBuildNotifyConfig, actual.FailedBuildNotifyConfig);
            Assert.Equal(expected.SucceededBuildNotifyConfig, actual.SucceededBuildNotifyConfig);
            Assert.Equal(expected.CanceledBuildNotifyConfig, actual.CanceledBuildNotifyConfig);
            Assert.Equal(expected.GroupDefinition, actual.GroupDefinition);
            Assert.Equal(expected.SortingDefinition, actual.SortingDefinition);
            Assert.Equal(expected.UsePreReleases, actual.UsePreReleases);

            Assert.Single(actual.Connections);
            Assert.Equal(expected.Connections[0].Name, actual.Connections[0].Name);
            Assert.Equal(expected.Connections[0].PluginConfiguration, actual.Connections[0].PluginConfiguration);
            Assert.Equal(expected.Connections[0].PluginType, actual.Connections[0].PluginType);

            Assert.Single(actual.Projects);
            Assert.Equal(expected.Projects[0].ProjectName, actual.Projects[0].ProjectName);
            Assert.Equal(expected.Projects[0].DefaultCompareBranch, actual.Projects[0].DefaultCompareBranch);
            Assert.Equal(expected.Projects[0].PullRequestDisplay, actual.Projects[0].PullRequestDisplay);
            Assert.Equal(expected.Projects[0].BuildConnectionNames, actual.Projects[0].BuildConnectionNames);
            Assert.Equal(expected.Projects[0].SourceControlConnectionName, actual.Projects[0].SourceControlConnectionName);
            Assert.Equal(expected.Projects[0].BranchBlacklist, actual.Projects[0].BranchBlacklist);
            Assert.Equal(expected.Projects[0].BuildDefinitionBlacklist, actual.Projects[0].BuildDefinitionBlacklist);
            Assert.Equal(expected.Projects[0].BranchWhitelist, actual.Projects[0].BranchWhitelist);
            Assert.Equal(expected.Projects[0].BuildDefinitionWhitelist, actual.Projects[0].BuildDefinitionWhitelist);
            Assert.Equal(expected.Projects[0].HideCompletedPullRequests, actual.Projects[0].HideCompletedPullRequests);
        }