/// <summary> /// Save selected filetypes as preset filter. /// </summary> void SavePreset() { if (!(String.IsNullOrWhiteSpace(_savePresetText) || String.IsNullOrEmpty(_savePresetText))) { if (_presets.PresetExists(_savePresetText)) { MessageBox.Show("Preset already exists."); } else { try { _presets.AddPreset(_savePresetText, _fgOrganiser.SelectedFileTypes); } catch (ArgumentException AEx) { _logger.LogError(AEx.Message + "\n" + AEx.StackTrace); } SavePresetText = String.Empty; OnPropertyChanged("PresetNames"); } } }
/// <summary> /// Method for saving a new preset. /// </summary> void SaveNewPreset() { if (!String.IsNullOrEmpty(_newPresetName) && !String.IsNullOrWhiteSpace(_newPresetName)) { if (_newPresetFileTypes.Count > 0) { if (!_presets.PresetExists(_newPresetName)) { _presets.AddPreset(_newPresetName, GUIDispatcherUpdates.CollectionAsList(_newPresetFileTypes)); NewPresetName = String.Empty; _newPresetFileTypes = null; OnPropertyChanged("NewPresetFileTypes"); OnPropertyChanged("PresetNames"); } else { NewPresetErrorText = "Preset filter name currently exists."; } } else { NewPresetErrorText = "Filetypes must exist."; } } else { NewPresetErrorText = "Preset filter name can't be empty or whitespace."; } }
public void PresetTypeExistsTest() { PresetFilters target = new PresetFilters(); string presetName = "AreYouMockingMe"; List <string> types = new List <string>() { "Yes" }; target.AddPreset(presetName, types); Assert.IsTrue(target.PresetTypeExists(presetName, "Yes"), "Added type does not appear to exist"); }
public void PresetExistsTest() { PresetFilters target = new PresetFilters(); string presetName = "MockedYouOut"; List <string> types = new List <string>() { "Mocking" }; target.AddPreset(presetName, types); Assert.IsTrue(target.PresetExists(presetName), "Added preset does not appear to exist"); }
public void AddPresetTest() { bool condition = false; PresetFilters target = new PresetFilters(); string presetName = null; List <string> types = null; try { target.AddPreset(presetName, types); } catch (ArgumentException AEx) { condition = true; } Assert.IsTrue(condition); condition = true; presetName = "MockPreset"; types = new List <string>() { "mp3" }; try { target.AddPreset(presetName, types); } catch (ArgumentException AEx) { condition = false; } Assert.IsTrue(condition); }
public void RemovePresetTypeTest() { PresetFilters target = new PresetFilters(); string presetName = "MockingBird"; List <string> types = new List <string>() { "MockING" }; target.AddPreset(presetName, types); target.RemovePresetType(presetName, "MockING"); Assert.IsFalse(target.PresetTypeExists(presetName, "MockING"), "Added type does not appear to exist"); }
public void GetPresetTypesTest() { PresetFilters target = new PresetFilters(); string presetName = "MockedOut"; List <string> types = new List <string>() { "Mocking" }; target.AddPreset(presetName, types); List <string> returnTypes = target.GetPresetTypes(presetName); Assert.IsTrue(returnTypes.Contains("Mocking"), "Added type has not been found"); }
public void EditPresetsTest() { PresetFilters target = new PresetFilters(); string presetName = "MockedUp"; List <string> types = new List <string>() { "Mocking" }; target.AddPreset(presetName, types); List <string> newTypes = new List <string>() { "Mark" }; string newName = "Marking"; target.EditPresets(presetName, newName, newTypes); Assert.IsTrue(target.PresetExists("Marking"), "Preset name has not been changed"); Assert.IsTrue(target.PresetTypeExists("Marking", "Mark"), "New types have not been added"); }