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


C# TaskController.MakeUserAnOrgAdmin方法代码示例

本文整理汇总了C#中AllReady.Areas.Admin.Controllers.TaskController.MakeUserAnOrgAdmin方法的典型用法代码示例。如果您正苦于以下问题:C# TaskController.MakeUserAnOrgAdmin方法的具体用法?C# TaskController.MakeUserAnOrgAdmin怎么用?C# TaskController.MakeUserAnOrgAdmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AllReady.Areas.Admin.Controllers.TaskController的用法示例。


在下文中一共展示了TaskController.MakeUserAnOrgAdmin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateGetSendsCreateTaskQueryAsyncWithTheCorrectEventId

        public async Task CreateGetSendsCreateTaskQueryAsyncWithTheCorrectEventId()
        {
            const int eventId = 1;
            const int organizationId = 1;

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<CreateTaskQueryAsync>())).ReturnsAsync(new EditViewModel { OrganizationId = organizationId });

            var urlHelper = new Mock<IUrlHelper>();
            urlHelper.Setup(x => x.Action(It.IsAny<UrlActionContext>())).Returns(It.IsAny<string>());

            var sut = new TaskController(mediator.Object, null) { Url = urlHelper.Object };
            sut.MakeUserAnOrgAdmin(organizationId.ToString());

            await sut.Create(eventId);
            mediator.Verify(x => x.SendAsync(It.Is<CreateTaskQueryAsync>(y => y.EventId == eventId)), Times.Once);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:17,代码来源:TaskControllerTests.cs

示例2: CreateGetInvokesUrlActionWithTheCorrectParameters

        public async Task CreateGetInvokesUrlActionWithTheCorrectParameters()
        {
            var model = new EditViewModel { EventId = 1, OrganizationId = 1 };

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<CreateTaskQueryAsync>())).ReturnsAsync(model);

            var urlHelper = new Mock<IUrlHelper>();
            urlHelper.Setup(x => x.Action(It.IsAny<UrlActionContext>())).Returns(It.IsAny<string>());

            var sut = new TaskController(mediator.Object, null) { Url = urlHelper.Object };
            sut.MakeUserAnOrgAdmin(model.OrganizationId.ToString());

            await sut.Create(It.IsAny<int>());

            urlHelper.Verify(x => x.Action(It.Is<UrlActionContext>(y =>
                y.Action == nameof(EventController.Details) &&
                y.Controller == "Event" &&
                y.Values.ToString() == $"{{ id = {model.EventId}, area = Admin }}")),
            Times.Once);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:21,代码来源:TaskControllerTests.cs

示例3: CreateGetSetCorrectToTitleOnViewBag

        public async Task CreateGetSetCorrectToTitleOnViewBag()
        {
            var model = new EditViewModel { EventId = 1, OrganizationId = 1 };

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<CreateTaskQueryAsync>())).ReturnsAsync(model);

            var urlHelper = new Mock<IUrlHelper>();
            urlHelper.Setup(x => x.Action(It.IsAny<UrlActionContext>())).Returns(It.IsAny<string>());

            var sut = new TaskController(mediator.Object, null) { Url = urlHelper.Object };
            sut.MakeUserAnOrgAdmin(model.OrganizationId.ToString());

            await sut.Create(It.IsAny<int>());

            Assert.Equal(sut.ViewBag.Title, "Create Task");
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:17,代码来源:TaskControllerTests.cs

示例4: CreateGetAssignsCancelUrlToModel

        public async Task CreateGetAssignsCancelUrlToModel()
        {
            const string cancelUrl = "url";
            var model = new EditViewModel { EventId = 1, OrganizationId = 1 };

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<CreateTaskQueryAsync>())).ReturnsAsync(model);

            var urlHelper = new Mock<IUrlHelper>();
            urlHelper.Setup(x => x.Action(It.IsAny<UrlActionContext>())).Returns(cancelUrl);

            var sut = new TaskController(mediator.Object, null) { Url = urlHelper.Object };
            sut.MakeUserAnOrgAdmin(model.OrganizationId.ToString());

            var result = await sut.Create(It.IsAny<int>()) as ViewResult;
            var modelResult = result.Model as EditViewModel;

            Assert.Equal(modelResult.CancelUrl, cancelUrl);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:19,代码来源:TaskControllerTests.cs

示例5: MessageAllVolunteersReturnsHttpOkResult

        public async Task MessageAllVolunteersReturnsHttpOkResult()
        {
            const int organizationId = 1;

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdByTaskIdQueryAsync>())).ReturnsAsync(organizationId);

            var sut = new TaskController(mediator.Object, null);
            sut.MakeUserAnOrgAdmin(organizationId.ToString());
            var result = await sut.MessageAllVolunteers(new MessageTaskVolunteersViewModel());

            Assert.IsType<OkResult>(result);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:13,代码来源:TaskControllerTests.cs

示例6: MessageAllVolunteersSendsMessageTaskVolunteersCommandAsyncWithCorrectData

        public async Task MessageAllVolunteersSendsMessageTaskVolunteersCommandAsyncWithCorrectData()
        {
            const int organizationId = 1;
            var model = new MessageTaskVolunteersViewModel();

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdByTaskIdQueryAsync>())).ReturnsAsync(organizationId);

            var sut = new TaskController(mediator.Object, null);
            sut.MakeUserAnOrgAdmin(organizationId.ToString());
            await sut.MessageAllVolunteers(model);

            mediator.Verify(x => x.SendAsync(It.Is<MessageTaskVolunteersCommandAsync>(y => y.Model == model)), Times.Once);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:14,代码来源:TaskControllerTests.cs

示例7: AssignRedirectsToCorrectRoute

        public async Task AssignRedirectsToCorrectRoute()
        {
            const int organizationId = 1;
            const int taskId = 1;

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdByTaskIdQueryAsync>())).ReturnsAsync(organizationId);

            var sut = new TaskController(mediator.Object, null);
            sut.MakeUserAnOrgAdmin(organizationId.ToString());

            var result = await sut.Assign(taskId, null) as RedirectToRouteResult;

            Assert.Equal(result.RouteValues["controller"], "Task");
            Assert.Equal(result.RouteValues["Area"], "Admin");
            Assert.Equal(result.RouteValues["action"], nameof(TaskController.Details));
            Assert.Equal(result.RouteValues["id"], taskId);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:18,代码来源:TaskControllerTests.cs

示例8: AssignSendsAssignTaskCommandAsync

        public async Task AssignSendsAssignTaskCommandAsync()
        {
            const int organizationId = 1;
            const int taskId = 1;
            var userIds = new List<string> { "1", "2" };

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdByTaskIdQueryAsync>())).ReturnsAsync(organizationId);

            var sut = new TaskController(mediator.Object, null);
            sut.MakeUserAnOrgAdmin(organizationId.ToString());
            await sut.Assign(taskId, userIds);

            mediator.Verify(x => x.SendAsync(It.Is<AssignTaskCommandAsync>(y => y.TaskId == taskId && y.UserIds == userIds)), Times.Once);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:15,代码来源:TaskControllerTests.cs

示例9: 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

示例10: DeleteReturnsCorrectViewModelAndView

        public async Task DeleteReturnsCorrectViewModelAndView()
        {
            const int organizationId = 1;
            var deleteViewModel = new DeleteViewModel { OrganizationId = organizationId };

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<DeleteQueryAsync>())).ReturnsAsync(deleteViewModel);

            var sut = new TaskController(mediator.Object, null);
            sut.MakeUserAnOrgAdmin(organizationId.ToString());

            var result = await sut.Delete(It.IsAny<int>()) as ViewResult;
            var modelResult = result.ViewData.Model as DeleteViewModel;

            Assert.IsType<ViewResult>(result);
            Assert.IsType<DeleteViewModel>(modelResult);
            Assert.Equal(modelResult, deleteViewModel);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:18,代码来源:TaskControllerTests.cs

示例11: DeleteSendsDeleteQueryAsyncWithCorrectTaskId

        public async Task DeleteSendsDeleteQueryAsyncWithCorrectTaskId()
        {
            const int taskId = 1;
            const int organizationId = 1;

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<DeleteQueryAsync>())).ReturnsAsync(new DeleteViewModel { OrganizationId = organizationId });

            var sut = new TaskController(mediator.Object, null);
            sut.MakeUserAnOrgAdmin(organizationId.ToString());
            await sut.Delete(taskId);

            mediator.Verify(x => x.SendAsync(It.Is<DeleteQueryAsync>(y => y.TaskId == taskId)), Times.Once);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:14,代码来源:TaskControllerTests.cs

示例12: EditPostRedirectsToCorrectAction_WhenUpdatingTask

        public async Task EditPostRedirectsToCorrectAction_WhenUpdatingTask()
        {
            const int organizationId = 1;

            var model = new EditViewModel { Id = 1, OrganizationId = organizationId };

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<EditTaskCommandAsync>())).ReturnsAsync(1);

            var validator = new Mock<ITaskEditViewModelValidator>();
            validator.Setup(x => x.Validate(It.IsAny<EditViewModel>())).Returns(new List<KeyValuePair<string, string>>());

            var sut = new TaskController(mediator.Object, validator.Object);
            sut.MakeUserAnOrgAdmin(organizationId.ToString());

            var result = await sut.Edit(model) as RedirectToActionResult;

            var routeValues = new Dictionary<string, object> { ["id"] = model.Id };

            Assert.Equal(result.ControllerName, "Task");
            Assert.Equal(result.ActionName, nameof(TaskController.Details));
            Assert.Equal(result.RouteValues, routeValues);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:23,代码来源:TaskControllerTests.cs

示例13: EditPostSendsEditTaskCommandAsyncWithCorrectModel_WhenModelStateIsValidAndUserIsOrganizationAdmin

        public async Task EditPostSendsEditTaskCommandAsyncWithCorrectModel_WhenModelStateIsValidAndUserIsOrganizationAdmin()
        {
            const int organizationId = 1;

            var model = new EditViewModel { OrganizationId = organizationId };

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<EditTaskCommandAsync>())).ReturnsAsync(1);

            var validator = new Mock<ITaskEditViewModelValidator>();
            validator.Setup(x => x.Validate(It.IsAny<EditViewModel>())).Returns(new List<KeyValuePair<string, string>>());

            var sut = new TaskController(mediator.Object, validator.Object);
            sut.MakeUserAnOrgAdmin(organizationId.ToString());

            await sut.Edit(model);

            mediator.Verify(x => x.SendAsync(It.Is<EditTaskCommandAsync>(y => y.Task == model)));
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:19,代码来源:TaskControllerTests.cs

示例14: EditGetReturnsCorrectViewModelAndView

        public async Task EditGetReturnsCorrectViewModelAndView()
        {
            const int organizationId = 1;
            var editViewModel = new EditViewModel { OrganizationId = organizationId };

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<EditTaskQueryAsync>())).ReturnsAsync(editViewModel);

            var urlHelper = new Mock<IUrlHelper>();
            urlHelper.Setup(x => x.Action(It.IsAny<UrlActionContext>())).Returns(It.IsAny<string>());

            var sut = new TaskController(mediator.Object, null) { Url = urlHelper.Object };
            sut.MakeUserAnOrgAdmin(organizationId.ToString());

            var result = await sut.Edit(It.IsAny<int>()) as ViewResult;
            var modelResult = result.ViewData.Model as EditViewModel;

            Assert.IsType<ViewResult>(result);
            Assert.IsType<EditViewModel>(modelResult);
            Assert.Equal(modelResult, editViewModel);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:21,代码来源:TaskControllerTests.cs

示例15: CreateGetReturnsCorrectView

        public async Task CreateGetReturnsCorrectView()
        {
            const int organizationId = 1;

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<CreateTaskQueryAsync>())).ReturnsAsync(new EditViewModel { OrganizationId = organizationId });

            var urlHelper = new Mock<IUrlHelper>();
            urlHelper.Setup(x => x.Action(It.IsAny<UrlActionContext>())).Returns(It.IsAny<string>());

            var sut = new TaskController(mediator.Object, null) { Url = urlHelper.Object };
            sut.MakeUserAnOrgAdmin(organizationId.ToString());

            var result = await sut.Create(It.IsAny<int>()) as ViewResult;

            Assert.Equal(result.ViewName, "Edit");
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:17,代码来源:TaskControllerTests.cs


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