• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Controllers.SiteController类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



SiteController类属于AllReady.Areas.Admin.Controllers命名空间,在下文中一共展示了SiteController类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ConfirmDeletUserSendsDeleteUserCommandAsync

        public async Task ConfirmDeletUserSendsDeleteUserCommandAsync()
        {
            var mediator = new Mock<IMediator>();
            var controller = new SiteController(null, null, null, null, mediator.Object);
            const string userId = "foo_id";

            await controller.ConfirmDeleteUser(userId);
            mediator.Verify(b => b.SendAsync(It.Is<DeleteUserCommand>(u => u.UserId == userId)));
        }
开发者ID:mmoore99,项目名称:allReady,代码行数:9,代码来源:SiteAdminControllerShould.cs


示例2: DeleteUserSendsUserQueryWithCorrectUserId

        public async Task DeleteUserSendsUserQueryWithCorrectUserId()
        {
            var mediator = new Mock<IMediator>();
            
            const string userId = "foo_id";
            mediator.Setup(x => x.SendAsync(It.Is<UserQuery>(q => q.UserId == userId))).ReturnsAsync(new EditUserModel());
            var controller = new SiteController(null, null, mediator.Object);

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


示例3: DeleteUserReturnsTheCorrectViewModel

        public async Task DeleteUserReturnsTheCorrectViewModel()
        {
            var mediator = new Mock<IMediator>();
            const string userId = "foo_id";
            mediator.Setup(x => x.SendAsync(It.IsAny<UserQuery>())).ReturnsAsync(new EditUserModel());
            var controller = new SiteController(null, null, mediator.Object);            

            var result = await controller.DeleteUser(userId);
            var model = ((ViewResult)result).ViewData.Model as DeleteUserModel;

            Assert.Equal(model.UserId, userId);
            Assert.IsType<DeleteUserModel>(model);
        }
开发者ID:yobenzima,项目名称:allReady,代码行数:13,代码来源:SiteAdminControllerShould.cs


示例4: IndexReturnsCorrectViewModel

        public async Task IndexReturnsCorrectViewModel()
        {
            var users = new List<ApplicationUser> { new ApplicationUser { Id = It.IsAny<string>() }, new ApplicationUser { Id = It.IsAny<string>() }};
            var viewModel = new IndexViewModel { Users = users };

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<IndexQuery>())).ReturnsAsync(viewModel);

            var controller = new SiteController(null, null, mediator.Object);
            var result = await controller.Index() as ViewResult;
            var model = result.ViewData.Model as IndexViewModel;
            
            Assert.Equal(model.Users.Count(), users.Count());
            Assert.IsType<IndexViewModel>(model);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:15,代码来源:SiteAdminControllerShould.cs


示例5: IndexReturnsCorrectViewModel

        public void IndexReturnsCorrectViewModel()
        {

            var mediator = new Mock<IMediator>();
            var users = new List<ApplicationUser>() {
                new ApplicationUser {
                    Id = It.IsAny<string>()
                },
                new ApplicationUser {
                    Id = It.IsAny<string>()
                }
            };
            mediator.Setup(x => x.Send(It.IsAny<AllUsersQuery>())).Returns(users);

            var controller = new SiteController(null, null, mediator.Object);
            var result = controller.Index();
            var model = ((ViewResult)result).ViewData.Model as SiteAdminModel;
            
            Assert.Equal(model.Users.Count(), users.Count());
            Assert.IsType<SiteAdminModel>(model);
        }
开发者ID:yobenzima,项目名称:allReady,代码行数:21,代码来源:SiteAdminControllerShould.cs


示例6: EditUserPostHasValidateAntiForgeryTokenAttribute

 public void EditUserPostHasValidateAntiForgeryTokenAttribute()
 {
     var controller = new SiteController(null, null, null);
     var attribute = controller.GetAttributesOn(x => x.EditUser(It.IsAny<EditUserModel>())).OfType<ValidateAntiForgeryTokenAttribute>().SingleOrDefault();
     Assert.NotNull(attribute);
 }
开发者ID:yobenzima,项目名称:allReady,代码行数:6,代码来源:SiteAdminControllerShould.cs


示例7: EditUserGetReturnsCorrectViewModelWhenOrganizationIdIsNull

        public void EditUserGetReturnsCorrectViewModelWhenOrganizationIdIsNull()
        {
            {
                var mediator = new Mock<IMediator>();                

                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, null, mediator.Object);

                var result = controller.EditUser(userId);
                var model = ((ViewResult)result).ViewData.Model as EditUserModel;

                Assert.Equal(model.Organization, null);
                Assert.IsType<EditUserModel>(model);
            }
        }
开发者ID:yobenzima,项目名称:allReady,代码行数:17,代码来源:SiteAdminControllerShould.cs


示例8: ConfirmDeletUserInvokesFindByIdAsync

        public async Task ConfirmDeletUserInvokesFindByIdAsync()
        {
            const string userId = "userId";
            var userManager = CreateApplicationUserMock();

            var controller = new SiteController(userManager.Object, null, null);
            
            await controller.ConfirmDeleteUser(userId);
            userManager.Verify(x => x.FindByIdAsync(userId), Times.Once);
        }
开发者ID:yobenzima,项目名称:allReady,代码行数:10,代码来源:SiteAdminControllerShould.cs


示例9: RevokeOrganizationAdminHasHttpGetAttribute

 public void RevokeOrganizationAdminHasHttpGetAttribute()
 {
     var controller = new SiteController(null, null,null);
     var attribute = controller.GetAttributesOn(x => x.RevokeOrganizationAdmin(It.IsAny<string>())).OfType<HttpGetAttribute>().SingleOrDefault();
     Assert.NotNull(attribute);
 }
开发者ID:yobenzima,项目名称:allReady,代码行数:6,代码来源:SiteAdminControllerShould.cs


示例10: AssignSiteAdminRedirectsToCorrectAction

        public async Task AssignSiteAdminRedirectsToCorrectAction()
        {
            var mediator = new Mock<IMediator>();
            var userManager = CreateApplicationUserMock();
            var user = new ApplicationUser()
            {
                Id = "1234"
            };

            mediator.Setup(x => x.Send(It.Is<UserByUserIdQuery>(q => q.UserId == user.Id)))
                .Returns(user);
            userManager.Setup(x => x.AddClaimAsync(It.IsAny<ApplicationUser>(), It.IsAny<Claim>()))
                .Returns(() => Task.FromResult(IdentityResult.Success));

            var controller = new SiteController(userManager.Object, null, mediator.Object);
            var result = (RedirectToActionResult) await controller.AssignSiteAdmin(user.Id);
            Assert.Equal("Index", result.ActionName);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:18,代码来源:SiteAdminControllerShould.cs


示例11: SearchForCorrectUserWhenGeneratingApiKeys

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

            string userId = Guid.NewGuid().ToString();
            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.GenerateToken(userId);
            mediator.Verify(m => m.Send(It.Is<UserByUserIdQuery>(q => q.UserId == userId)), Times.Once);
        }
开发者ID:yobenzima,项目名称:allReady,代码行数:12,代码来源:SiteAdminControllerShould.cs


示例12: AssignOrganizationAdminGetAddsCorrectSelectListItemToOrganizationsOnViewBag

        public void AssignOrganizationAdminGetAddsCorrectSelectListItemToOrganizationsOnViewBag()
        {
            var mediator = new Mock<IMediator>();
            var user = new ApplicationUser()
            {
                Id = "1234"
            };
            mediator.Setup(x => x.Send(It.Is<UserByUserIdQuery>(q => q.UserId == user.Id)))
                .Returns(user);
            List<Organization> orgs = new List<Organization>();
            orgs.Add(new Organization() { Id = 2, Name = "Borg" });
            orgs.Add(new Organization() { Id = 1, Name = "Aorg" });
            mediator.Setup(x => x.Send(It.IsAny<AllOrganizationsQuery>())).Returns(orgs);
            var controller = new SiteController(null, null, mediator.Object);
            var result = controller.AssignOrganizationAdmin(user.Id);

            List<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem> viewBagOrgs = 
                ((IEnumerable<Microsoft.AspNetCore.Mvc.Rendering.SelectListItem>)controller.ViewBag.Organizations).ToList();

            Assert.Equal(3, viewBagOrgs.Count);
            Assert.Equal("0", viewBagOrgs[0].Value); // Select One item added in controller
            Assert.Equal("1", viewBagOrgs[1].Value); // sorted items
            Assert.Equal("2", viewBagOrgs[2].Value);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:24,代码来源:SiteAdminControllerShould.cs


示例13: AssignOrganizationAdminGetSendsAllOrganizationsQuery

        public void AssignOrganizationAdminGetSendsAllOrganizationsQuery()
        {
            var mediator = new Mock<IMediator>();
            var user = new ApplicationUser()
            {
                Id = "1234"
            };
            mediator.Setup(x => x.Send(It.Is<UserByUserIdQuery>(q => q.UserId == user.Id)))
                .Returns(user);

            var controller = new SiteController(null, null, mediator.Object);
            var result = controller.AssignOrganizationAdmin(user.Id);
            mediator.Verify(m => m.Send(It.IsAny<AllOrganizationsQuery>()), Times.Once);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:14,代码来源:SiteAdminControllerShould.cs


示例14: AssignOrganizationAdminGetRedirectsToCorrectActionWhenUserIsASiteAdmin

        public void AssignOrganizationAdminGetRedirectsToCorrectActionWhenUserIsASiteAdmin()
        {
            var mediator = new Mock<IMediator>();
            var user = new ApplicationUser()
            {
                Id = "1234"
            };
            user.Claims.Add(new Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityUserClaim<string>()
            {
                ClaimType = AllReady.Security.ClaimTypes.UserType,
                ClaimValue = Enum.GetName(typeof(UserType), UserType.SiteAdmin)
            });

            mediator.Setup(x => x.Send(It.Is<UserByUserIdQuery>(q => q.UserId == user.Id)))
                .Returns(user);

            var controller = new SiteController(null, null, mediator.Object);
            var result = (RedirectToActionResult)controller.AssignOrganizationAdmin(user.Id);
            Assert.Equal("Index", result.ActionName);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:20,代码来源:SiteAdminControllerShould.cs


示例15: AssignOrganizationAdminGetSendsUserByUserIdQueryWithCorrectUserId

 public void AssignOrganizationAdminGetSendsUserByUserIdQueryWithCorrectUserId()
 {
     var mediator = new Mock<IMediator>();
     string userId = "1234";
     var controller = new SiteController(null, null, mediator.Object);
     controller.AssignOrganizationAdmin(userId);
     mediator.Verify(m => m.Send(It.Is<UserByUserIdQuery>(q => q.UserId == userId)), Times.Once);
 }
开发者ID:mheggeseth,项目名称:allReady,代码行数:8,代码来源:SiteAdminControllerShould.cs


示例16: AssignSiteAdminReturnsAViewWhenExceptionIsThrown

        public async Task AssignSiteAdminReturnsAViewWhenExceptionIsThrown()
        {
            var mediator = new Mock<IMediator>();
            var logger = new Mock<ILogger<SiteController>>();
            var userManager = CreateApplicationUserMock();
            var user = new ApplicationUser()
            {
                Id = "1234"
            };

            mediator.Setup(x => x.Send(It.Is<UserByUserIdQuery>(q => q.UserId == user.Id)))
                .Throws<Exception>();

            var controller = new SiteController(userManager.Object, logger.Object, mediator.Object);
            var result = await controller.AssignSiteAdmin(user.Id);
            Assert.IsType<ViewResult>(result);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:17,代码来源:SiteAdminControllerShould.cs


示例17: AssignSiteAdminAddsCorrectErrorMessageToViewBagWhenExceptionIsThrown

        public async Task AssignSiteAdminAddsCorrectErrorMessageToViewBagWhenExceptionIsThrown()
        {
            var mediator = new Mock<IMediator>();
            var logger = new Mock<ILogger<SiteController>>();
            var userManager = CreateApplicationUserMock();
            var user = new ApplicationUser()
            {
                Id = "1234"
            };

            mediator.Setup(x => x.Send(It.Is<UserByUserIdQuery>(q => q.UserId == user.Id)))
                .Throws<Exception>();

            var controller = new SiteController(userManager.Object, logger.Object, mediator.Object);
            var result = await controller.AssignSiteAdmin(user.Id);

            Assert.Equal($"Failed to assign site admin for {user.Id}. Exception thrown.", controller.ViewBag.ErrorMessage);
        }
开发者ID:mheggeseth,项目名称:allReady,代码行数:18,代码来源:SiteAdminControllerShould.cs


示例18: AssignSiteAdminInvokesLogErrorWhenExceptionIsThrown

        public async Task AssignSiteAdminInvokesLogErrorWhenExceptionIsThrown()
        {
            var mediator = new Mock<IMediator>();
            var logger = new Mock<ILogger<SiteController>>();
            var user = new ApplicationUser()
            {
                Id = "1234"
            };

            mediator.Setup(x => x.Send(It.Is<UserByUserIdQuery>(q => q.UserId == user.Id)))
                .Throws<Exception>();

            var controller = new SiteController(null, logger.Object, mediator.Object);
            var result = await controller.AssignSiteAdmin(user.Id);

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


示例19: AssignApiRoleQueriesForCorrectId

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

            string userId = Guid.NewGuid().ToString();
            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.AssignApiAccessRole(userId);
            mediator.Verify(m => m.Send(It.Is<UserByUserIdQuery>(q => q.UserId == userId)), Times.Once);
        }
开发者ID:yobenzima,项目名称:allReady,代码行数:12,代码来源:SiteAdminControllerShould.cs


示例20: AssignOrganizationAdminPostHasHttpPostAttribute

        public void AssignOrganizationAdminPostHasHttpPostAttribute()
        {
            var mediator = new Mock<IMediator>();
            var controller = new SiteController(null, null, mediator.Object);

            var model = new AssignOrganizationAdminModel { UserId = It.IsAny<string>(), OrganizationId = It.IsAny<int>() };

            var attribute = controller.GetAttributesOn(x => x.AssignOrganizationAdmin(model)).OfType<HttpPostAttribute>().SingleOrDefault();

            Assert.NotNull(attribute);
        }
开发者ID:yobenzima,项目名称:allReady,代码行数:11,代码来源:SiteAdminControllerShould.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Controllers.TaskController类代码示例发布时间:2022-05-24
下一篇:
C# Controllers.ItineraryController类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap