///////////////////////////////////////////////////////// #region Constructors /// <summary> /// Initializes a new instance of the <see cref="SolutionPagePresenter"/> class. /// </summary> /// <param name="view">The view.</param> /// <param name="viewModel">The view model.</param> /// <param name="model">The model.</param> /// <param name="viewStateProvider">A common <see cref="IViewStateProvider"/>.</param> /// <param name="fileSystem">The file sytem access.</param> /// <param name="systemInterface">The interface for system operations.</param> /// <param name="userIOInterface">The user IO interface.</param> /// <param name="ide">Information about the current Visual Studio instance.</param> /// <exception cref="ArgumentNullException">Any parameter is null.</exception> public SolutionPagePresenter([NotNull] ISolutionPageView view, [NotNull] ISolutionPageViewModel viewModel, [NotNull] ISolutionPageModel model, [NotNull] IViewStateProvider viewStateProvider, [NotNull] IFileSystem fileSystem, [NotNull] ISystemInterface systemInterface, [NotNull] IUserIOInterface userIOInterface, [NotNull] IIde ide) : base(view, viewModel) { ThrowIfNull(model, nameof(model)); ThrowIfNull(viewStateProvider, nameof(viewStateProvider)); ThrowIfNull(fileSystem, nameof(fileSystem)); ThrowIfNull(systemInterface, nameof(systemInterface)); ThrowIfNull(userIOInterface, nameof(userIOInterface)); ThrowIfNull(ide, nameof(ide)); _model = model; _viewStateProvider = viewStateProvider; _fileSystem = fileSystem; _systemInterface = systemInterface; _userIOInterface = userIOInterface; _ide = ide; _configuration = _model.LoadConfiguration(); }
async Task ISolutionPageModel.SaveConfiguration(SolutionPageConfiguration configuration) { ThrowIfNull(configuration, nameof(configuration)); await Task.Run(async() => { var serializer = new XmlSerializer(typeof(SolutionPageConfiguration)); for (var i = 0; i <= _MAXIMUM_RETRIES; i++) { try { using (var writer = new StreamWriter(_settingsFilePath)) { serializer.Serialize(writer, configuration); return; } } catch (Exception) { if (i >= _MAXIMUM_RETRIES) { return; } } await Task.Delay(200); } }).ConfigureAwait(false); }
public void ApplyViewModel_NullReferenceException() { // Arrange var config = new SolutionPageConfiguration(); // Act config.ApplyViewModel(null); }
public void Columns_Maxvalue() { // Arrange var config = new SolutionPageConfiguration(); // Act config.Columns = 4; var result = config.Columns; // Assert Assert.AreEqual(3, result); }
public void Columns_GetSet() { // Arrange var config = new SolutionPageConfiguration(); // Act config.Columns = 2; var result = config.Columns; // Assert Assert.AreEqual(2, result); }
///////////////////////////////////////////////////////// #region Base Overrides protected override async Task View_Loaded(object sender, RoutedEventArgs e) { _configuration = await _model.LoadConfiguration().ConfigureAwait(true); ComputeConfigurationProperties(); PrepareLoadedData(); ConnectEventHandler(); View.ConnectDataSource(ViewModel); FillDefault(); }
public void ApplyViewModel_Success() { // Arrange var config = new SolutionPageConfiguration(); var vm = Mock.Create <ISolutionPageViewModel>(); var group = new SolutionGroup(); Mock.Arrange(() => vm.Columns).Returns(2); Mock.Arrange(() => vm.SolutionGroups).Returns(new ObservableCollection <SolutionGroup> { group }); // Act var result = config.ApplyViewModel(vm); // Assert Assert.IsNotNull(result); Assert.AreEqual(2, result.Columns); Assert.AreEqual(group, result.SolutionGroups.Single()); }
public async Task SaveConfiguration(SolutionPageConfiguration groups) { for (var i = 0; i <= _MAXIMUM_RETRIES; i++) { try { using (var writer = new StreamWriter(_settingsFilePath)) { _serializer.Serialize(writer, groups); return; } } catch (Exception) { if (i >= _MAXIMUM_RETRIES) { return; } } await Task.Delay(200); } }
public SolutionPageViewModel(SolutionPageConfiguration config) : this() { Columns = config.Columns; SolutionGroups = new ObservableCollection <SolutionGroup>(config.SolutionGroups); }