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


C# SelectList.GetType方法代码示例

本文整理汇总了C#中System.Web.Mvc.SelectList.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# SelectList.GetType方法的具体用法?C# SelectList.GetType怎么用?C# SelectList.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Mvc.SelectList的用法示例。


在下文中一共展示了SelectList.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EditBillTestLockError

        public void EditBillTestLockError()
        {
            // Arrange
            db = new touch_for_foodEntities();
            BillController target = new BillController();
            SelectList expectedOrderList = new SelectList(db.orders, "id", "id", bill1.order_id);
            ViewResult actual;
            bill1.version += 5;

            // Act
            actual = (ViewResult)target.Edit(bill1);

            // Assert
            SelectList actualOrderList = actual.ViewBag.order_id;
            Assert.AreEqual(expectedOrderList.GetType(), actualOrderList.GetType());
            Assert.AreEqual(expectedOrderList.Count(), actualOrderList.Count());

            string errorMsg = actual.ViewBag.Error;
            Assert.IsNotNull(errorMsg); //error message is sent to view
        }
开发者ID:pmoda,项目名称:TFFCode,代码行数:20,代码来源:BillControllerTest.cs

示例2: EditViewTest

        public void EditViewTest()
        {
            // Arrange
            db = new touch_for_foodEntities();
            int expected = request1.id;
            SelectList expectedTableList = new SelectList(db.tables, "id", "name", request1.table_id);
            ViewResult actual;

            // Act
            actual = (ViewResult)target.Edit(request1.id);

            // Assert
            Assert.AreEqual(expected, ((service_request)actual.ViewData.Model).id);

            SelectList actualTableList = actual.ViewBag.table_id;
            Assert.AreEqual(expectedTableList.GetType(), actualTableList.GetType());
            Assert.AreEqual(expectedTableList.Count(), actualTableList.Count());
        }
开发者ID:pmoda,项目名称:TFFCode,代码行数:18,代码来源:ServiceRequestControllerTest.cs

示例3: CreateViewTest

        public void CreateViewTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            BillController target = new BillController();
            SelectList orderList = new SelectList(db.orders, "id", "id");

            //Act
            var actual = (ViewResult)target.Create();

            //Assert
            Assert.AreEqual(orderList.GetType(), actual.ViewBag.order_id.GetType());
        }
开发者ID:pmoda,项目名称:TFFCode,代码行数:13,代码来源:BillControllerTest.cs

示例4: CreateTestInvalidStateModel

        public void CreateTestInvalidStateModel()
        {
            // Arrange
            db = new touch_for_foodEntities();
            Menu_ItemController target = new Menu_ItemController();
            target.ModelState.AddModelError("error", "ModelState is invalid");
            SelectList expectedItemList = new SelectList(db.items, "id", "name", menuItem2.item_id);
            SelectList expectedCategoryList = new SelectList(db.menu_category, "id", "id", menuItem2.menu_category_id);
            ViewResult actual;

            // Act
            actual = (ViewResult)target.Create(menuItem2);

            // Assert
            SelectList actualItemList = actual.ViewBag.item_id;
            Assert.AreEqual(expectedItemList.GetType(), actualItemList.GetType());
            Assert.AreEqual(expectedItemList.Count(), actualItemList.Count());

            SelectList actualCategoryList = actual.ViewBag.menu_category_id;
            Assert.AreEqual(expectedCategoryList.GetType(), actualCategoryList.GetType());
            Assert.AreEqual(expectedCategoryList.Count(), actualCategoryList.Count());

            string errorMsg = actual.ViewBag.Error;
            Assert.IsNotNull(errorMsg); //error message is sent to view
        }
开发者ID:pmoda,项目名称:TFFCode,代码行数:25,代码来源:Menu_ItemControllerTest.cs

示例5: EditTestLockFailure

        public void EditTestLockFailure()
        {
            // Arrange
            db = new touch_for_foodEntities();
            Menu_ItemController target = new Menu_ItemController();
            int expected = menuItem1.id;
            SelectList expectedItemList = new SelectList(db.items, "id", "name", menuItem1.item_id);
            SelectList expectedCategoryList = new SelectList(db.menu_category, "id", "id", menuItem1.menu_category_id);
            ViewResult actual;
            menuItem1.version += 5;

            // Act
            actual = (ViewResult)target.Edit(menuItem1);

            // Assert
            Assert.AreEqual(expected, ((menu_item)actual.ViewData.Model).id);

            SelectList actualItemList = actual.ViewBag.item_id;
            Assert.AreEqual(expectedItemList.GetType(), actualItemList.GetType());
            Assert.AreEqual(expectedItemList.Count(), actualItemList.Count());

            SelectList actualCategoryList = actual.ViewBag.menu_category_id;
            Assert.AreEqual(expectedCategoryList.GetType(), actualCategoryList.GetType());
            Assert.AreEqual(expectedCategoryList.Count(), actualCategoryList.Count());

            string errorMsg = actual.ViewBag.Error;
            Assert.IsNotNull(errorMsg); //error message is sent to view
        }
开发者ID:pmoda,项目名称:TFFCode,代码行数:28,代码来源:Menu_ItemControllerTest.cs

示例6: EditTestLockError

        public void EditTestLockError()
        {
            // Arrange
            db = new touch_for_foodEntities();
            Order_ItemController target = new Order_ItemController();
            int expected = orderItem1.id;
            orderItem1.version += 5;
            SelectList expectedMenuList = new SelectList(db.menu_item, "id", "id", orderItem1.menu_item_id);
            SelectList expectedOrderList = new SelectList(db.orders, "id", "id", orderItem1.order_id);
            ViewResult actual;

            // Act
            actual = (ViewResult)target.Edit(orderItem1);

            // Assert
            Assert.AreEqual(expected, ((order_item)actual.ViewData.Model).id);

            SelectList actualMenuList = actual.ViewBag.menu_item_id;
            Assert.AreEqual(expectedMenuList.GetType(), actualMenuList.GetType());
            Assert.AreEqual(expectedMenuList.Count(), actualMenuList.Count());

            SelectList actualOrderList = actual.ViewBag.order_id;
            Assert.AreEqual(expectedOrderList.GetType(), actualOrderList.GetType());
            Assert.AreEqual(expectedOrderList.Count(), actualOrderList.Count());

            string errorMsg = actual.ViewBag.Error;
            Assert.IsNotNull(errorMsg); //error message is sent to view
        }
开发者ID:pmoda,项目名称:TFFCode,代码行数:28,代码来源:Order_ItemControllerTest.cs

示例7: EditVersionErrorTest

        public void EditVersionErrorTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            Menu_CategoryController target = new Menu_CategoryController(db);
            SelectList mcList = new SelectList(db.categories, "id", "name", menuCategory1.category_id);
            SelectList menuList = new SelectList(db.menus, "id", "name", menuCategory1.menu_id);
            Assert.IsFalse(db.menu_category.Find(menuCategory1.id).is_active);
            menuCategory1.is_active = true;
            menuCategory1.version -= 1;

            //Act
            var actual = (ViewResult)target.Edit(menuCategory1);

            //Assert
            db = new touch_for_foodEntities();
            Assert.IsFalse(db.menu_category.Find(menuCategory1.id).is_active);
            Assert.AreEqual(mcList.GetType(), actual.ViewBag.category_id.GetType());
            Assert.AreEqual(menuList.GetType(), actual.ViewBag.menu_id.GetType());
            Assert.IsNotNull(actual.ViewBag.Error);
        }
开发者ID:pmoda,项目名称:TFFCode,代码行数:21,代码来源:Menu_CategoryControllerTest.cs

示例8: EditTableTestInvalidStateModel

        public void EditTableTestInvalidStateModel()
        {
            // Arrange
            db = new touch_for_foodEntities();
            target.ModelState.AddModelError("error", "ModelState is invalid");
            int expected = table1.id;
            SelectList expectedRestos = new SelectList(db.restaurants, "id", "name", table1.restaurant_id);
            ViewResult actual;

            // Act
            actual = (ViewResult)target.Edit(table1);

            // Assert
            Assert.AreEqual(expected, ((table)actual.ViewData.Model).id);

            SelectList actualRestos = actual.ViewBag.restaurant_id;
            Assert.AreEqual(expectedRestos.GetType(), actualRestos.GetType());
            Assert.AreEqual(expectedRestos.Count(), actualRestos.Count());

            string errorMsg = actual.ViewBag.Error;
            Assert.IsNotNull(errorMsg); //error message is sent to view
        }
开发者ID:pmoda,项目名称:TFFCode,代码行数:22,代码来源:TableControllerTest.cs

示例9: EditTest

        public void EditTest()
        {
            //Setup
            int expected = table1.id;
            SelectList expectedRestoList = new SelectList(db.restaurants, "id", "name", table1.restaurant_id);

            //Act
            ViewResult actual = (ViewResult)target.Edit(table1.id);

            //Assert
            Assert.AreEqual(((table)actual.Model).id, expected);
            Assert.AreEqual(expectedRestoList.GetType(), actual.ViewBag.restaurant_id.GetType());
            SelectList actualRestoList = actual.ViewBag.restaurant_id;
            Assert.AreEqual(expectedRestoList.Count(), actualRestoList.Count());
        }
开发者ID:pmoda,项目名称:TFFCode,代码行数:15,代码来源:TableControllerTest.cs

示例10: EditVersionErrorTest

        public void EditVersionErrorTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            SelectList expectedRestoList = new SelectList(db.restaurants, "id", "name", menu1.id);
            string changeString = "UnitTesting";
            menu1.version += 5;
            menu1.name = changeString;

            //Act
            var actual = target.Edit(menu1) as ViewResult;

            //Assert
            db = new touch_for_foodEntities();
            Assert.IsFalse(db.menus.Find(menu1.id).name.Equals(changeString));
            Assert.AreEqual(((menu)actual.Model).id, menu1.id);
            Assert.AreEqual(expectedRestoList.GetType(), actual.ViewBag.resto_id.GetType());
            SelectList actualRestoList = actual.ViewBag.resto_id;
            Assert.AreEqual(expectedRestoList.Count(), actualRestoList.Count());
        }
开发者ID:pmoda,项目名称:TFFCode,代码行数:20,代码来源:MenuControllerTest.cs

示例11: EditViewTest

        public void EditViewTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            SelectList expectedRestoList = new SelectList(db.restaurants, "id", "name", menu1.id);

            //Act
            ViewResult actual = (ViewResult)target.Edit(menu1.id);

            //Assert
            Assert.AreEqual(((menu)actual.Model).id, menu1.id);
            Assert.AreEqual(expectedRestoList.GetType(), actual.ViewBag.resto_id.GetType());
            SelectList actualRestoList = actual.ViewBag.resto_id;
            Assert.AreEqual(expectedRestoList.Count(), actualRestoList.Count());
        }
开发者ID:pmoda,项目名称:TFFCode,代码行数:15,代码来源:MenuControllerTest.cs

示例12: CreateViewTest

        public void CreateViewTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            SelectList expectedRestoList = new SelectList(db.restaurants, "id", "name", db.restaurants.First().id);

            //Act
            ViewResult actual = (ViewResult)target.Create();

            //Assert
            Assert.AreEqual(expectedRestoList.GetType(), actual.ViewBag.resto_id.GetType());
            SelectList actualRestoList = actual.ViewBag.resto_id;
            Assert.AreEqual(expectedRestoList.Count(), actualRestoList.Count());
        }
开发者ID:pmoda,项目名称:TFFCode,代码行数:14,代码来源:MenuControllerTest.cs

示例13: CreateTestInvalidStateModel

        public void CreateTestInvalidStateModel()
        {
            // Arrange
            db = new touch_for_foodEntities();
            target.ModelState.AddModelError("error", "ModelState is invalid");
            SelectList expectedRestoList = new SelectList(db.restaurants, "id", "name", menu1.resto_id);
            ViewResult actual;

            // Act
            actual = (ViewResult)target.Create(menu1);

            // Assert
            SelectList actualRestoList = actual.ViewBag.resto_id;
            Assert.AreEqual(expectedRestoList.GetType(), actualRestoList.GetType());
            Assert.AreEqual(expectedRestoList.Count(), actualRestoList.Count());

            string errorMsg = actual.ViewBag.Error;
            Assert.IsNotNull(errorMsg); //error message is sent to view
        }
开发者ID:pmoda,项目名称:TFFCode,代码行数:19,代码来源:MenuControllerTest.cs

示例14: CreateViewTest

        public void CreateViewTest()
        {
            //Arrange
            db = new touch_for_foodEntities();
            RestaurantUserController target = new RestaurantUserController();
            SelectList expectedRestoList = new SelectList(db.restaurants, "id", "name");
            SelectList expectedUsersList = new SelectList(db.users.Where(u => u.user_role == (int)SiteRoles.Restaurant
                || u.user_role == (int)SiteRoles.Admin), "id", "username");
            ViewResult actual;

            //Act
            actual = (ViewResult)target.Create();

            //Assert
            SelectList actualRestoList = actual.ViewBag.restaurant_id;
            Assert.AreEqual(expectedRestoList.GetType(), actualRestoList.GetType());
            Assert.AreEqual(expectedRestoList.Count(), actualRestoList.Count());

            SelectList actualUserList = actual.ViewBag.user_id;
            Assert.AreEqual(expectedUsersList.GetType(), actualUserList.GetType());
            Assert.AreEqual(expectedUsersList.Count(), actualUserList.Count());
        }
开发者ID:pmoda,项目名称:TFFCode,代码行数:22,代码来源:RestaurantUserControllerTest.cs

示例15: CreateTestInvalidStateModel

        public void CreateTestInvalidStateModel()
        {
            // Arrange
            db = new touch_for_foodEntities();
            Order_ItemController target = new Order_ItemController();
            target.ModelState.AddModelError("error", "ModelState is invalid");
            SelectList expectedMenuList = new SelectList(db.menu_item, "id", "id", orderItem3.menu_item_id);
            SelectList expectedOrderList = new SelectList(db.orders, "id", "id", orderItem3.order_id);
            ViewResult actual;

            // Act
            actual = (ViewResult)target.Create(orderItem3);

            // Assert
            SelectList actualMenuList = actual.ViewBag.menu_item_id;
            Assert.AreEqual(expectedMenuList.GetType(), actualMenuList.GetType());
            Assert.AreEqual(expectedMenuList.Count(), actualMenuList.Count());

            SelectList actualOrderList = actual.ViewBag.order_id;
            Assert.AreEqual(expectedOrderList.GetType(), actualOrderList.GetType());
            Assert.AreEqual(expectedOrderList.Count(), actualOrderList.Count());

            string errorMsg = actual.ViewBag.Error;
            Assert.IsNotNull(errorMsg); //error message is sent to view
        }
开发者ID:pmoda,项目名称:TFFCode,代码行数:25,代码来源:Order_ItemControllerTest.cs


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