コード例 #1
0
        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);
        }
コード例 #2
0
        public void AddIgnoredFile_DoesNotChangeSettings()
        {
            var initialSettings = new IgnoredProjectsSettings();
            var viewModel       = GetSettingsViewModel(initialSettings, "someFilename");

            viewModel.AddIgnoredFileCommand.Execute(null);

            Assert.IsFalse(initialSettings.IgnoredProjectPaths.Any());
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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());
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        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());
        }
コード例 #10
0
        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));
        }
コード例 #11
0
        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));
        }
コード例 #12
0
        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));
        }
コード例 #13
0
        private static IgnoredProjectsSettingsViewModel GetSettingsViewModel(IFileSystemBrowserFactory fileSystem, IgnoredProjectsSettings initialSettings = null)
        {
            var providerMock = ConfigProviderMock(initialSettings);

            return(GetSettingsViewModel(providerMock.Object, fileSystem));
        }
コード例 #14
0
        private static IgnoredProjectsSettingsViewModel GetSettingsViewModel(IgnoredProjectsSettings initialSettings = null, string newIgnoredFilename = null)
        {
            var providerMock = ConfigProviderMock(initialSettings);

            return(GetSettingsViewModel(providerMock.Object, newIgnoredFilename));
        }