本文整理汇总了C#中AllReady.Controllers.TaskApiController.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# TaskApiController.Delete方法的具体用法?C# TaskApiController.Delete怎么用?C# TaskApiController.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AllReady.Controllers.TaskApiController
的用法示例。
在下文中一共展示了TaskApiController.Delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteSendsDeleteTaskCommandAsyncWithCorrectTaskId
public async Task DeleteSendsDeleteTaskCommandAsyncWithCorrectTaskId()
{
var allReadyTask = new AllReadyTask { Id = 1 };
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.Send(It.IsAny<TaskByTaskIdQuery>())).Returns(allReadyTask);
var determineIfATaskIsEditable = new Mock<IDetermineIfATaskIsEditable>();
determineIfATaskIsEditable.Setup(x => x.For(It.IsAny<ClaimsPrincipal>(), It.IsAny<AllReadyTask>())).Returns(true);
var sut = new TaskApiController(mediator.Object, determineIfATaskIsEditable.Object);
await sut.Delete(It.IsAny<int>());
mediator.Verify(x => x.SendAsync(It.Is<DeleteTaskCommandAsync>(y => y.TaskId == allReadyTask.Id)));
}
示例2: DeleteReturnsBadRequestResultWhenCannotFindTaskByTaskId
public async Task DeleteReturnsBadRequestResultWhenCannotFindTaskByTaskId()
{
var sut = new TaskApiController(Mock.Of<IMediator>(), null);
var result = await sut.Delete(It.IsAny<int>());
Assert.IsType<BadRequestResult>(result);
}
示例3: DeleteReturnsHttpUnauthorizedResultWhenAUserDoesNotHavePermissionToEditTheTaskOrTheTaskIsNotEditable
public async Task DeleteReturnsHttpUnauthorizedResultWhenAUserDoesNotHavePermissionToEditTheTaskOrTheTaskIsNotEditable()
{
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.Send(It.IsAny<TaskByTaskIdQuery>())).Returns(new AllReadyTask());
var determineIfATaskIsEditable = new Mock<IDetermineIfATaskIsEditable>();
determineIfATaskIsEditable.Setup(x => x.For(It.IsAny<ClaimsPrincipal>(), It.IsAny<AllReadyTask>())).Returns(false);
var sut = new TaskApiController(mediator.Object, determineIfATaskIsEditable.Object);
var result = await sut.Delete(It.IsAny<int>());
Assert.IsType<HttpUnauthorizedResult>(result);
}
示例4: DeleteSendsTaskByTaskIdQueryWithCorrectTaskId
public async Task DeleteSendsTaskByTaskIdQueryWithCorrectTaskId()
{
const int taskId = 1;
var mediator = new Mock<IMediator>();
var sut = new TaskApiController(mediator.Object, null);
await sut.Delete(taskId);
mediator.Verify(x => x.Send(It.Is<TaskByTaskIdQuery>(y => y.TaskId == taskId)));
}