本文整理汇总了C#中AllReady.Models.ApplicationUser.MakeSiteAdmin方法的典型用法代码示例。如果您正苦于以下问题:C# ApplicationUser.MakeSiteAdmin方法的具体用法?C# ApplicationUser.MakeSiteAdmin怎么用?C# ApplicationUser.MakeSiteAdmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AllReady.Models.ApplicationUser
的用法示例。
在下文中一共展示了ApplicationUser.MakeSiteAdmin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RedirectToCorrectActionResultWithCorrectRouteValues_WhenReturnUrlIsNotALocalUrl_AndUserIsSiteAdmin
public void RedirectToCorrectActionResultWithCorrectRouteValues_WhenReturnUrlIsNotALocalUrl_AndUserIsSiteAdmin()
{
var applicationUser = new ApplicationUser();
applicationUser.MakeSiteAdmin();
//applicationUser.Claims.Add(new IdentityUserClaim<string>
//{
// ClaimType = AllReady.Security.ClaimTypes.UserType,
// ClaimValue = Enum.GetName(typeof(UserType), UserType.SiteAdmin)
//});
var urlHelper = new Mock<IUrlHelper>();
urlHelper.Setup(x => x.IsLocalUrl(It.IsAny<string>())).Returns(false);
var routeValueDictionary = new RouteValueDictionary
{
["area"] = "Admin"
};
var sut = new RedirectAccountControllerRequests();
var result = sut.RedirectToLocal(It.IsAny<string>(), applicationUser, urlHelper.Object) as RedirectToActionResult;
Assert.Equal(result.ActionName, nameof(SiteController.Index));
Assert.Equal(result.ControllerName, "Site");
Assert.Equal(result.RouteValues, routeValueDictionary);
}
示例2: ApplicationUser
public async Task LoginPostReturnsErrorViewWithCorrectTextInViewData_WhenUserIsNotNull_AndUserIsASiteAdmin_AndUsersEmailIsNotConfirmed()
{
var applicationUser = new ApplicationUser();
applicationUser.MakeSiteAdmin();
var mediator = new Mock<IMediator>();
mediator.Setup(x => x.SendAsync(It.IsAny<ApplicationUserQuery>())).ReturnsAsync(applicationUser);
var userManager = MockHelper.CreateUserManagerMock();
userManager.Setup(x => x.IsEmailConfirmedAsync(applicationUser)).ReturnsAsync(false).Verifiable();
var signInManager = MockHelper.CreateSignInManagerMock(userManager);
signInManager.Setup(x => x.PasswordSignInAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<bool>())).ReturnsAsync(Microsoft.AspNetCore.Identity.SignInResult.Failed);
var sut = new AccountController(userManager.Object, signInManager.Object, null, mediator.Object, null, null);
var result = await sut.Login(new LoginViewModel()) as ViewResult;
Assert.Equal(result.ViewData["Message"], "You must have a confirmed email to log on.");
Assert.Equal(result.ViewName, "Error");
}