当前位置: 首页>>代码示例>>C#>>正文


C# TaskApiController.Put方法代码示例

本文整理汇总了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);
        }
开发者ID:codethug,项目名称:allReady,代码行数:17,代码来源:TaskApiControllerTests.cs

示例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);
        }
开发者ID:codethug,项目名称:allReady,代码行数:16,代码来源:TaskApiControllerTests.cs

示例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);
        }
开发者ID:codethug,项目名称:allReady,代码行数:7,代码来源:TaskApiControllerTests.cs

示例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);
        }
开发者ID:codethug,项目名称:allReady,代码行数:15,代码来源:TaskApiControllerTests.cs

示例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)));
        }
开发者ID:codethug,项目名称:allReady,代码行数:10,代码来源:TaskApiControllerTests.cs


注:本文中的AllReady.Controllers.TaskApiController.Put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。