private void LstAvailableKeyModifiersOnDoubleClick(object sender, EventArgs e) { var selected = ((ListBox)sender).SelectedItem; if (selected != null) { _viewModel.AddModifier((KeyModifiers)selected); } }
public void AddModifier_RemovesNomod_AndCorrectlyNotifies() { //arrange _settingsServiceMock.Setup(x => x.GetAllModifiers()) .Returns(new List <KeyModifiers> { KeyModifiers.Alt }); _settingsServiceMock.Setup(x => x.GetSavedModifiers()) .Returns(new List <KeyModifiers>()); _settingsServiceMock.Setup(x => x.GetDefaultKey()) .Returns('A'); _viewModel = new ConfigViewModel(_settingsServiceMock.Object); _viewModel.PropertyChanged += ViewModelPropertyChanged; //act _viewModel.AddModifier(KeyModifiers.Alt); //assert _viewModel.AvailableModifiers.Should().Not.Contain(KeyModifiers.Alt); _viewModel.CurrentModifiers.Should().Contain(KeyModifiers.Alt).And.Have.Count.EqualTo(1); _changedProperties.Should().Contain("CanSave").And.Have.Count.EqualTo(1); }