本文整理汇总了C#中AdminController.Index方法的典型用法代码示例。如果您正苦于以下问题:C# AdminController.Index方法的具体用法?C# AdminController.Index怎么用?C# AdminController.Index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdminController
的用法示例。
在下文中一共展示了AdminController.Index方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AdminController_Index_Action_Should_Fetch_Surveys_From_Repo
public void AdminController_Index_Action_Should_Fetch_Surveys_From_Repo()
{
// arrange
var repositoryStub = MockRepository.GenerateStub<IRepository>();
var sut = new AdminController(repositoryStub);
var vm = new AdminViewModel();
var s = new List<Survey>();
repositoryStub
.Stub(x => x.GetUnapprovedSurveys())
.Return(s);
// act
var actual = sut.Index();
// assert
var viewResult = (ViewResult)actual;
Assert.AreEqual(vm, viewResult.ViewData.Model as AdminViewModel);
Assert.AreEqual("selected", sut.ViewData["Selected_Admin"], "Selected tab was incorrect.");
}
示例2: Index_Contains_All_Clients
public void Index_Contains_All_Clients()
{
// Arrange - create the mock repository
Mock<IClientRepository> mock = new Mock<IClientRepository>();
mock.Setup(m => m.Clients)
.Returns(new Client[]
{
new Client {ClientId = 1, ContractNumber = "C1"},
new Client {ClientId = 2, ContractNumber = "C2"},
new Client {ClientId = 3, ContractNumber = "C3"}
}
.AsQueryable());
// Arrange - create a controller
AdminController target = new AdminController(mock.Object);
// Action
Client[] result = ((IEnumerable<Client>)target.Index().ViewData.Model).ToArray();
// Assert
Assert.AreEqual(result.Length, 3);
Assert.AreEqual("C1", result[0].ContractNumber);
Assert.AreEqual("C2", result[1].ContractNumber);
Assert.AreEqual("C3", result[2].ContractNumber);
}
示例3: Index_Contains_All_Products
public void Index_Contains_All_Products()
{
// Arrange - create the mock repository
Mock<IProductRepository> mock = new Mock<IProductRepository>();
mock.Setup(m => m.Products).Returns(new Product[]
{
new Product {ProductID = 1, Name = "P1"},
new Product {ProductID = 2, Name = "P2"},
new Product {ProductID = 3, Name = "P3"},
});
// Arrange - create a controller
AdminController target = new AdminController(mock.Object);
// Action
Product[] result = ((IEnumerable<Product>) target.Index().ViewData.Model).ToArray();
// Assert
Assert.AreEqual(result.Length, 3);
Assert.AreEqual("P1", result[0].Name);
Assert.AreEqual("P2", result[1].Name);
Assert.AreEqual("P3", result[2].Name);
}