public async Task NewItemClicked_CompletedDialog_PresetAddedToList() { //Arrange var preset = _fixture.Create <PresetViewModel>(); _presetController.CreateAsync(Arg.Any <string>(), Arg.Any <string>()).Returns(Task.FromResult(preset)); DialogMocker.InitializeOkCancelDialog(preset, DialogResults.Ok); _presetControlViewModel.Presets.Count.ShouldBe(0); //Act await _presetControlViewModel.NewItemClickedAsync(new ButtonClickArgs("Create", "Preset")); var newPreset = _presetControlViewModel.Presets.First(); //Assert newPreset.ShouldBe(preset); }
public async Task NewItemClickedAsync(ButtonClickArgs args) { var e = (ButtonClickArgs)args; var title = $"{e.Action} {e.ItemDescriptor}"; var message = $"{e.Action} {e.ItemDescriptor}: "; var selectedItem = SelectedPreset; var results = CrudDialogProvider.Show(new NestedViewModel <PresetViewModel>(title, message, selectedItem, DialogButtons.OkCancel)); if (results.DialogResult != DialogResults.Ok) { return; } var newPreset = await _presetController.CreateAsync(results.InnerResults.Name, results.InnerResults.ProcessName); Presets.Add(newPreset); SelectedPreset = newPreset; }