本文整理汇总了C#中AllReady.Areas.Admin.Controllers.TaskController.SetDefaultHttpContext方法的典型用法代码示例。如果您正苦于以下问题:C# TaskController.SetDefaultHttpContext方法的具体用法?C# TaskController.SetDefaultHttpContext怎么用?C# TaskController.SetDefaultHttpContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AllReady.Areas.Admin.Controllers.TaskController
的用法示例。
在下文中一共展示了TaskController.SetDefaultHttpContext方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGetReturnsHttpUnauthorizedResultWhenUserIsNotOrganizationAdminForTheirOrganization
public void CreateGetReturnsHttpUnauthorizedResultWhenUserIsNotOrganizationAdminForTheirOrganization()
{
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.Send(It.IsAny<EventByIdQuery>())).Returns(new Event { Campaign = new Campaign { ManagingOrganizationId = 1 } });
var sut = new TaskController(mediator.Object, Mock.Of<ITaskSummaryModelValidator>());
sut.SetDefaultHttpContext();
var result = sut.Create(It.IsAny<int>());
Assert.IsType<HttpUnauthorizedResult>(result);
}
示例2: CreateGetReturnsUnauthorizedResultWhenUserIsNotOrganizationAdmin
public async Task CreateGetReturnsUnauthorizedResultWhenUserIsNotOrganizationAdmin()
{
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<CreateTaskQueryAsync>())).ReturnsAsync(new EditViewModel());
var sut = new TaskController(mediator.Object, null);
sut.SetDefaultHttpContext();
var result = await sut.Create(It.IsAny<int>());
Assert.IsType<UnauthorizedResult>(result);
}
示例3: ControllerHasAreaAtttributeWithTheCorrectAreaName
public void ControllerHasAreaAtttributeWithTheCorrectAreaName()
{
var sut = new TaskController(null, Mock.Of<ITaskSummaryModelValidator>());
sut.SetDefaultHttpContext();
var attribute = sut.GetAttributes().OfType<AreaAttribute>().SingleOrDefault();
Assert.NotNull(attribute);
Assert.Equal(attribute.RouteValue, "Admin");
}
示例4: MessageAllVolunttersReturnsHttpUnauthorizedResultWhenUserIsNotOrgAdmin
public async Task MessageAllVolunttersReturnsHttpUnauthorizedResultWhenUserIsNotOrgAdmin()
{
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.MessageAllVolunteers(new MessageTaskVolunteersModel());
Assert.IsType<HttpUnauthorizedResult>(result);
}
示例5: AssignReturnsHttpUnauthorizedResultWhenUserIsNotOrgAdmin
public async Task AssignReturnsHttpUnauthorizedResultWhenUserIsNotOrgAdmin()
{
var taskModelSummary = new TaskSummaryModel { EventId = 1 };
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<TaskQueryAsync>())).ReturnsAsync(taskModelSummary);
mediator.Setup(x => x.Send(It.IsAny<EventByIdQuery>())).Returns(new Event { Campaign = new Campaign { ManagingOrganizationId = 1 } });
var sut = new TaskController(mediator.Object, Mock.Of<ITaskSummaryModelValidator>());
sut.SetDefaultHttpContext();
var result = await sut.Assign(1, null);
Assert.IsType<HttpUnauthorizedResult>(result);
}
示例6: AssignSendsTaskQueryAsyncWithCorrectTaskId
public async Task AssignSendsTaskQueryAsyncWithCorrectTaskId()
{
const int taskId = 1;
var taskModelSummary = new TaskSummaryModel { EventId = 1 };
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.Send(It.IsAny<EventByIdQuery>())).Returns(new Event { Campaign = new Campaign { ManagingOrganizationId = 1 } });
mediator.Setup(x => x.SendAsync(It.IsAny<TaskQueryAsync>())).ReturnsAsync(taskModelSummary);
var sut = new TaskController(mediator.Object, Mock.Of<ITaskSummaryModelValidator>());
sut.SetDefaultHttpContext();
await sut.Assign(taskId, null);
mediator.Verify(x => x.SendAsync(It.Is<TaskQueryAsync>(y => y.TaskId == taskId)), Times.Once);
}
示例7: EditPostReturnsHttpUnauthorizedResultWhenModelStateIsValidAndUserIsNotAnOrganizationAdminUser
public async Task EditPostReturnsHttpUnauthorizedResultWhenModelStateIsValidAndUserIsNotAnOrganizationAdminUser()
{
var startDateTime = DateTimeOffset.Now.AddDays(-1);
var endDateTime = DateTimeOffset.Now.AddDays(1);
var model = new TaskSummaryModel { StartDateTime = startDateTime, EndDateTime = endDateTime, OrganizationId = 1 };
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.Send(It.IsAny<EventByIdQuery>())).Returns(new Event
{
Campaign = new Campaign { TimeZoneId = "Eastern Standard Time" },
StartDateTime = startDateTime.AddDays(-1),
EndDateTime = endDateTime.AddDays(1)
});
var validator = new Mock<ITaskSummaryModelValidator>();
validator.Setup(x => x.Validate(It.IsAny<TaskSummaryModel>())).Returns(new List<KeyValuePair<string, string>>());
var sut = new TaskController(mediator.Object, validator.Object);
sut.SetDefaultHttpContext();
var result = await sut.Edit(model);
Assert.IsType<HttpUnauthorizedResult>(result);
}
示例8: MessageAllVolunteersReturnsUnauthorizedResultWhenUserIsNotOrgAdmin
public async Task MessageAllVolunteersReturnsUnauthorizedResultWhenUserIsNotOrgAdmin()
{
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdByTaskIdQueryAsync>())).ReturnsAsync(It.IsAny<int>());
var sut = new TaskController(mediator.Object, null);
sut.SetDefaultHttpContext();
var result = await sut.MessageAllVolunteers(new MessageTaskVolunteersViewModel());
Assert.IsType<UnauthorizedResult>(result);
}
示例9: AssignSendsOrganizationIdByTaskIdQueryAsyncWithCorrectTaskId
public async Task AssignSendsOrganizationIdByTaskIdQueryAsyncWithCorrectTaskId()
{
const int taskId = 1;
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdByTaskIdQueryAsync>())).ReturnsAsync(It.IsAny<int>());
var sut = new TaskController(mediator.Object, null);
sut.SetDefaultHttpContext();
await sut.Assign(taskId, null);
mediator.Verify(x => x.SendAsync(It.Is<OrganizationIdByTaskIdQueryAsync>(y => y.TaskId == taskId)), Times.Once);
}
示例10: 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);
}
示例11: DeleteReturnsHttpUnauthorizedResultWhenUserIsNotOrgAdmin
public async Task DeleteReturnsHttpUnauthorizedResultWhenUserIsNotOrgAdmin()
{
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<DeleteQueryAsync>())).ReturnsAsync(new DeleteViewModel());
var sut = new TaskController(mediator.Object, null);
sut.SetDefaultHttpContext();
var result = await sut.Delete(It.IsAny<int>());
Assert.IsType<UnauthorizedResult>(result);
}
示例12: EditPostReturnsUnauthorizedResultWhenModelStateIsValidAndUserIsNotAnOrganizationAdminUser
public async Task EditPostReturnsUnauthorizedResultWhenModelStateIsValidAndUserIsNotAnOrganizationAdminUser()
{
var validator = new Mock<ITaskEditViewModelValidator>();
validator.Setup(x => x.Validate(It.IsAny<EditViewModel>())).Returns(new List<KeyValuePair<string, string>>());
var sut = new TaskController(Mock.Of<IMediator>(), validator.Object);
sut.SetDefaultHttpContext();
var result = await sut.Edit(new EditViewModel());
Assert.IsType<UnauthorizedResult>(result);
}
示例13: CreatePostReturnsHttpUnauthorizedResultWhenModelStateIsValidAndUserIsNotAnOrganizationAdminUser
public async Task CreatePostReturnsHttpUnauthorizedResultWhenModelStateIsValidAndUserIsNotAnOrganizationAdminUser()
{
var startDateTime = DateTimeOffset.Now.AddDays(-1);
var endDateTime = DateTimeOffset.Now.AddDays(1);
var model = new TaskEditModel { StartDateTime = startDateTime, EndDateTime = endDateTime, OrganizationId = 1 };
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.Send(It.IsAny<ActivityByActivityIdQuery>())).Returns(new Activity
{
Campaign = new Campaign { TimeZoneId = "Eastern Standard Time" },
StartDateTime = startDateTime.AddDays(-1),
EndDateTime = endDateTime.AddDays(1)
});
var sut = new TaskController(mediator.Object);
sut.SetDefaultHttpContext();
var result = await sut.Create(It.IsAny<int>(), model);
Assert.IsType<HttpUnauthorizedResult>(result);
}