本文整理汇总了C#中AllReady.Areas.Admin.Controllers.ItineraryController.AddTeamMember方法的典型用法代码示例。如果您正苦于以下问题:C# ItineraryController.AddTeamMember方法的具体用法?C# ItineraryController.AddTeamMember怎么用?C# ItineraryController.AddTeamMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AllReady.Areas.Admin.Controllers.ItineraryController
的用法示例。
在下文中一共展示了ItineraryController.AddTeamMember方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ItineraryController
public async Task AddTeamMemberRedirectsToCorrectActionWithCorrectRouteValuesWhenOrganizationIdIsNotZero_AndUserIsOrgAdmin_AndIdOrSelectedTeamMemberIsNotZero()
{
const int itineraryId = 1;
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 result = await sut.AddTeamMember(itineraryId, 1) as RedirectToActionResult;
Assert.Equal(result.ActionName, nameof(ItineraryController.Details));
Assert.Equal(result.RouteValues, new Dictionary<string, object> { ["id"] = itineraryId });
}
示例2: 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);
}
示例3: AddTeamMemberSendsOrganizationIdQueryWithCorrectItineraryId
public async Task AddTeamMemberSendsOrganizationIdQueryWithCorrectItineraryId()
{
const int itineraryId = 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, null);
sut.SetClaims(new List<Claim>
{
new Claim(AllReady.Security.ClaimTypes.UserType, UserType.SiteAdmin.ToString())
});
await sut.AddTeamMember(itineraryId, 0);
mockMediator.Verify(x => x.SendAsync(It.Is<OrganizationIdQuery>(y => y.ItineraryId == itineraryId)), Times.Once);
}
示例4: 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);
}
示例5: ItineraryController
public async Task AddTeamMemberRedirectsToCorrectActionWithCorrectRouteValuesWhenOrganizationIdIsNotZero_AndUserIsOrgAdmin_AndIdOrSelectedTeamMemberIsNotZero()
{
const int id = 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.OrgAdmin.ToString()),
new Claim(AllReady.Security.ClaimTypes.Organization, "1")
});
var result = await sut.AddTeamMember(id, 1) as RedirectToActionResult;
Assert.Equal(result.ActionName, nameof(ItineraryController.Details));
Assert.Equal(result.RouteValues, new Dictionary<string, object> { ["id"] = id });
}
示例6: AddTeamMemberDoesNotCallAddTeamMemberCommand_WhenSelectedTeamMemberIsZero
public async Task AddTeamMemberDoesNotCallAddTeamMemberCommand_WhenSelectedTeamMemberIsZero()
{
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>())).ReturnsAsync(true);
var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);
await sut.AddTeamMember(1, 0);
mockMediator.Verify(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>()), Times.Never);
}
示例7: AddTeamMemberCallsAddTeamMemberCommand
public async Task AddTeamMemberCallsAddTeamMemberCommand()
{
var mockMediator = new Mock<IMediator>();
mockMediator.Setup(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>())).ReturnsAsync(true);
var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object);
await sut.AddTeamMember(1, 1);
mockMediator.Verify(x => x.SendAsync(It.IsAny<AddTeamMemberCommand>()), Times.Once);
}
示例8: ItineraryController
public async Task AddTeamMemberReturnsCorrectJsonWhenOrganizationIdIsNotZero_AndUserIsOrgAdmin_AndIdOrSelectedTeamMemberIsNotZero()
{
const int itineraryId = 1;
const int orgId = 1;
const int teamMemberId = 1;
string volunteerEmail = "[email protected]";
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);
}
示例9: 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]);
}
示例10: AddTeamMemberSendsAddTeamMemberCommandWithCorrectParameters
public async Task AddTeamMemberSendsAddTeamMemberCommandWithCorrectParameters()
{
const int itineraryId = 1;
const int selectedTeamMember = 1;
string volunteerEmail = "[email protected]";
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(1);
mockMediator.Setup(x => x.SendAsync(It.IsAny<ItineraryDetailQuery>())).ReturnsAsync(itineraryDetailsViewModel);
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, 1);
mockMediator.Verify(x => x.SendAsync(It.Is<AddTeamMemberCommand>(y => y.ItineraryId == itineraryId && y.TaskSignupId == selectedTeamMember)), Times.Once);
mockMediator.Verify(x => x.SendAsync(It.Is<ItineraryDetailQuery>(y => y.ItineraryId == itineraryId)), Times.Once);
}