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


C# SiteController.RevokeOrganizationAdmin方法代码示例

本文整理汇总了C#中AllReady.Areas.Admin.Controllers.SiteController.RevokeOrganizationAdmin方法的典型用法代码示例。如果您正苦于以下问题:C# SiteController.RevokeOrganizationAdmin方法的具体用法?C# SiteController.RevokeOrganizationAdmin怎么用?C# SiteController.RevokeOrganizationAdmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AllReady.Areas.Admin.Controllers.SiteController的用法示例。


在下文中一共展示了SiteController.RevokeOrganizationAdmin方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RevokeOrganizationAdminReturnsAViewWhenErrorIsThrown

 public async Task RevokeOrganizationAdminReturnsAViewWhenErrorIsThrown()
 {
     var mediator = new Mock<IMediator>();
     var userManager = CreateApplicationUserMock();
     var logger = new Mock<ILogger<SiteController>>();
     string userId = "1234";
     mediator.Setup(m => m.Send(It.Is<UserByUserIdQuery>(q => q.UserId == userId))).Throws<Exception>();
     var controller = new SiteController(userManager.Object, logger.Object, mediator.Object);
     var result = (ViewResult)await controller.RevokeOrganizationAdmin(userId);
     Assert.IsType<ViewResult>(result);
 }
开发者ID:mheggeseth,项目名称:allReady,代码行数:11,代码来源:SiteAdminControllerShould.cs

示例2: RevokeOrganizationAdminSendsUserByUserIdQueryWithCorrectUserId

        public async Task RevokeOrganizationAdminSendsUserByUserIdQueryWithCorrectUserId()
        {
            var mediator = new Mock<IMediator>();
            var logger = new Mock<ILogger<SiteController>>();

            string userId = It.IsAny<string>();
            mediator.Setup(x => x.Send(It.Is<UserByUserIdQuery>(q => q.UserId == userId))).Returns(new ApplicationUser());
            var controller = new SiteController(null, logger.Object, mediator.Object);

            await controller.RevokeOrganizationAdmin(userId);
            mediator.Verify(m => m.Send(It.Is<UserByUserIdQuery>(q => q.UserId == userId)), Times.Once);
        }
开发者ID:yobenzima,项目名称:allReady,代码行数:12,代码来源:SiteAdminControllerShould.cs

示例3: RevokeOrganizationAdminAddsCorrectErrorMessageToViewBagWhenExceptionIsThrown

        public async Task RevokeOrganizationAdminAddsCorrectErrorMessageToViewBagWhenExceptionIsThrown()
        {
            var mediator = new Mock<IMediator>();
            var userManager = CreateApplicationUserMock();
            var logger = new Mock<ILogger<SiteController>>();
            string userId = "1234";
            mediator.Setup(m => m.Send(It.Is<UserByUserIdQuery>(q => q.UserId == userId))).Throws<Exception>();
            var controller = new SiteController(userManager.Object, logger.Object, mediator.Object);
            var result = await controller.RevokeOrganizationAdmin(userId);

            string expectedMessage = $"Failed to revoke organization admin for {userId}. Exception thrown.";

            Assert.Equal(controller.ViewBag.ErrorMessage, expectedMessage);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:14,代码来源:SiteAdminControllerShould.cs

示例4: RevokeOrganizationAdminInvokesLogErrorWithCorrectParametersWhenExceptionIsThrown

        public async Task RevokeOrganizationAdminInvokesLogErrorWithCorrectParametersWhenExceptionIsThrown()
        {
            var mediator = new Mock<IMediator>();
            var userManager = CreateApplicationUserMock();
            var logger = new Mock<ILogger<SiteController>>();
            string userId = "1234";
            mediator.Setup(m => m.Send(It.Is<UserByUserIdQuery>(q => q.UserId == userId))).Throws<Exception>();
            var controller = new SiteController(userManager.Object, logger.Object, mediator.Object);
            var result = await controller.RevokeOrganizationAdmin(userId);

            string expectedMessage = $"Failed to revoke organization admin for {userId}";

            logger.Verify(l => l.Log(LogLevel.Error, 0,
                It.Is<Microsoft.Extensions.Logging.Internal.FormattedLogValues>(x => x.ToString().Equals(expectedMessage)),
                null, It.IsAny<Func<object, Exception, string>>()), Times.Once);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:16,代码来源:SiteAdminControllerShould.cs

示例5: RevokeOrganizationAdminRedirectsToCorrectAction

        public async Task RevokeOrganizationAdminRedirectsToCorrectAction()
        {
            var mediator = new Mock<IMediator>();
            var userManager = CreateApplicationUserMock();
            var logger = new Mock<ILogger<SiteController>>();
            string userId = "1234";
            ApplicationUser user = new ApplicationUser() { UserName = "name", Id = userId };
            mediator.Setup(m => m.Send(It.Is<UserByUserIdQuery>(q => q.UserId == userId))).Returns(user);

            string orgId = "4567";
            IList<Claim> claims = new List<Claim>();
            claims.Add(new Claim(AllReady.Security.ClaimTypes.UserType, UserType.SiteAdmin.ToName()));
            claims.Add(new Claim(AllReady.Security.ClaimTypes.Organization, orgId));
            userManager.Setup(u => u.GetClaimsAsync(user)).ReturnsAsync(claims);

            var controller = new SiteController(userManager.Object, logger.Object, mediator.Object);
            var result = (RedirectToActionResult) await controller.RevokeOrganizationAdmin(userId);

            Assert.Equal("Index", result.ActionName);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:20,代码来源:SiteAdminControllerShould.cs

示例6: RevokeOrganizationAdminInokesRemoveClaimAsyncTwiceWithCorrectParameters

        public async Task RevokeOrganizationAdminInokesRemoveClaimAsyncTwiceWithCorrectParameters()
        {
            var mediator = new Mock<IMediator>();
            var userManager = CreateApplicationUserMock();
            var logger = new Mock<ILogger<SiteController>>();
            string userId = "1234";
            ApplicationUser user = new ApplicationUser() { UserName = "name", Id = userId };
            mediator.Setup(m => m.Send(It.Is<UserByUserIdQuery>(q => q.UserId == userId))).Returns(user);

            string orgId = "4567";
            IList<Claim> claims = new List<Claim>();
            claims.Add(new Claim(AllReady.Security.ClaimTypes.UserType, UserType.SiteAdmin.ToName()));
            claims.Add(new Claim(AllReady.Security.ClaimTypes.Organization, orgId));
            userManager.Setup(u => u.GetClaimsAsync(user)).ReturnsAsync(claims);

            var controller = new SiteController(userManager.Object, logger.Object, mediator.Object);
            var result = await controller.RevokeOrganizationAdmin(userId);

            userManager.Verify(u => u.RemoveClaimAsync(user, It.Is<Claim>(c =>
                                                c.Type == AllReady.Security.ClaimTypes.UserType
                                                && c.Value == UserType.SiteAdmin.ToName())), Times.Once);
            userManager.Verify(u => u.RemoveClaimAsync(user, It.Is<Claim>(c =>
                                                            c.Type == AllReady.Security.ClaimTypes.Organization
                                                            && c.Value == orgId)), Times.Once);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:25,代码来源:SiteAdminControllerShould.cs

示例7: RevokeOrganizationAdminInvokesGetclaimsAsyncWithCorrectUser

        public async Task RevokeOrganizationAdminInvokesGetclaimsAsyncWithCorrectUser()
        {
            var mediator = new Mock<IMediator>();
            var userManager = CreateApplicationUserMock();
            var logger = new Mock<ILogger<SiteController>>();
            string userId = "1234";
            ApplicationUser user = new ApplicationUser() { UserName = "name", Id = userId };
            mediator.Setup(m => m.Send(It.Is<UserByUserIdQuery>(q => q.UserId == userId))).Returns(user);

            var controller = new SiteController(userManager.Object, logger.Object, mediator.Object);
            var result = await controller.RevokeOrganizationAdmin(userId);

            userManager.Verify(u => u.GetClaimsAsync(user), Times.Once);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:14,代码来源:SiteAdminControllerShould.cs


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