本文整理汇总了C#中AllReady.Areas.Admin.Controllers.TaskController.DeleteConfirmed方法的典型用法代码示例。如果您正苦于以下问题:C# TaskController.DeleteConfirmed方法的具体用法?C# TaskController.DeleteConfirmed怎么用?C# TaskController.DeleteConfirmed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AllReady.Areas.Admin.Controllers.TaskController
的用法示例。
在下文中一共展示了TaskController.DeleteConfirmed方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteConfirmedRedirectsToCorrectAction
public async Task DeleteConfirmedRedirectsToCorrectAction()
{
const int organizationId = 1;
const int taskId = 1;
var taskSummaryModel = new TaskSummaryModel { OrganizationId = organizationId, EventId = 1 };
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<TaskQueryAsync>())).ReturnsAsync(taskSummaryModel);
var sut = new TaskController(mediator.Object, Mock.Of<ITaskSummaryModelValidator>());
MakeUserOrganizationAdminUser(sut, organizationId.ToString());
var result = await sut.DeleteConfirmed(taskId) as RedirectToActionResult;
var routeValues = new Dictionary<string, object> { ["id"] = taskSummaryModel.EventId };
Assert.Equal(result.ActionName, nameof(EventController.Details));
Assert.Equal(result.ControllerName, "Event");
Assert.Equal(result.RouteValues, routeValues);
}
示例2: DeleteConfirmedReturnsHttpUnauthorizedResultWhenUserIsNotOrgAdmin
public async Task DeleteConfirmedReturnsHttpUnauthorizedResultWhenUserIsNotOrgAdmin()
{
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<TaskQueryAsync>())).ReturnsAsync(new TaskSummaryModel());
var sut = new TaskController(mediator.Object, Mock.Of<ITaskSummaryModelValidator>());
sut.SetDefaultHttpContext();
var result = await sut.DeleteConfirmed(It.IsAny<int>());
Assert.IsType<HttpUnauthorizedResult>(result);
}
示例3: DeleteConfirmedSendsDeleteTaskCommandAsyncWithCorrectTaskId
public async Task DeleteConfirmedSendsDeleteTaskCommandAsyncWithCorrectTaskId()
{
const int organizationId = 1;
const int taskId = 1;
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<TaskQueryAsync>())).ReturnsAsync(new TaskSummaryModel { OrganizationId = 1 });
var sut = new TaskController(mediator.Object, Mock.Of<ITaskSummaryModelValidator>());
MakeUserOrganizationAdminUser(sut, organizationId.ToString());
await sut.DeleteConfirmed(taskId);
mediator.Verify(x => x.SendAsync(It.Is<DeleteTaskCommandAsync>(y => y.TaskId == taskId)), Times.Once);
}
示例4: DeleteConfirmedReturnsHttpNotFoundResultWhenTaskSummaryModelIsNull
public async Task DeleteConfirmedReturnsHttpNotFoundResultWhenTaskSummaryModelIsNull()
{
var sut = new TaskController(Mock.Of<IMediator>(), Mock.Of<ITaskSummaryModelValidator>());
var result = await sut.DeleteConfirmed(It.IsAny<int>());
Assert.IsType<HttpNotFoundResult>(result);
}
示例5: DeleteConfirmedSendsTaskQueryAsyncWithCorrectTaskId
public async Task DeleteConfirmedSendsTaskQueryAsyncWithCorrectTaskId()
{
const int taskId = 1;
var mediator = new Mock<IMediator>();
var sut = new TaskController(mediator.Object, Mock.Of<ITaskSummaryModelValidator>());
await sut.DeleteConfirmed(taskId);
mediator.Verify(x => x.SendAsync(It.Is<TaskQueryAsync>(y => y.TaskId == taskId)), Times.Once);
}
示例6: DeleteConfirmedRedirectsToCorrectAction
public async Task DeleteConfirmedRedirectsToCorrectAction()
{
const int organizationId = 1;
var deleteViewModel = new DeleteViewModel { OrganizationId = organizationId, EventId = 1, UserIsOrgAdmin = true };
var mediator = new Mock<IMediator>();
var sut = new TaskController(mediator.Object, null);
sut.MakeUserAnOrgAdmin(organizationId.ToString());
var result = await sut.DeleteConfirmed(deleteViewModel) as RedirectToActionResult;
var routeValues = new Dictionary<string, object> { ["id"] = deleteViewModel.EventId };
Assert.Equal(result.ActionName, nameof(EventController.Details));
Assert.Equal(result.ControllerName, "Event");
Assert.Equal(result.RouteValues, routeValues);
}
示例7: DeleteConfirmedSendsDeleteTaskCommandAsyncWithCorrectTaskId
public async Task DeleteConfirmedSendsDeleteTaskCommandAsyncWithCorrectTaskId()
{
const int taskId = 1;
var mediator = new Mock<IMediator>();
var sut = new TaskController(mediator.Object, null);
await sut.DeleteConfirmed(new DeleteViewModel { Id = taskId, UserIsOrgAdmin = true });
mediator.Verify(x => x.SendAsync(It.Is<DeleteTaskCommandAsync>(y => y.TaskId == taskId)), Times.Once);
}
示例8: DeleteConfirmedReturnsUnauthorizedResultWhenUserIsNotOrgAdmin
public async Task DeleteConfirmedReturnsUnauthorizedResultWhenUserIsNotOrgAdmin()
{
var model = new DeleteViewModel { UserIsOrgAdmin = false };
var sut = new TaskController(null, null);
sut.SetDefaultHttpContext();
var result = await sut.DeleteConfirmed(model);
Assert.IsType<UnauthorizedResult>(result);
}