Exemplo n.º 1
0
        public void SaveSetsValues()
        {
            // Arrange
            var vm = new SettingsViewModel( MockContext.ViewServiceRepo, MockContext.SettingsRepo, MockContext.AppThemes );

            // Act
            vm.SelectedAccent = vm.AvailableAccents.Last();
            vm.SelectedTheme = vm.AvailableThemes.Last();
            vm.SelectedLanguage = vm.AvailableLanguages.Last();
            vm.ExpandEntries = !vm.ExpandEntries;

            vm.SaveCommand.Execute( null );

            // Assert
            Assert.AreEqual( vm.AvailableAccents.Last().Name, Settings[SettingKeys.Accent].Value );
            Assert.AreEqual( vm.AvailableThemes.Last().Name, Settings[SettingKeys.Theme].Value );
            Assert.AreEqual( vm.AvailableLanguages.Last().IetfLanguageTag, Settings[SettingKeys.Language].Value );
            Assert.AreEqual( vm.ExpandEntries.ToString(), Settings[SettingKeys.ExpandEntries].Value );
        }
Exemplo n.º 2
0
        public void ResetToDefaultsSetsDefaultValues()
        {
            // Arrange
            var vm = new SettingsViewModel( MockContext.ViewServiceRepo, MockContext.SettingsRepo, MockContext.AppThemes );

            // Act
            vm.SelectedTheme = new ColorItem { Name = "test" };
            vm.SelectedAccent = new ColorItem { Name = "test" };
            vm.SelectedLanguage = CultureInfo.CreateSpecificCulture( "es-ES" );

            vm.ResetToDefaultsCommand.Execute( null );

            // Assert
            Assert.AreEqual( SettingKeys.DefaultValues[SettingKeys.Accent], vm.SelectedAccent.Name );
            Assert.AreEqual( SettingKeys.DefaultValues[SettingKeys.Theme], vm.SelectedTheme.Name );
            Assert.AreEqual( SettingKeys.DefaultValues[SettingKeys.Language], vm.SelectedLanguage.IetfLanguageTag );
            Assert.AreEqual( SettingKeys.DefaultValues[SettingKeys.DatabasePath], vm.DatabasePath );
            Assert.AreEqual( SettingKeys.DefaultValues[SettingKeys.ExpandEntries], vm.ExpandEntries.ToString() );
        }