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


C# DataBase.ItemTypeInsert方法代码示例

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


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

示例1: GetItemByType

        public void GetItemByType()
        {
            DataBase dataBase = new DataBase();
            string itemTypeName1 = Guid.NewGuid().ToString();
            string itemTypeName2 = Guid.NewGuid().ToString();
            string itemTypeName3 = Guid.NewGuid().ToString();
            int rowsInserted =
                dataBase.ItemTypeInsert(new ItemType {Name = itemTypeName1, Description = "item type description 1",});
            Assert.AreEqual(1, rowsInserted);
            rowsInserted =
                dataBase.ItemTypeInsert(new ItemType {Name = itemTypeName2, Description = "item type description 2",});
            Assert.AreEqual(1, rowsInserted);
            rowsInserted =
                dataBase.ItemTypeInsert(new ItemType {Name = itemTypeName3, Description = "item type description 3",});
            Assert.AreEqual(1, rowsInserted);
            List<ItemType> itemTypes = dataBase.ItemTypeGetAll();
            string itemName1 = Guid.NewGuid().ToString();
            string itemName2 = Guid.NewGuid().ToString();
            string itemName3 = Guid.NewGuid().ToString();

            int itemTypeId1 = itemTypes.Find(n => n.Name == itemTypeName1).Id;
            int itemTypeId2 = itemTypes.Find(n => n.Name == itemTypeName2).Id;
            int itemTypeId3 = itemTypes.Find(n => n.Name == itemTypeName3).Id;
            rowsInserted =
                dataBase.ItemInsert(new Item
                                    {
                                        Name = itemName1,
                                        Description = "item description 1",
                                        ItemTypeId = itemTypeId1,
                                    });
            Assert.AreEqual(1, rowsInserted);
            rowsInserted =
                dataBase.ItemInsert(new Item
                                    {
                                        Name = itemName2,
                                        Description = "item description 2",
                                        ItemTypeId = itemTypeId2,
                                    });
            Assert.AreEqual(1, rowsInserted);
            rowsInserted =
                dataBase.ItemInsert(new Item
                                    {
                                        Name = itemName3,
                                        Description = "item description 3",
                                        ItemTypeId = itemTypeId2,
                                    });
            Assert.AreEqual(1, rowsInserted);
            List<Item> items = dataBase.ItemGetByType(itemTypeId1);
            Assert.IsNotNull(items);
            Assert.IsTrue(items.Count == 1, "Expected: {0}, Actual:{1}", 1, items.Count);
            items = dataBase.ItemGetByType(itemTypeId2);
            Assert.IsNotNull(items);
            Assert.IsTrue(items.Count == 2, "Expected: {0}, Actual:{1}", 2, items.Count);
            items = dataBase.ItemGetByType(itemTypeId3);
            Assert.IsNotNull(items);
            Assert.IsTrue(items.Count == 0, "Expected: {0}, Actual:{1}", 0, items.Count);
        }
开发者ID:trippleflux,项目名称:jezatools,代码行数:57,代码来源:DataBaseTests.cs

示例2: OrderGetAll

 public void OrderGetAll()
 {
     DataBase dataBase = new DataBase();
     string itemTypeName = Guid.NewGuid().ToString();
     ItemType itemType = new ItemType {Name = itemTypeName,};
     dataBase.ItemTypeInsert(itemType);
     ItemType itemTypeGet = dataBase.ItemTypeGet(itemTypeName);
     Assert.IsNotNull(itemTypeGet);
     string itemName = Guid.NewGuid().ToString();
     Item item = new Item
                 {
                     Name = itemName,
                     ItemTypeId = itemTypeGet.Id,
                 };
     dataBase.ItemInsert(item);
     Item itemGet = dataBase.ItemGet(itemName);
     Assert.IsNotNull(itemGet);
     string itemStatusName = Guid.NewGuid().ToString();
     ItemStatus itemStatus = new ItemStatus {Name = itemStatusName};
     dataBase.ItemStatusInsert(itemStatus);
     ItemStatus itemStatusGet = dataBase.ItemStatusGet(itemStatusName);
     Assert.IsNotNull(itemStatusGet);
     string personInfoName = Guid.NewGuid().ToString();
     string personInfoSurName = Guid.NewGuid().ToString();
     PersonInfo personInfo = new PersonInfo {Name = personInfoName, SurName = personInfoSurName,};
     dataBase.PersonInfoInsert(personInfo);
     PersonInfo personInfoGet = dataBase.PersonInfoGet(personInfoName, personInfoSurName);
     Assert.IsNotNull(personInfoGet);
     Order order = new Order
                   {
                       ItemId = itemGet.Id,
                       Count = 1,
                       ItemStatusId = itemStatusGet.Id,
                       LegalEntity = true,
                       PersonInfoId = personInfoGet.Id,
                       Postage = 0M.DecimalToString(),
                       Price = 1M.DecimalToString(),
                       BankId = -1,
                   };
     int rowsInserted = dataBase.OrderInsert(order);
     Assert.AreEqual(1, rowsInserted);
     List<Order> orders = dataBase.OrderGetAll();
     Assert.IsNotNull(orders);
     Order find = orders.Find(o => o.ItemId == itemGet.Id);
     Assert.IsNotNull(find);
 }
开发者ID:trippleflux,项目名称:jezatools,代码行数:46,代码来源:OrdersTest.cs

示例3: UpdateItemType

 public void UpdateItemType()
 {
     DataBase dataBase = new DataBase();
     string itemTypeName = Guid.NewGuid().ToString();
     ItemType itemType = new ItemType {Name = itemTypeName, Description = "hula bula...",};
     int rowsInserted = dataBase.ItemTypeInsert(itemType);
     Assert.AreEqual(1, rowsInserted, "Item type not inserted!");
     List<ItemType> list = dataBase.ItemTypeGetAll();
     Assert.IsNotNull(list);
     ItemType find = list.Find(i => i.Name == itemTypeName);
     Assert.IsNotNull(find);
     string newName = Guid.NewGuid().ToString();
     find.Name = newName;
     int rowsUpdated = dataBase.ItemTypeUpdate(find);
     Assert.AreEqual(1, rowsUpdated);
     ItemType updatedItemType = dataBase.ItemTypeGet(find.Id);
     Assert.AreEqual(newName, updatedItemType.Name);
     Assert.AreEqual(itemType.Description, updatedItemType.Description);
 }
开发者ID:trippleflux,项目名称:jezatools,代码行数:19,代码来源:DataBaseTests.cs

示例4: InsertItemType

 public void InsertItemType()
 {
     DataBase dataBase = new DataBase();
     string itemTypeName = Guid.NewGuid().ToString();
     ItemType itemType = new ItemType {Name = itemTypeName, Description = "hula bula...",};
     int rowsInserted = dataBase.ItemTypeInsert(itemType);
     Assert.AreEqual(1, rowsInserted, "Item type not inserted!");
 }
开发者ID:trippleflux,项目名称:jezatools,代码行数:8,代码来源:DataBaseTests.cs


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