Example #1
0
        public void TestExecuteWithNonWindowParameter()
        {
            CloseWindowCommand changeFocusCommand = new CloseWindowCommand();
            var exception = Assert.ThrowsException <ArgumentException>(() => changeFocusCommand.Execute(null));

            Assert.AreEqual("parameter is not Window", exception.Message);
        }
Example #2
0
        /// <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();
        }
Example #3
0
        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);
        }
Example #4
0
 public new void Close()
 {
     if (CloseWindowCommand != null)
     {
         CloseWindowCommand?.Execute(this);
     }
     else
     {
         base.Close();
     }
 }
Example #5
0
        /// <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);
        }