本文整理汇总了C#中AllReady.Areas.Admin.Controllers.ItineraryController.AddRequests方法的典型用法代码示例。如果您正苦于以下问题:C# ItineraryController.AddRequests方法的具体用法?C# ItineraryController.AddRequests怎么用?C# ItineraryController.AddRequests使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AllReady.Areas.Admin.Controllers.ItineraryController
的用法示例。
在下文中一共展示了ItineraryController.AddRequests方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ItineraryController
public async Task AddRequestsRedirectsToCorrectActionWithCorrectRouteValuesWhenOrganizationIdIsNotZero_AndUserIsOrgAdmin_AndThereAreSelectedRequests()
{
const int orgId = 1;
var itineraryId = It.IsAny<int>();
var selectedRequests = new List<string> { "request1", "request2" };
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(orgId);
var sut = new ItineraryController(mockMediator.Object, null);
sut.MakeUserAnOrgAdmin(orgId.ToString());
var result = await sut.AddRequests(itineraryId, selectedRequests) as RedirectToActionResult;
Assert.Equal(result.ActionName, nameof(ItineraryController.Details));
Assert.Equal(result.RouteValues, new Dictionary<string, object> { ["id"] = itineraryId });
}
示例2: AddRequestsReturnsHttpUnauthorizedWhenUserIsNotOrgAdmin
public async Task AddRequestsReturnsHttpUnauthorizedWhenUserIsNotOrgAdmin()
{
var itineraryId = It.IsAny<int>();
var selectedRequests = new List<string> { "request1", "request2" };
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(1);
var sut = new ItineraryController(mockMediator.Object, null);
sut.MakeUserNotAnOrgAdmin();
Assert.IsType<UnauthorizedResult>(await sut.AddRequests(itineraryId, selectedRequests));
}
示例3: AddRequestsSendsAddRequestsCommandWhenThereAreSelectedRequests
public async Task AddRequestsSendsAddRequestsCommandWhenThereAreSelectedRequests()
{
const int orgId = 1;
var itineraryId = It.IsAny<int>();
var selectedRequests = new List<string> { "request1", "request2" };
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(orgId);
mockMediator.Setup(x => x.SendAsync(It.IsAny<AddRequestsToItineraryCommand>())).ReturnsAsync(true);
var sut = new ItineraryController(mockMediator.Object, null);
sut.MakeUserAnOrgAdmin(orgId.ToString());
await sut.AddRequests(itineraryId, selectedRequests);
mockMediator.Verify(x => x.SendAsync(It.Is<AddRequestsToItineraryCommand>(y => y.RequestIdsToAdd.Equals(selectedRequests))), Times.Once);
}
示例4: ItineraryController
public async Task AddRequestsRedirectsToCorrectActionWithCorrectRouteValuesWhenOrganizationIdIsNotZero_AndUserIsOrgAdmin_AndThereAreSelectedRequests()
{
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")
});
var result = await sut.AddRequests(itineraryId, selectedRequests) as RedirectToActionResult;
Assert.Equal(result.ActionName, nameof(ItineraryController.Details));
Assert.Equal(result.RouteValues, new Dictionary<string, object> { ["id"] = itineraryId });
}
示例5: AddRequestsSendsOrganizationIdQueryWithCorrectItineraryId
public async Task AddRequestsSendsOrganizationIdQueryWithCorrectItineraryId()
{
const int itineraryId = 1;
var mockMediator = new Mock<IMediator>();
var sut = new ItineraryController(mockMediator.Object, null);
await sut.AddRequests(itineraryId, It.IsAny<List<string>>());
mockMediator.Verify(x => x.SendAsync(It.Is<OrganizationIdQuery>(y => y.ItineraryId == itineraryId)), Times.Once);
}
示例6: 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);
}
示例7: 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<HttpUnauthorizedResult>(await sut.AddRequests(itineraryId, selectedRequests));
}
示例8: AddRequestsReturnsHttpUnauthorizedWhenOrganizationIdIsZero
public async Task AddRequestsReturnsHttpUnauthorizedWhenOrganizationIdIsZero()
{
var itineraryId = It.IsAny<int>();
var selectedRequests = new[] { "request1", "request2" };
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(0);
var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);
Assert.IsType<HttpUnauthorizedResult>(await sut.AddRequests(itineraryId, selectedRequests));
}
示例9: AddRequestsSendsOrganizationIdQueryWithCorrectIntineraryId
public async Task AddRequestsSendsOrganizationIdQueryWithCorrectIntineraryId()
{
var itineraryId = It.IsAny<int>();
var selectedRequests = new[] { "request1", "request2" };
var mockMediator = new Mock<IMediator>();
var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);
await sut.AddRequests(itineraryId, selectedRequests);
mockMediator.Verify(x => x.SendAsync(It.Is<OrganizationIdQuery>(y => y.ItineraryId == itineraryId)), Times.Once);
}
示例10: AddRequestsSendsAddRequestsCommandWhenThereAreSelectedRequests
public async Task AddRequestsSendsAddRequestsCommandWhenThereAreSelectedRequests()
{
const int orgId = 1;
var itineraryId = It.IsAny<int>();
var selectedRequests = new[]{ "request1", "request2" };
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(orgId);
var sut = new ItineraryController(mockMediator.Object, null);
sut.MakeUserAnOrgAdmin(orgId.ToString());
await sut.AddRequests(itineraryId, selectedRequests);
//TODO: need a way to verify that the RequestIdsToAdd List<string> is the same as the string array selectedRequests. Only problem is that .ToList() is called on selectedRequests in the AddRequests action method, creating a new List<string>
//mockMediator.Verify(x => x.SendAsync(It.Is<AddRequestsCommand>(y => y.RequestIdsToAdd == selectedRequests.ToList())), Times.Once);
}