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


C# AdminController.Index方法代码示例

本文整理汇总了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.");
        }
开发者ID:Narelle,项目名称:ASPWD2,代码行数:20,代码来源:AdminControllerTest.cs

示例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);
 }
开发者ID:TimHanes,项目名称:OB,代码行数:22,代码来源:AdminTests.cs

示例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);
 }
开发者ID:kademat,项目名称:FoodStore,代码行数:20,代码来源:AdminTests.cs


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