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


C# Controllers.SiteController类代码示例

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


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


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