本文整理汇总了C#中AllReady.Controllers.TaskApiController.Put方法的典型用法代码示例。如果您正苦于以下问题:C# TaskApiController.Put方法的具体用法?C# TaskApiController.Put怎么用?C# TaskApiController.Put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AllReady.Controllers.TaskApiController
的用法示例。
在下文中一共展示了TaskApiController.Put方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PutReturnsHttpStatusCodeResultOf204
public async Task PutReturnsHttpStatusCodeResultOf204()
{
var allReadyTask = new AllReadyTask();
var model = new TaskViewModel { Name = "name", Description = "description", StartDateTime = DateTime.UtcNow, EndDateTime = DateTime.UtcNow };
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);
var result = await sut.Put(It.IsAny<int>(), model) as HttpStatusCodeResult;
Assert.IsType<HttpStatusCodeResult>(result);
Assert.Equal(result.StatusCode, 204);
}
示例2: PutSendsUpdateTaskCommandAsyncWithCorrectAllReadyTask
public async Task PutSendsUpdateTaskCommandAsyncWithCorrectAllReadyTask()
{
var allReadyTask = new AllReadyTask();
var model = new TaskViewModel { Name = "name", Description = "description", StartDateTime = DateTime.UtcNow, EndDateTime = DateTime.UtcNow };
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.Put(It.IsAny<int>(), model);
mediator.Verify(x => x.SendAsync(It.Is<UpdateTaskCommandAsync>(y => y.AllReadyTask == allReadyTask)), Times.Once);
}
示例3: PutReturnsBadRequestResultWhenCannotFindTaskByTaskId
public async Task PutReturnsBadRequestResultWhenCannotFindTaskByTaskId()
{
var sut = new TaskApiController(Mock.Of<IMediator>(), null);
var result = await sut.Put(It.IsAny<int>(), It.IsAny<TaskViewModel>());
Assert.IsType<BadRequestResult>(result);
}
示例4: PutReturnsHttpUnauthorizedResultWhenAUserDoesNotHavePermissionToEditTheTaskOrTheTaskIsNotEditable
public async Task PutReturnsHttpUnauthorizedResultWhenAUserDoesNotHavePermissionToEditTheTaskOrTheTaskIsNotEditable()
{
const int taskId = 1;
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.Put(taskId, It.IsAny<TaskViewModel>());
Assert.IsType<HttpUnauthorizedResult>(result);
}
示例5: PutSendsTaskByTaskIdQueryWithCorrectTaskId
public async Task PutSendsTaskByTaskIdQueryWithCorrectTaskId()
{
const int taskId = 1;
var mediator = new Mock<IMediator>();
var sut = new TaskApiController(mediator.Object, null);
await sut.Put(taskId, It.IsAny<TaskViewModel>());
mediator.Verify(x => x.Send(It.Is<TaskByTaskIdQuery>(y => y.TaskId == taskId)));
}