本文整理汇总了C#中AllReady.Areas.Admin.Controllers.ItineraryController.MakeUserAnOrgAdmin方法的典型用法代码示例。如果您正苦于以下问题:C# ItineraryController.MakeUserAnOrgAdmin方法的具体用法?C# ItineraryController.MakeUserAnOrgAdmin怎么用?C# ItineraryController.MakeUserAnOrgAdmin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AllReady.Areas.Admin.Controllers.ItineraryController
的用法示例。
在下文中一共展示了ItineraryController.MakeUserAnOrgAdmin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ItineraryController
public async Task MarkCompleteSendsRequestStatusChangeCommandWithCorrectRequestIdWhenOrganizationIsNotZero_AndUserIsOrgAdmin()
{
var requestId = Guid.NewGuid();
const int orgId = 1;
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.MarkComplete(It.IsAny<int>(), requestId);
mockMediator.Verify(x => x.SendAsync(It.Is<ChangeRequestStatusCommand>(y => y.RequestId == requestId)), Times.Once);
}
示例2: ConfirmRemoveTeamMemberReturnsHttpNotFound_WhenTaskSignupSummaryModelIsNull
public async Task ConfirmRemoveTeamMemberReturnsHttpNotFound_WhenTaskSignupSummaryModelIsNull()
{
const int orgId = 1;
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(orgId);
mockMediator.Setup(x => x.SendAsync(It.IsAny<TaskSignupSummaryQuery>())).ReturnsAsync(null);
var sut = new ItineraryController(mockMediator.Object, null);
sut.MakeUserAnOrgAdmin(orgId.ToString());
Assert.IsType<NotFoundResult>(await sut.ConfirmRemoveTeamMember(It.IsAny<int>(), It.IsAny<int>()));
}
示例3: ConfirmRemoveTeamMemberReturnsTheCorrectViewAndViewModel
public async Task ConfirmRemoveTeamMemberReturnsTheCorrectViewAndViewModel()
{
const int orgId = 1;
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(orgId);
mockMediator.Setup(x => x.SendAsync(It.IsAny<TaskSignupSummaryQuery>())).ReturnsAsync(new TaskSignupSummaryViewModel { TaskSignupId = It.IsAny<int>(), VolunteerEmail = "[email protected]", VolunteerName = "Test McTesterson" });
var sut = new ItineraryController(mockMediator.Object, null);
sut.MakeUserAnOrgAdmin(orgId.ToString());
var result = await sut.ConfirmRemoveTeamMember(It.IsAny<int>(), It.IsAny<int>()) as ViewResult;
Assert.Equal(result.ViewName, "ConfirmRemoveTeamMember");
var resultViewModel = result.ViewData.Model;
Assert.IsType<TaskSignupSummaryViewModel>(resultViewModel);
}
示例4: 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);
}
示例5: DetailsPost_ReturnsViewModelWithCorrectRequestListData
public async Task DetailsPost_ReturnsViewModelWithCorrectRequestListData()
{
const int orgId = 1;
var fullList = new List<RequestListViewModel> {new RequestListViewModel {Id = Guid.NewGuid()}};
var filteredList = new List<RequestListViewModel> {new RequestListViewModel {Id = Guid.NewGuid()}};
var viewModel = new ItineraryDetailsViewModel { OrganizationId = orgId, Requests = fullList};
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<ItineraryDetailQuery>())).ReturnsAsync(viewModel);
mediator.Setup(x => x.SendAsync(It.IsAny<RequestListItemsQuery>())).ReturnsAsync(filteredList);
var sut = new ItineraryController(mediator.Object, null);
sut.MakeUserAnOrgAdmin(orgId.ToString());
var result = await sut.Details(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<RequestStatus?>()) as ViewResult;
var model = (ItineraryDetailsViewModel) result.ViewData.Model;
Assert.Equal(model.Requests, filteredList);
}
示例6: CreateReturnsOkResultWhenUserIsOrgAdmin
public async Task CreateReturnsOkResultWhenUserIsOrgAdmin()
{
const int orgId = 1;
//var sut = GetItineraryControllerWithEventSummaryQuery(UserType.OrgAdmin.ToString(), 1);
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.MakeUserAnOrgAdmin(orgId.ToString());
Assert.IsType<OkObjectResult>(await sut.Create(new ItineraryEditViewModel()));
}
示例7: ConfirmRemoveRequestReturnsNotFoundResult_WhenViewModelIsNull
public async Task ConfirmRemoveRequestReturnsNotFoundResult_WhenViewModelIsNull()
{
const int orgId = 1;
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(orgId);
var sut = new ItineraryController(mediator.Object, null);
sut.MakeUserAnOrgAdmin(orgId.ToString());
var result = await sut.ConfirmRemoveRequest(It.IsAny<int>(), It.IsAny<Guid>());
Assert.IsType<NotFoundResult>(result);
}
示例8: ConfirmRemoveRequestSendsRequestSummaryQueryWithCorrectRequestId
public async Task ConfirmRemoveRequestSendsRequestSummaryQueryWithCorrectRequestId()
{
const int orgId = 1;
var requestId = Guid.NewGuid();
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(orgId);
var sut = new ItineraryController(mediator.Object, null);
sut.MakeUserAnOrgAdmin(orgId.ToString());
await sut.ConfirmRemoveRequest(It.IsAny<int>(), requestId);
mediator.Verify(x => x.SendAsync(It.Is<RequestSummaryQuery>(y => y.RequestId == requestId)));
}
示例9: ItineraryController
public async Task RemoveTeamMemberRedirectsToCorrectActionWithCorrectRouteValuesWhenOrganizationIdIsNotZero_AndUserIsOrgAdmin()
{
const int orgId = 1;
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.RemoveTeamMember(It.IsAny<int>(), It.IsAny<int>());
//TODO: this assertion does not assert what the title of this unit test says it does. Please fix to assert that the redirect action and route values are correct
//mockMediator.Verify(x => x.SendAsync(It.Is<RemoveTeamMemberCommand>(y => y.TaskSignupId == taskSignupId)), Times.Once);
}
示例10: DetailsReturnsCorrectViewAndViewModelWhenEventIsNotNullAndUserIsOrgAdmin
public async Task DetailsReturnsCorrectViewAndViewModelWhenEventIsNotNullAndUserIsOrgAdmin()
{
const int orgId = 1;
var viewModel = new ItineraryDetailsViewModel { OrganizationId = orgId };
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<ItineraryDetailQuery>())).ReturnsAsync(viewModel);
var sut = new ItineraryController(mediator.Object, null);
sut.MakeUserAnOrgAdmin(orgId.ToString());
var result = await sut.Details(It.IsAny<int>()) as ViewResult;
Assert.Equal(result.ViewName, "Details");
var resultViewModel = result.ViewData.Model;
Assert.IsType<ItineraryDetailsViewModel>(resultViewModel);
Assert.Equal(resultViewModel, viewModel);
}
示例11: 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);
}
示例12: ItineraryController
public async Task AddTeamMemberReturnsCorrectJsonWhenOrganizationIdIsNotZero_AndUserIsOrgAdmin_AndIdOrSelectedTeamMemberIsNotZero()
{
const int itineraryId = 1;
const int orgId = 1;
const int teamMemberId = 1;
string volunteerEmail = "[email protected]ample.com";
var mockMediator = new Mock<IMediator>();
var itineraryDetailsViewModel = new ItineraryDetailsViewModel
{
PotentialTeamMembers = new List<SelectListItem>(),
TeamMembers = new List<TeamListViewModel>
{
new TeamListViewModel {VolunteerEmail = volunteerEmail}
}
};
mockMediator.Setup(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>())).ReturnsAsync(true);
mockMediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(orgId);
mockMediator.Setup(x => x.SendAsync(It.IsAny<ItineraryDetailQuery>())).ReturnsAsync(itineraryDetailsViewModel);
var sut = new ItineraryController(mockMediator.Object, null);
sut.MakeUserAnOrgAdmin(orgId.ToString());
var jsonResult = await sut.AddTeamMember(itineraryId, teamMemberId) as JsonResult;
var successStatus = jsonResult.GetValueForProperty<bool>("isSuccess");
var teamMembers = jsonResult.GetValueForProperty<IEnumerable<TeamListViewModel>>("teamMembers").ToList();
var potentialMembers = jsonResult.GetValueForProperty<IEnumerable<SelectListItem>>("potentialTeamMembers").ToList();
Assert.True(successStatus);
Assert.NotNull(teamMembers);
Assert.NotNull(potentialMembers);
Assert.Equal(1, teamMembers.Count);
Assert.Equal(volunteerEmail, teamMembers[0].VolunteerEmail);
}
示例13: AddTeamMemberReturnsCorrectJsonWhenIdIsZeroOrSelectedTeamMemberIsZero
public async Task AddTeamMemberReturnsCorrectJsonWhenIdIsZeroOrSelectedTeamMemberIsZero()
{
const int itineraryId = 0;
const int orgId = 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(orgId);
var sut = new ItineraryController(mockMediator.Object, null);
sut.MakeUserAnOrgAdmin(orgId.ToString());
var jsonResult = await sut.AddTeamMember(itineraryId, 0) as JsonResult;
var successStatus = jsonResult.GetValueForProperty<bool>("isSuccess");
var errors = jsonResult.GetValueForProperty<string[]>("errors");
Assert.False(successStatus);
Assert.NotNull(errors);
Assert.Equal(1, errors.Length);
Assert.Equal("Invalid selection.", errors[0]);
}
示例14: MarkCompleteReturnsRedirectToActionWhenOrganizationIsNotZero_AndUserIsOrgAdmin
public async Task MarkCompleteReturnsRedirectToActionWhenOrganizationIsNotZero_AndUserIsOrgAdmin()
{
const int orgId = 1;
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.MarkComplete(It.IsAny<int>(), It.IsAny<Guid>());
Assert.IsType<RedirectToActionResult>(result);
}
示例15: ConfirmRemoveRequestAssignsCorrectTitleOnViewModel
public async Task ConfirmRemoveRequestAssignsCorrectTitleOnViewModel()
{
const int orgId = 1;
var requestId = Guid.NewGuid();
var viewModel = new RequestSummaryViewModel { Name = "ViewModelName" };
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<OrganizationIdQuery>())).ReturnsAsync(orgId);
mediator.Setup(x => x.SendAsync(It.IsAny<RequestSummaryQuery>())).ReturnsAsync(viewModel);
var sut = new ItineraryController(mediator.Object, null);
sut.MakeUserAnOrgAdmin(orgId.ToString());
var result = await sut.ConfirmRemoveRequest(It.IsAny<int>(), requestId) as ViewResult;
var resultViewModel = result.ViewData.Model as RequestSummaryViewModel;
Assert.Equal(resultViewModel.Title, $"Remove request: {viewModel.Name}");
}