本文整理汇总了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);
}
示例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);
}
示例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");
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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)));
}
示例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);
}
示例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");
}