public void LoadUserSettingsCommand__PresetsNotEmpty_SettingsIsNotSaved__CannotExecute() { // Arrange: // Action: var mvm = GetMainViewModel(PresetFactory.GetPresetCollection()); // Assert: TestWithNoRegistryKeys(() => { Assert.IsFalse(mvm.LoadUserSettingsCommand.CanExecute(null)); }); }
public void LoadUserSettingsCommand__SettingsIsSaved__CallsAlarmSetDefaultSound() { // Arrange: // Action: var mvm = GetMainViewModel(PresetFactory.GetPresetCollection()); // Assert: TestWithRegistryKeys(() => { mvm.LoadUserSettingsCommand.Execute(null); _mockAlarm.Verify(a => a.SetDefaultSound(It.IsAny <Uri>()), Times.Once()); }); }
public void LoadUserSettingsCommand__SettingsIsSaved_SavedPresetExists__SetsSelectedPreset() { // Arrange: var presets = PresetFactory.GetPresetCollection(); // Action: var mvm = GetMainViewModel(presets); // Assert: TestWithRegistryKeys(() => { mvm.LoadUserSettingsCommand.Execute(null); Assert.That(mvm.SelectedPreset.Name, Is.EqualTo(presets[1].PresetName)); }, presets[1].PresetName); }
public void SaveUserSettingsCommand_SettingsIsNotSaved_CallsAlarmGetDefaultSound() { var mvm = GetMainViewModel(PresetFactory.GetPresetCollection()); mvm.SelectedPreset = mvm.PresetViewModelCollection[1]; TestWithNoRegistryKeys(() => { mvm.SaveUserSettingsCommand.Execute(null); _mockAlarm.Verify(a => a.GetDefaultSound(), Times.Once); Registry.CurrentUser.DeleteSubKey(MainViewModel.REG_PATH); }); }
public void SaveUserSettingsCommand_SettingsIsNotSaved_SaveSettings() { var mvm = GetMainViewModel(PresetFactory.GetPresetCollection()); mvm.SelectedPreset = mvm.PresetViewModelCollection[1]; TestWithNoRegistryKeys(() => { mvm.SaveUserSettingsCommand.Execute(null); var key = Registry.CurrentUser.OpenSubKey(MainViewModel.REG_PATH); Assert.IsNotNull(key); Assert.That(key.GetValue(MainViewModel.SELECTED_PRESET_KEY).ToString(), Is.EqualTo(mvm.PresetViewModelCollection[1].Name)); var ds = key.GetValue(MainViewModel.DEFAULT_SOUND_KEY).ToString(); key.Close(); Registry.CurrentUser.DeleteSubKey(MainViewModel.REG_PATH); }); }
public void SaveUserSettingsCommand_SettingsIsSaved_OverridesSettings() { var mvm = GetMainViewModel(PresetFactory.GetPresetCollection()); mvm.SelectedPreset = mvm.PresetViewModelCollection[1]; var sound = new Uri(AppDomain.CurrentDomain.BaseDirectory + "\\Sounds\\Alarm 2.mp3"); mvm.Alarm.SetDefaultSound(sound); TestWithRegistryKeys(() => { mvm.SaveUserSettingsCommand.Execute(null); var key = Registry.CurrentUser.OpenSubKey(MainViewModel.REG_PATH); Assert.IsNotNull(key); Assert.That(key.GetValue(MainViewModel.SELECTED_PRESET_KEY).ToString(), Is.EqualTo(mvm.PresetViewModelCollection[1].Name)); Assert.That(key.GetValue(MainViewModel.DEFAULT_SOUND_KEY).ToString(), Is.EqualTo(sound.ToString())); key.Close(); }); }