当前位置: 首页>>代码示例>>C#>>正文


C# ApplicationUser.MakeSiteAdmin方法代码示例

本文整理汇总了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);
        }
开发者ID:ChrisDobby,项目名称:allReady,代码行数:25,代码来源:RedirectAccountControllerRequestsShould.cs

示例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");
        }
开发者ID:nicolastarzia,项目名称:allReady,代码行数:20,代码来源:AccountControllerTests.cs


注:本文中的AllReady.Models.ApplicationUser.MakeSiteAdmin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。