當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。