public void DeleteTask_Action_Fails() { // Arrange var taskDto = TestHelper.TaskDto(); GenericServiceResponse <bool> fakeResponse = null; mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable(); mockClientServicesProvider.Setup(x => x.TaskService.DeleteTask(taskDto)).Returns(fakeResponse).Verifiable(); var viewModel = new GenericViewModel(); var action = new DeleteTask <GenericViewModel>(mockClientServicesProvider.Object) { OnComplete = model => viewModel = model }; // Act var result = action.Invoke(taskDto); // Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(GenericViewModel)); Assert.IsNotNull(result.Notifications); Assert.IsInstanceOfType(result.Notifications, typeof(NotificationCollection)); Assert.IsTrue(result.Notifications.Count() == 1); Assert.IsTrue(result.HasErrors); Assert.IsNotNull(result.Success); Assert.IsInstanceOfType(result.Success, typeof(bool)); Assert.IsFalse(result.Success); }
/// <summary> /// hack:删除任务(只在调试中使用) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_Delete_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("是否要进行任务删除处理?", "注意", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { if (Self != null) { var temp = DeleteTask?.Invoke(Self); if (temp == null) { MessageBox.Show("未处理任务删除事件"); } if (temp.Success) { MessageBox.Show("任务删除处理成功"); } else { MessageBox.Show($"任务删除失败:{temp.Msg}"); } } } }
private void MenuItemDeleteTask_OnClick(object sender, RoutedEventArgs e) { CommonMethods.WorkWithTables.Delete(thisTask, httpClientProvider.GetDatabaseTaskEditor(), task => task.TaskId, () => DeleteTask?.Invoke(this, default(EventArgs))); }