public void UpdateConfig_UsesLoadedSettingsInstance() { var initialSettings = new IgnoredProjectsSettings(); var provider = ConfigProviderMock(initialSettings); var viewModel = GetSettingsViewModel(provider.Object); viewModel.UpdateConfig(null); provider.Verify(m => m.Save(initialSettings), Times.Once); }
public void AddIgnoredFile_DoesNotChangeSettings() { var initialSettings = new IgnoredProjectsSettings(); var viewModel = GetSettingsViewModel(initialSettings, "someFilename"); viewModel.AddIgnoredFileCommand.Execute(null); Assert.IsFalse(initialSettings.IgnoredProjectPaths.Any()); }
private static IConfigurationService <IgnoredProjectsSettings> MockIgnoredProjectsSettingsProviderMock() { var mock = new Mock <IConfigurationService <IgnoredProjectsSettings> >(); var defaultSettings = new IgnoredProjectsSettings(); var currentSettings = new IgnoredProjectsSettings(); mock.Setup(m => m.Read()).Returns(currentSettings); mock.Setup(m => m.ReadDefaults()).Returns(defaultSettings); return(mock.Object); }
private static Mock <IConfigurationService <IgnoredProjectsSettings> > ConfigProviderMock(IgnoredProjectsSettings initialSettings = null) { var mock = new Mock <IConfigurationService <IgnoredProjectsSettings> >(); var defaultSettings = new IgnoredProjectsSettings(); var currentSettings = initialSettings ?? new IgnoredProjectsSettings(); mock.Setup(m => m.ReadDefaults()).Returns(defaultSettings); mock.Setup(m => m.Read()).Returns(currentSettings); return(mock); }
public void AddIgnoredFile_DoesNotAddIfNotOK() { var initialSettings = new IgnoredProjectsSettings(); var mockFileDialog = FileDialogMock("someFilename", dialogOk: false); var mockFileSystemBrowser = FileSystemBrowserMock(mockFileDialog.Object, "asdawedefde"); var viewModel = GetSettingsViewModel(mockFileSystemBrowser.Object, initialSettings); viewModel.AddIgnoredFileCommand.Execute(null); Assert.IsFalse(viewModel.IgnoredProjectPaths.Any()); }
public void AddIgnoredFile_AddsFileReturnedFromFileBrowser() { var initialSettings = new IgnoredProjectsSettings(); var viewModel = GetSettingsViewModel(initialSettings, "someFilename"); viewModel.AddIgnoredFileCommand.Execute(null); var expectedFolders = new List <string> { "someFilename" }; Assert.IsTrue(expectedFolders.SequenceEqual(viewModel.IgnoredProjectPaths)); }
public void UpdateConfig_TransfersIgnoredPathsToSettings() { var initialSettings = new IgnoredProjectsSettings(); var viewModel = GetSettingsViewModel(initialSettings, "someFilename"); viewModel.AddIgnoredFileCommand.Execute(null); viewModel.UpdateConfig(null); var expectedFolders = new List <string> { "someFilename" }; Assert.IsTrue(expectedFolders.SequenceEqual(initialSettings.IgnoredProjectPaths)); }
public void ViewModel_InitiallyHasIgnoredPathsFromCurrentSettingsFromProvider() { var initialFolders = new List <string> { "asdasdasd", "eftgsrghdg", "faffvseafuoeagfwvef" }; var initialSettings = new IgnoredProjectsSettings { IgnoredProjectPaths = initialFolders }; var viewModel = GetSettingsViewModel(initialSettings); var expectedPaths = initialFolders; Assert.IsTrue(expectedPaths.SequenceEqual(viewModel.IgnoredProjectPaths)); }
public void SetToDefaults_ClearsIgnoredPaths() { var initialFolders = new List <string> { "asdasdasd", "eftgsrghdg", "faffvseafuoeagfwvef" }; var initialSettings = new IgnoredProjectsSettings { IgnoredProjectPaths = initialFolders }; var viewModel = GetSettingsViewModel(initialSettings); viewModel.SetToDefaults(null); Assert.IsFalse(viewModel.IgnoredProjectPaths.Any()); }
public void RemoveFilename_DoesNothingForNonExistingFilename() { var initialFolders = new List <string> { "asdasdasd", "eftgsrghdg", "faffvseafuoeagfwvef" }; var initialSettings = new IgnoredProjectsSettings { IgnoredProjectPaths = initialFolders }; var viewModel = GetSettingsViewModel(initialSettings); viewModel.RemoveSelectedProjects.Execute("ssss"); var expectedPaths = initialFolders; Assert.IsTrue(expectedPaths.SequenceEqual(viewModel.IgnoredProjectPaths)); }
public void RemoveFilename_RemovesExistingFilename() { var initialFolders = new List <string> { "asdasdasd", "eftgsrghdg", "faffvseafuoeagfwvef" }; var initialSettings = new IgnoredProjectsSettings { IgnoredProjectPaths = initialFolders }; var viewModel = GetSettingsViewModel(initialSettings); viewModel.RemoveSelectedProjects.Execute("eftgsrghdg"); var expectedPaths = initialFolders.Where(name => !"eftgsrghdg".Equals(name)).ToList(); Assert.IsTrue(expectedPaths.SequenceEqual(viewModel.IgnoredProjectPaths)); }
public void AddIgnoredFile_DoesNotAddIfAlreadyThere() { var initialFolders = new List <string> { "asdasdasd", "eftgsrghdg", "faffvseafuoeagfwvef" }; var initialSettings = new IgnoredProjectsSettings { IgnoredProjectPaths = initialFolders }; var viewModel = GetSettingsViewModel(initialSettings, "asdasdasd"); viewModel.AddIgnoredFileCommand.Execute(null); var expectedPaths = initialFolders; Assert.IsTrue(expectedPaths.SequenceEqual(viewModel.IgnoredProjectPaths)); }
private static IgnoredProjectsSettingsViewModel GetSettingsViewModel(IFileSystemBrowserFactory fileSystem, IgnoredProjectsSettings initialSettings = null) { var providerMock = ConfigProviderMock(initialSettings); return(GetSettingsViewModel(providerMock.Object, fileSystem)); }
private static IgnoredProjectsSettingsViewModel GetSettingsViewModel(IgnoredProjectsSettings initialSettings = null, string newIgnoredFilename = null) { var providerMock = ConfigProviderMock(initialSettings); return(GetSettingsViewModel(providerMock.Object, newIgnoredFilename)); }