public void TestOptionSaving() { using (var workspace = TestWorkspace.CreateCSharp("")) { var serviceProvider = new MockServiceProvider(workspace.ExportProvider); using (var viewModel = new SpacingViewModel(workspace.Options, serviceProvider)) { // Use the first item's preview. var checkbox = viewModel.Items.OfType <CheckBoxOptionViewModel>().Where(c => c.Option == CSharpFormattingOptions.SpacingAfterMethodDeclarationName).First(); var initial = checkbox.IsChecked; checkbox.IsChecked = !checkbox.IsChecked; var changedOptions = viewModel.ApplyChangedOptions(workspace.Options); Assert.NotEqual(changedOptions.GetOption(CSharpFormattingOptions.SpacingAfterMethodDeclarationName), initial); } } }
public async Task TestOptionSaving() { using (var workspace = await CSharpWorkspaceFactory.CreateWorkspaceFromFileAsync("")) { var serviceProvider = new MockServiceProvider(workspace.ExportProvider); using (var viewModel = new SpacingViewModel(workspace.Options, serviceProvider)) { // Use the first item's preview. var checkbox = viewModel.Items.OfType <CheckBoxOptionViewModel>().Where(c => c.Option == CSharpFormattingOptions.SpacingAfterMethodDeclarationName).First(); var initial = checkbox.IsChecked; checkbox.IsChecked = !checkbox.IsChecked; var optionService = workspace.GetService <IOptionService>(); var optionSet = optionService.GetOptions(); var changedOptions = viewModel.ApplyChangedOptions(optionSet); Assert.NotEqual(changedOptions.GetOption(CSharpFormattingOptions.SpacingAfterMethodDeclarationName), initial); } } }