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


C# TaskController.DeleteConfirmed方法代码示例

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

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

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

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

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

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

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

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


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