public void ClientSettingsManager_Write_WritesTheClientSettingsToDisk()
        {
            // Arrange
            const string testFile = "..\\..\\TestFiles\\new.ext";

            var client = new FahClient();

            client.Settings = new ClientSettings {
                Name = "test"
            };
            // TODO: Implement ArtifactFolder
            var manager = new ClientSettingsManager();

            // Act
            try
            {
                manager.Write(new[] { client.Settings }, testFile, 1);
                // Assert
                Assert.AreEqual("..\\..\\TestFiles\\new.ext", manager.FileName);
                Assert.AreEqual(1, manager.FilterIndex);
                Assert.AreEqual(".ext", manager.FileExtension);
            }
            finally
            {
                try
                {
                    File.Delete(testFile);
                }
                catch (Exception)
                {
                    // do nothing
                }
            }
        }
        public void ClientSettingsManager_VerifyDefaultState()
        {
            // Act
            var manager = new ClientSettingsManager();

            // Assert
            Assert.AreEqual(String.Empty, manager.FileName);
            Assert.AreEqual(1, manager.FilterIndex);
            Assert.AreEqual("hfmx", manager.FileExtension);
            Assert.AreEqual("HFM Configuration Files|*.hfmx", manager.FileTypeFilters);
        }
Beispiel #3
0
        public MainPresenter(MainGridModel mainGridModel, IMainView view, IMessagesView messagesView, IViewFactory viewFactory,
                             IMessageBoxView messageBoxView, UserStatsDataModel userStatsDataModel, IPresenterFactory presenterFactory,
                             IClientConfiguration clientConfiguration, IProteinService proteinService, IUpdateLogic updateLogic,
                             Core.ScheduledTasks.RetrievalModel retrievalModel, IExternalProcessStarter processStarter,
                             IPreferenceSet prefs, ClientSettingsManager settingsManager)
        {
            _gridModel = mainGridModel;
            _gridModel.AfterResetBindings += (sender, e) =>
            {
                // run asynchronously so binding operation can finish
                _view.BeginInvoke(new Action(() =>
                {
                    DisplaySelectedSlotData();
                    _view.RefreshControlsWithTotalsData(_gridModel.SlotTotals);
                }), null);
            };
            _gridModel.SelectedSlotChanged += (sender, e) =>
            {
                if (e.Index >= 0 && e.Index < _view.DataGridView.Rows.Count)
                {
                    // run asynchronously so binding operation can finish
                    _view.BeginInvoke(new Action(() =>
                    {
                        _view.DataGridView.Rows[e.Index].Selected = true;
                        DisplaySelectedSlotData();
                    }), null);
                }
            };
            _userStatsDataModel = userStatsDataModel;

            // Views
            _view           = view;
            _messagesView   = messagesView;
            _messageBoxView = messageBoxView;
            //
            _viewFactory      = viewFactory;
            _presenterFactory = presenterFactory;
            // Collections
            _clientConfiguration = clientConfiguration;
            _proteinService      = proteinService;
            // Logic Services
            _updateLogic       = updateLogic;
            _updateLogic.Owner = _view;
            _retrievalModel    = retrievalModel;
            _processStarter    = processStarter;
            // Data Services
            _prefs           = prefs;
            _settingsManager = settingsManager;

            _clientConfiguration.ConfigurationChanged += delegate { AutoSaveConfig(); };
        }
        public void ClientSettingsManager_Read_ReturnsClientSettingsCollectionAndSetsManagerState()
        {
            // Arrange
            var manager = new ClientSettingsManager();
            // Act
            var settings = manager.Read("..\\..\\TestFiles\\TestClientSettings.hfmx", 1);

            // Assert
            Assert.IsNotNull(settings);
            Assert.AreEqual(1, settings.Count());
            Assert.AreEqual("..\\..\\TestFiles\\TestClientSettings.hfmx", manager.FileName);
            Assert.AreEqual(1, manager.FilterIndex);
            Assert.AreEqual(".hfmx", manager.FileExtension);
        }
        public void ClientSettingsManager_Write_WritesTheClientSettingsToDisk()
        {
            // Arrange
            var client = new NullClient();

            client.Settings = new ClientSettings {
                Name = "test"
            };
            using (var artifacts = new ArtifactFolder())
            {
                var    manager = new ClientSettingsManager(null);
                string path    = Path.ChangeExtension(artifacts.GetRandomFilePath(), ".hfmx");
                // Act
                manager.Write(new[] { client.Settings }, path, 1);
                // Assert
                Assert.AreEqual(path, manager.FileName);
                Assert.AreEqual(1, manager.FilterIndex);
                Assert.AreEqual(".hfmx", manager.FileExtension);
            }
        }