コード例 #1
0
        public void TestAddItemCategory_正确添加()
        {
            string id = "c2ecf0ef-dc5b-4308-9f38-047453d53919";

            #region 验证前置条件

            MSSql2005Query query = new MSSql2005Query();
            string sqlQuery = query.GenerateSelectViewSql(typeof(ItemCategoryInfo));
            sqlQuery += string.Format("WHERE [Id] = N'{0}'", id);
            using (DbOperator dbOperator = new DbOperator(connString))
            {
                DataTable dt = dbOperator.GetTable(sqlQuery);

                Assert.AreEqual(0, dt.Rows.Count);
            }

            #endregion

            ItemCategoryFacade facade = new ItemCategoryFacade();
            string idNew = facade.AddItemCategory(id, "50011665", "0", "网游装备/游戏币/帐号/代练", false, "normal", 0);

            #region 验证后置条件

            Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-047453d53919", idNew, true);

            using (DbOperator dbOperator = new DbOperator(connString))
            {
                DataTable dt = dbOperator.GetTable(sqlQuery);

                Assert.AreEqual(1, dt.Rows.Count);
                Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-047453d53919", dt.Rows[0]["Id"].ToString(), true);
                Assert.AreEqual("50011665", dt.Rows[0]["CategoryId"].ToString(), true);
                Assert.AreEqual("0", dt.Rows[0]["ParentId"].ToString(), true);
                Assert.AreEqual("网游装备/游戏币/帐号/代练", dt.Rows[0]["Name"].ToString(), true);
                Assert.AreEqual("false", dt.Rows[0]["IsParent"].ToString(), true);
                Assert.AreEqual("normal", dt.Rows[0]["Status"].ToString(), true);
                Assert.AreEqual("0", dt.Rows[0]["SortOrder"].ToString(), true);
            }

            #endregion
        }
コード例 #2
0
        public void TestIsItemCategoryExist_不存在的情况()
        {
            ItemCategoryFacade facade = new ItemCategoryFacade();
            bool isExist = facade.IsItemCategoryExist("50011665");

            Assert.AreEqual(false, isExist);
        }
コード例 #3
0
        public void TestIsItemCategoryExist_已经存在的情况()
        {
            #region 验证前置条件

            ItemCategory category = new ItemCategory();
            category.Id = "c2ecf0ef-dc5b-4308-9f38-047453d53919";
            category.CategoryId = "50011665";
            ItemCategoryManager manager = new ItemCategoryManager();
            string sqlCreate = manager.GetCreateSql(category);
            using (DbOperator dbOperator = new DbOperator(connString))
            {
                dbOperator.ExecSql(sqlCreate);
            }

            #endregion

            ItemCategoryFacade facade = new ItemCategoryFacade();
            bool isExist = facade.IsItemCategoryExist("50011665");

            Assert.AreEqual(true, isExist);
        }
コード例 #4
0
        public void TestGetItemCategory_不存在的情况()
        {
            ItemCategoryFacade facade = new ItemCategoryFacade();
            ItemCategoryInfo categoryInfo = facade.GetItemCategoryById("50011665");

            #region 验证后置条件

            Assert.IsNull(categoryInfo);

            #endregion
        }
コード例 #5
0
        public void TestGetItemCategory_已经存在的情况()
        {
            #region 验证前置条件

            ItemCategory category = new ItemCategory();
            category.Id = "c2ecf0ef-dc5b-4308-9f38-047453d53919";
            category.CategoryId = "50011665";
            category.Name = "测试类目";
            category.ParentId = "0";
            category.IsParent = true;
            category.SortOrder = 1;
            category.Status = "normal";
            ItemCategoryManager manager = new ItemCategoryManager();
            string sqlCreate = manager.GetCreateSql(category);
            using (DbOperator dbOperator = new DbOperator(connString))
            {
                dbOperator.ExecSql(sqlCreate);
            }

            #endregion

            ItemCategoryFacade facade = new ItemCategoryFacade();
            ItemCategoryInfo categoryInfo = facade.GetItemCategoryById("50011665");

            #region 验证后置条件

            Assert.IsNotNull(categoryInfo);
            Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-047453d53919", categoryInfo.Id);
            Assert.AreEqual("50011665", categoryInfo.CategoryId);
            Assert.AreEqual("测试类目", categoryInfo.Name);
            Assert.AreEqual("0", categoryInfo.ParentId);
            Assert.AreEqual(true, categoryInfo.IsParent);
            Assert.AreEqual(1, categoryInfo.SortOrder);
            Assert.AreEqual("normal", categoryInfo.Status);

            #endregion
        }
コード例 #6
0
        public void TestGetItemCategoryListByParent_父子数据情况()
        {
            #region 验证前置条件

            ItemCategory category1 = new ItemCategory();
            category1.Id = "c2ecf0ef-dc5b-4308-9f38-047453d53919";
            category1.CategoryId = "50011665";
            category1.Name = "测试类目1";
            category1.ParentId = "0";
            category1.IsParent = true;
            category1.SortOrder = 1;
            category1.Status = "normal";

            ItemCategory category2 = new ItemCategory();
            category2.Id = "c2ecf0ef-dc5b-4308-9f38-047453d53929";
            category2.CategoryId = "50011667";
            category2.Name = "测试类目2";
            category2.ParentId = "50011665";
            category2.IsParent = true;
            category2.SortOrder = 0;
            category2.Status = "deleted";

            ItemCategoryManager manager = new ItemCategoryManager();
            string sqlCreate1 = manager.GetCreateSql(category1);
            string sqlCreate2 = manager.GetCreateSql(category2);

            using (DbOperator dbOperator = new DbOperator(connString))
            {
                dbOperator.ExecSql(sqlCreate1);
                dbOperator.ExecSql(sqlCreate2);
            }

            #endregion

            ItemCategoryFacade facade = new ItemCategoryFacade();

            #region 验证后置条件

            List<ItemCategoryInfo> list1 = facade.GetItemCategoryListByParent(string.Empty);

            Assert.AreEqual(1, list1.Count);
            ItemCategoryInfo categoryInfo1 = list1[0];
            Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-047453d53919", categoryInfo1.Id);
            Assert.AreEqual("50011665", categoryInfo1.CategoryId);
            Assert.AreEqual("测试类目1", categoryInfo1.Name);
            Assert.AreEqual("0", categoryInfo1.ParentId);
            Assert.AreEqual(true, categoryInfo1.IsParent);
            Assert.AreEqual(1, categoryInfo1.SortOrder);
            Assert.AreEqual("normal", categoryInfo1.Status);

            List<ItemCategoryInfo> list2 = facade.GetItemCategoryListByParent("50011665");

            ItemCategoryInfo categoryInfo2 = list2[0];
            Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-047453d53929", categoryInfo2.Id);
            Assert.AreEqual("50011667", categoryInfo2.CategoryId);
            Assert.AreEqual("测试类目2", categoryInfo2.Name);
            Assert.AreEqual("50011665", categoryInfo2.ParentId);
            Assert.AreEqual(true, categoryInfo2.IsParent);
            Assert.AreEqual(0, categoryInfo2.SortOrder);
            Assert.AreEqual("deleted", categoryInfo2.Status);

            #endregion
        }
コード例 #7
0
        public void TestGetItemCategoryListByParent_没有数据()
        {
            ItemCategoryFacade facade = new ItemCategoryFacade();
            List<ItemCategoryInfo> list = facade.GetItemCategoryListByParent(string.Empty);

            Assert.AreEqual(0, list.Count);
        }
コード例 #8
0
        public void TestGetItemCategoryListByParent_有一条根数据()
        {
            #region 验证前置条件

            ItemCategory category = new ItemCategory();
            category.Id = "c2ecf0ef-dc5b-4308-9f38-047453d53919";
            category.CategoryId = "50011665";
            category.Name = "测试类目";
            category.ParentId = "0";
            category.IsParent = true;
            category.SortOrder = 1;
            category.Status = "normal";
            ItemCategoryManager manager = new ItemCategoryManager();
            string sqlCreate = manager.GetCreateSql(category);
            using (DbOperator dbOperator = new DbOperator(connString))
            {
                dbOperator.ExecSql(sqlCreate);
            }

            #endregion

            ItemCategoryFacade facade = new ItemCategoryFacade();
            List<ItemCategoryInfo> list = facade.GetItemCategoryListByParent(string.Empty);

            #region 验证后置条件

            Assert.AreEqual(1, list.Count);
            Assert.AreEqual("c2ecf0ef-dc5b-4308-9f38-047453d53919", list[0].Id);
            Assert.AreEqual("50011665", list[0].CategoryId);
            Assert.AreEqual("测试类目", list[0].Name);
            Assert.AreEqual("0", list[0].ParentId);
            Assert.AreEqual(true, list[0].IsParent);
            Assert.AreEqual(1, list[0].SortOrder);
            Assert.AreEqual("normal", list[0].Status);

            #endregion
        }
コード例 #9
0
        private int UpdateSubItemCategories(string parentId)
        {
            ItemCategoryFacade localFacade = new ItemCategoryFacade();
            localFacade.DeleteItemCategoryByParentId(parentId);

            CategoryFacade topFacade = new CategoryFacade(varHelper.TOP_AppKey, varHelper.TOP_AppSecret);
            TOPDataList<ItemCategory> list = topFacade.GetItemCategories(parentId, string.Empty);
            foreach (ItemCategory category in list)
            {
                if (!localFacade.IsItemCategoryExist(category.Id))
                {
                    localFacade.AddItemCategory(string.Empty, category.Id, category.ParentId, category.Name, category.IsParent, category.Status, category.SortOrder);
                }
            }
            return list.Count;
        }
コード例 #10
0
 private void InitTreeNode(TreeViewNode node)
 {
     ItemCategoryFacade localFacade = new ItemCategoryFacade();
     List<ItemCategoryInfo> list = localFacade.GetItemCategoryListByParent(node.Value);
     node.Nodes.Clear();
     foreach (ItemCategoryInfo item in list)
     {
         TreeViewNode sub = GetNodeByItemCategory(item);
         node.Nodes.Add(sub);
     }
     if (node.Nodes.Count == 0)
     {
         AddNoneNode(node);
     }
     else
     {
         node.AutoPostBackOnExpand = false;
     }
 }