Exemple #1
0
    private static void deleteTag()
    {
        output += "deleteTag\n";

        List <int> list = User2TagManager.getTagListByUserId(sampleUser);

        foreach (int id in list)
        {
            User2Tag u2t2 = new User2Tag(sampleUser.UserId, id);
            if (!FocusAndCreateTag.deleteTag(u2t2))
            {
                output += "Error! 删除User2Tag记录失败!\n";
                errorCount++;
            }
            else
            {
                output += "Ok! 删除User2Tag记录成功!\n";
            }
        }
        List <int> list2 = User2TagManager.getTagListByUserId(sampleUser);

        int list2_len = 0;

        if (list2 != null)
        {
            list2_len = list2.Count;
        }

        if (list2_len == list.Count)
        {
            output += "Error! 调用deleteTag前后getTagListByUserId返回的列表长度相同!未能真正删除User2Tag记录!\n";
        }
    }
Exemple #2
0
    private static void addTag()
    {
        output += "addTag\n";

        Random r = new Random();

        // insert
        for (int i = 0; i < count; i++)
        {
            int no = r.Next(1000, 9000);

            if (!FocusAndCreateTag.addTag(pgs[i].GroupId, "intre" + no, "intre" + no, sampleUser.UserId))
            {
                output += "Error! 新增兴趣标签失败!返回false。\n";
                errorCount++;
                continue;
            }
        }

        // check
        List <int> list = User2TagManager.getTagListByUserId(sampleUser);

        if (list.Count < count)
        {
            output += "Error! 通过getTagListByUserId返回列表长度(=" + list.Count + ")小于测试用例数量!\n";
            errorCount++;
        }
        else
        {
            output += "Ok! 通过getTagListByUserId返回列表长度(=" + list.Count + ")不少于测试用例数量!\n";
        }
    }
Exemple #3
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     FocusAndCreateTag.addTag(Int32.Parse(DropDownList1.SelectedValue), TextBox1.Text.Trim(), TextBox2.Text.Trim(), user.UserId);
     Response.Redirect("FocusSelect.aspx");
 }
Exemple #4
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        /*
         * List<GroupNode> tempList = new List<GroupNode>();
         * GroupNode g1 = new GroupNode("a", 0, true, 5, false);
         * GroupNode g2 = new GroupNode("b", 0, false, 2, false);
         * GroupNode g3 = new GroupNode("c", 0, false, 1, false);
         * GroupNode g4 = new GroupNode("d", 1, false, 3, false);
         * GroupNode g5 = new GroupNode("e", 1, true, 1, false);
         * GroupNode g6 = new GroupNode("f", 0, false, 4, false);
         * GroupNode g7 = new GroupNode("g", 1, false, 0, false);
         * tempList.Add(g1);
         * tempList.Add(g2);
         * tempList.Add(g3);
         * tempList.Add(g4);
         * tempList.Add(g5);
         * tempList.Add(g6);
         * tempList.Add(g7);
         * tempList.Sort();
         * String df = "";
         * foreach (GroupNode wu in tempList)
         *  df = df + wu.PrimaryGroupId + wu.Id;
         * TextBox1.Text = df;
         * */

        //把所有打勾的子分类的主分类都打上勾
        foreach (TreeView tv in tvs)
        {
            TreeNode           ptn  = tv.Nodes[0];
            TreeNodeCollection ptnc = ptn.ChildNodes;
            foreach (TreeNode tn in ptnc)
            {
                if (tn.Checked)
                {
                    ptn.Checked = true;
                    break;
                }
            }
        }


        List <int> focuses = new List <int>();

        foreach (TreeNode tn in alltns)
        {
            GroupNode gn = (GroupNode)map[tn];
            if (gn.IsPrimaryGroup && tn.Checked)
            {
                GroupNode pgn = (GroupNode)p2o[tn];
                focuses.Add(pgn.Id);
                continue;
            }
            if (gn.IsInterestLabel && !tn.Checked)
            {
                FocusAndCreateTag.deleteTag(new User2Tag(user.UserId, gn.Id));
                continue;
            }

            if (tn.Checked)
            {
                focuses.Add(gn.Id);
            }
        }

        /*
         * foreach (TreeView tv in tvs)
         * {
         *  TreeNode primary = tv.Nodes[0];
         *  GroupNode primarygp = (GroupNode)map[primary];
         *  if (primary.Checked)
         *  {
         *      GroupNode pgn = (GroupNode)p2o[primary];
         *      focuses.Add(pgn.Id);
         *  }
         *
         *
         *  TreeNodeCollection tnc = primary.ChildNodes;
         *  foreach (TreeNode tn in tnc)
         *  {
         *      GroupNode gn = (GroupNode)map[tn];
         *      if (gn == null)
         *          continue;
         *
         *      if ((!gn.IsInterestLabel) && tn.Checked)
         *          focuses.Add(gn.Id);
         *  }
         * }
         * */


        bool answer = FocusAndCreateTag.saveFocus(focuses, user.UserId);
        //Response.Redirect("FocusSelect.aspx");
    }
Exemple #5
0
    private static void saveFocus()
    {
        output += "saveFocus\n";

        List <int> list1 = new List <int>();
        List <int> list2 = new List <int>();

        for (int i = 0; i < count / 2; i++)
        {
            list1.Add(tags[i].TagId);
        }
        for (int i = count / 2; i < count; i++)
        {
            list2.Add(tags[i].TagId);
        }

        // 第一次测试
        output += "第一次测试:\n";
        if (!FocusAndCreateTag.saveFocus(list1, sampleUser.UserId))
        {
            output += "Error! saveFocus调用失败!返回false\n";
            errorCount++;
            return;
        }
        else
        {
            output += "Ok! saveFocus调用成功!返回true\n";
        }

        // 第一次测试成果检查
        List <int> result1 = User2TagManager.getTagListByUserId(sampleUser);

        if (result1 == null)
        {
            output += "Error! saveFocus执行失败!getTagListByUserId返回值为null。\n";
            errorCount++;
            return;
        }
        if (result1.Count < count / 2 - 1)
        {
            output += "Error! 通过getTagListByUserId返回列表长度(=" + result1.Count + ")小于测试用例数量!\n";
            errorCount++;
        }
        else
        {
            output += "Ok! 通过getTagListByUserId返回列表长度(=" + result1.Count + ")不少于测试用例数量!\n";
        }

        // 第二次测试
        output += "第二次测试:\n";
        if (!FocusAndCreateTag.saveFocus(list2, sampleUser.UserId))
        {
            output += "Error! saveFocus调用失败!返回false\n";
            errorCount++;
            return;
        }
        else
        {
            output += "Ok! saveFocus调用成功!返回true\n";
        }

        // 第二次测试成果检查
        List <int> result2 = User2TagManager.getTagListByUserId(sampleUser);

        if (result2 == null)
        {
            output += "Error! saveFocus执行失败!getTagListByUserId返回值为null。\n";
            errorCount++;
            return;
        }
        if (result2.Count < count / 2 - 1)
        {
            output += "Error! 通过getTagListByUserId返回列表长度(=" + result2.Count + ")小于测试用例数量!\n";
            errorCount++;
        }
        else
        {
            output += "Ok! 通过getTagListByUserId返回列表长度(=" + result2.Count + ")不少于测试用例数量!\n";
        }
    }