public void Initialize_LoadSavedSettings_ViewModelIsInitializedWithLoadedSettings() { Step2Settings savedSettings = new Step2Settings { PathTo = "TestPathTo", OnCopyActionID = 1, SaveSettings = true }; _settingsServiceMock.Setup(x => x.LoadSettings <Step2Settings>("Step2Settings")).Returns(savedSettings); _step2ViewModelMock.SetupGet(x => x.OnCopyOptions).Returns(new ReadOnlyCollection <ComboBoxOption>(new List <ComboBoxOption>() { new ComboBoxOption { ID = 2 }, new ComboBoxOption { ID = 1 }, new ComboBoxOption { ID = 100 } })); Assert.AreEqual(savedSettings.PathTo, _step2ViewModelMock.Object.PathTo); Assert.AreEqual(_step2ViewModelMock.Object.OnCopyOptions[1], _step2ViewModelMock.Object.SelectedOnCopyOption); Assert.AreEqual(savedSettings.SaveSettings, _step2ViewModelMock.Object.SaveSettings); }
public virtual void Initialize() { Step2Settings settings = _settingsService.LoadSettings <Step2Settings>("Step2Settings"); if (settings != null && settings.SaveSettings) { _pathTo = settings.PathTo; _selectedOnCopyOption = OnCopyOptions.SingleOrDefault(x => x.ID == settings.OnCopyActionID); _saveSettings = settings.SaveSettings; } else { _selectedOnCopyOption = OnCopyOptions.First(); } }
public virtual void UpdateSettings() { if (SaveSettings) { Step2Settings settings = new Step2Settings { PathTo = PathTo, OnCopyActionID = SelectedOnCopyOption.ID, SaveSettings = SaveSettings }; _settingsService.SaveSettings("Step2Settings", settings); } else { _settingsService.RemoveSettings("Step2Settings"); } }