本文整理汇总了C#中AllReady.Areas.Admin.Controllers.SiteController.Index方法的典型用法代码示例。如果您正苦于以下问题:C# SiteController.Index方法的具体用法?C# SiteController.Index怎么用?C# SiteController.Index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AllReady.Areas.Admin.Controllers.SiteController
的用法示例。
在下文中一共展示了SiteController.Index方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}