本文整理汇总了C#中AllReady.Areas.Admin.Controllers.ItineraryController.SetClaims方法的典型用法代码示例。如果您正苦于以下问题:C# ItineraryController.SetClaims方法的具体用法?C# ItineraryController.SetClaims怎么用?C# ItineraryController.SetClaims使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AllReady.Areas.Admin.Controllers.ItineraryController
的用法示例。
在下文中一共展示了ItineraryController.SetClaims方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetItineraryControllerWithDetailsQuery
private static ItineraryController GetItineraryControllerWithDetailsQuery(string userType, int organizationId)
{
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<ItineraryDetailQuery>())).ReturnsAsync(new ItineraryDetailsModel { Id = 1, Name = "Itinerary", EventId = 1, EventName = "Event Name", OrganizationId = 1, Date = new DateTime(2016, 07, 01) });
var sut = new ItineraryController(mediator.Object, MockSuccessValidation().Object);
sut.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, userType),
new Claim(AllReady.Security.ClaimTypes.Organization, organizationId.ToString())
});
return sut;
}
示例2: GetItineraryControllerWithEventSummaryQuery
private static ItineraryController GetItineraryControllerWithEventSummaryQuery(string userType, int organizationId)
{
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<EventSummaryQuery>())).ReturnsAsync(new EventSummaryModel { Id = 1, Name = "Event", OrganizationId = 1, StartDateTime = new DateTimeOffset(new DateTime(2016, 01, 01)), EndDateTime = new DateTimeOffset(new DateTime(2016, 12, 31)) });
mediator.Setup(x => x.SendAsync(It.IsAny<EditItineraryCommand>())).ReturnsAsync(1);
var sut = new ItineraryController(mediator.Object, MockSuccessValidation().Object);
sut.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, userType),
new Claim(AllReady.Security.ClaimTypes.Organization, organizationId.ToString())
});
return sut;
}
示例3: ItineraryController
public async Task MarkCompleteSendsRequestStatusChangeCommandWithCorrectTaskSignupIdWhenOrganizationIsNotZero_AndUserIsOrgAdmin()
{
var itineraryId = It.IsAny<int>();
var requestId = It.IsAny<Guid>();
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(1);
var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);
sut.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()),
new Claim(AllReady.Security.ClaimTypes.Organization, "1")
});
await sut.MarkComplete(itineraryId, requestId);
mockMediator.Verify(x => x.SendAsync(It.Is<RequestStatusChangeCommand>(y => y.RequestId == requestId)), Times.Once);
}
示例4: ItineraryController
public async Task RemoveTeamMemberRedirectsToCorrectActionWithCorrectRouteValuesWhenOrganizationIdIsNotZero_AndUserIsOrgAdmin()
{
var itineraryId = It.IsAny<int>();
var taskSignupId = It.IsAny<int>();
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(1);
var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);
sut.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()),
new Claim(AllReady.Security.ClaimTypes.Organization, "1")
});
await sut.RemoveTeamMember(itineraryId, taskSignupId);
mockMediator.Verify(x => x.SendAsync(It.Is<RemoveTeamMemberCommand>(y => y.TaskSignupId == taskSignupId)), Times.Once);
}
示例5: EditPost_SendsEditItineraryCommand_WithCorrectItineraryEditModel
public async Task EditPost_SendsEditItineraryCommand_WithCorrectItineraryEditModel()
{
var model = new ItineraryEditViewModel
{
EventId = 1,
Name = "Test",
Date = new DateTime(2016, 06, 01)
};
var mediator = new Mock<IMediator>();
var itinerarySummaryModel = new ItinerarySummaryViewModel
{
Id = 1,
Name = "Itinerary",
OrganizationId = 1,
EventSummary = new EventSummaryViewModel
{
StartDateTime = new DateTimeOffset(new DateTime(2016, 01, 01)),
EndDateTime = new DateTimeOffset(new DateTime(2016, 12, 31))
}
};
mediator.Setup(x => x.SendAsync(It.IsAny<ItinerarySummaryQuery>())).ReturnsAsync(itinerarySummaryModel);
mediator.Setup(x => x.SendAsync(It.IsAny<EditItineraryCommand>())).ReturnsAsync(0).Verifiable();
var mockValidator = new Mock<IItineraryEditModelValidator>();
mockValidator.Setup(mock => mock.Validate(It.IsAny<ItineraryEditViewModel>(), It.IsAny<EventSummaryViewModel>())).Returns(new List<KeyValuePair<string, string>>());
var sut = new ItineraryController(mediator.Object, mockValidator.Object);
sut.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.SiteAdmin.ToString()),
new Claim(AllReady.Security.ClaimTypes.Organization, "1")
});
await sut.Edit(model);
mediator.Verify(x => x.SendAsync(It.Is<EditItineraryCommand>(y => y.Itinerary == model)), Times.Once);
}
示例6: AddTeamMemberDoesNotCallAddTeamMemberCommand_WhenSelectedTeamMemberIsZero
public async Task AddTeamMemberDoesNotCallAddTeamMemberCommand_WhenSelectedTeamMemberIsZero()
{
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>())).ReturnsAsync(true);
mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(1);
var sut = new ItineraryController(mockMediator.Object, null);
sut.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.SiteAdmin.ToString())
});
await sut.AddTeamMember(1, 0);
mockMediator.Verify(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>()), Times.Never);
}
示例7: AddRequestsSendsAddRequestsCommandWhenThereAreSelecteRequests
public async Task AddRequestsSendsAddRequestsCommandWhenThereAreSelecteRequests()
{
var itineraryId = It.IsAny<int>();
var selectedRequests = new[]{ "request1", "request2" };
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(1);
var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);
sut.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()),
new Claim(AllReady.Security.ClaimTypes.Organization, "1")
});
await sut.AddRequests(itineraryId, selectedRequests);
mockMediator.Verify(x => x.SendAsync(It.Is<AddRequestsCommand>(y => y.ItineraryId == itineraryId)), Times.Once);
}
示例8: EditGet_ReturnsViewResult_WhenUserIsSiteAdmin
public async Task EditGet_ReturnsViewResult_WhenUserIsSiteAdmin()
{
const int orgId = 1;
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<EditItineraryQuery>())).ReturnsAsync(new ItineraryEditViewModel { OrganizationId = orgId, Id = 100, Name = "Test"});
var sut = new ItineraryController(mediator.Object, MockSuccessValidation().Object);
sut.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.SiteAdmin.ToString()),
new Claim(AllReady.Security.ClaimTypes.Organization, "0")
});
// Assert
var viewResult = Assert.IsType<ViewResult>(await sut.Edit(1));
var model = viewResult.Model as ItineraryEditViewModel;
model.ShouldNotBeNull();
model.Name.ShouldBe("Test");
}
示例9: AddTeamMemberSendsAddTeamMemberCommandWithCorrectParameters
public async Task AddTeamMemberSendsAddTeamMemberCommandWithCorrectParameters()
{
const int itineraryId = 1;
const int selectedTeamMember = 1;
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>())).ReturnsAsync(true);
mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(1);
var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);
sut.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.SiteAdmin.ToString())
});
await sut.AddTeamMember(1, 1);
mockMediator.Verify(x => x.SendAsync(It.Is<AddTeamMemberCommand>(y => y.ItineraryId == itineraryId && y.TaskSignupId == selectedTeamMember)), Times.Once);
}
示例10: AddRequestsReturnsHttpUnauthorizedWhenUserIsNotOrgAdmin
public async Task AddRequestsReturnsHttpUnauthorizedWhenUserIsNotOrgAdmin()
{
var itineraryId = It.IsAny<int>();
var selectedRequests = new[]{ "request1", "request2" };
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(1);
var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);
sut.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.BasicUser.ToString())
});
Assert.IsType<UnauthorizedResult>(await sut.AddRequests(itineraryId, selectedRequests));
}
示例11: SelectRequestsWithSingleParameterSetsSelectItineraryRequestsModelWithTheCorrectData
public async Task SelectRequestsWithSingleParameterSetsSelectItineraryRequestsModelWithTheCorrectData()
{
var organizationId = 4;
var itineraryRequestsModel = new SelectItineraryRequestsModel();
var itinerary = GetItineraryForSelectRequestHappyPathTests();
var returnedRequests = GetRequestsForSelectRequestHappyPathTests();
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.Is<ItineraryDetailQuery>(y => y.ItineraryId == itinerary.Id)))
.ReturnsAsync(itinerary);
mediator.Setup(x => x.SendAsync(It.IsAny<RequestListItemsQuery>()))
.ReturnsAsync(returnedRequests);
mediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>()))
.ReturnsAsync(organizationId);
var sut = new ItineraryController(mediator.Object, MockSuccessValidation().Object);
sut.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()),
new Claim(AllReady.Security.ClaimTypes.Organization, organizationId.ToString())
});
var view = await sut.SelectRequests(itinerary.Id, itineraryRequestsModel);
RunSelectRequestsHappyPathTests(view, itinerary, returnedRequests);
}
示例12: MarkCompleteReturnsRedirectToAction_WithActionName_Details
public async Task MarkCompleteReturnsRedirectToAction_WithActionName_Details()
{
var itineraryId = It.IsAny<int>();
var requestId = It.IsAny<Guid>();
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(1);
var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);
sut.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()),
new Claim(AllReady.Security.ClaimTypes.Organization, "1")
});
var result = await sut.MarkComplete(itineraryId, requestId);
var actionResult = (RedirectToActionResult)result;
Assert.Equal("Details", actionResult.ActionName);
}
示例13: CreateReturnsOkResultWhenUserIsSiteAdmin_AndModelIsValid_AndSuccessfulAdd
public async Task CreateReturnsOkResultWhenUserIsSiteAdmin_AndModelIsValid_AndSuccessfulAdd()
{
const int orgId = 1;
//var sut = GetItineraryControllerWithEventSummaryQuery(UserType.SiteAdmin.ToString(), 0);
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<EventSummaryQuery>())).ReturnsAsync(new EventSummaryViewModel { OrganizationId = orgId });
mediator.Setup(x => x.SendAsync(It.IsAny<EditItineraryCommand>())).ReturnsAsync(orgId);
var sut = new ItineraryController(mediator.Object, MockSuccessValidation().Object);
sut.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.SiteAdmin.ToString()),
new Claim(AllReady.Security.ClaimTypes.Organization, "0")
});
Assert.IsType<OkObjectResult>(await sut.Create(new ItineraryEditViewModel()));
}
示例14: CreateReturnsHttpBadRequestResultWhenEditItineraryReturnsZero
public async Task CreateReturnsHttpBadRequestResultWhenEditItineraryReturnsZero()
{
var model = new ItineraryEditViewModel
{
EventId = 1,
Name = "Test",
Date = new DateTime(2016, 06, 01)
};
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<EventSummaryQuery>())).ReturnsAsync(new EventSummaryViewModel { Id = 1, Name = "Event", OrganizationId = 1, StartDateTime = new DateTimeOffset(new DateTime(2016, 01, 01)), EndDateTime = new DateTimeOffset(new DateTime(2016, 12, 31)) });
mediator.Setup(x => x.SendAsync(It.IsAny<EditItineraryCommand>())).ReturnsAsync(0);
var mockValidator = new Mock<IItineraryEditModelValidator>();
mockValidator.Setup(mock => mock.Validate(It.IsAny<ItineraryEditViewModel>(), It.IsAny<EventSummaryViewModel>())).Returns(new List<KeyValuePair<string, string>>()).Verifiable();
var sut = new ItineraryController(mediator.Object, mockValidator.Object);
sut.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.SiteAdmin.ToString()),
new Claim(AllReady.Security.ClaimTypes.Organization, "1")
});
var result = await sut.Create(model);
Assert.IsType<BadRequestResult>(result);
}
示例15: ConfirmRemoveTeamMemberReturnsHttpNotFoundWhenTaskSignupSummaryModelIsNull
public async Task ConfirmRemoveTeamMemberReturnsHttpNotFoundWhenTaskSignupSummaryModelIsNull()
{
var itineraryId = It.IsAny<int>();
var taskSignupId = It.IsAny<int>();
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(1);
mockMediator.Setup(x => x.SendAsync(It.IsAny<TaskSignupSummaryQuery>())).ReturnsAsync(null);
var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);
sut.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()),
new Claim(AllReady.Security.ClaimTypes.Organization, "1")
});
Assert.IsType<HttpNotFoundResult>(await sut.ConfirmRemoveTeamMember(itineraryId, taskSignupId));
}