public void TestExecuteWithNonWindowParameter() { CloseWindowCommand changeFocusCommand = new CloseWindowCommand(); var exception = Assert.ThrowsException <ArgumentException>(() => changeFocusCommand.Execute(null)); Assert.AreEqual("parameter is not Window", exception.Message); }
/// <summary> /// Вызывает окно редактирования данных пользователя /// </summary> /// <param name="parameter"></param> private void ShowReaderUserWindow(object parameter) { CloseWindowCommand.Execute(null); var updateWindow = new RegistrationWindow(UserList, User); var viewUpdater = new UpdateViewUpdater(updateWindow); viewUpdater.Update(); updateWindow.ShowDialog(); }
public void TestExecuteSuccess() { CloseWindowCommand changeFocusCommand = new CloseWindowCommand(); Window window = new Window(); bool windowClosed = false; window.Closed += (sender, e) => { windowClosed = true; }; changeFocusCommand.Execute(window); Assert.IsTrue(windowClosed); }
public new void Close() { if (CloseWindowCommand != null) { CloseWindowCommand?.Execute(this); } else { base.Close(); } }
/// <summary> /// Удаляет выбранного пользователя /// </summary> private void ShowAsseccQuestionWindow(object parameter) { if (MessageBox.Show(@"Вы действительно хотите удалить данных данного пользователя ?", @"Подтверждение", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } CloseWindowCommand.Execute(null); using (var dataBase = new UserService()) { dataBase.DeleteUser(User.Id); } var removedElement = UserList.FirstOrDefault(x => x.Id == User.Id); UserList.Remove(removedElement); }