private static string deleteRecord()
    {
        string output = "deleteRecord\n";

        for (int i = 0; i < count; i++)
        {
            PrimaryGroupKeyWords kw = new PrimaryGroupKeyWords(primaryGroupId, keys[i]);
            if (!PrimaryGroupKeyWordsManager.deleteRecord(kw))
            {
                output += "Error! 删除测试关键词(keyWord为\"" + keys[i] + "\")失败!\n";
                errorCount++;
            }
            else
            {
                output += "Ok! 删除测试关键词(keyWord为\"" + keys[i] + "\")成功!\n";
            }
        }

        return(output);
    }
Esempio n. 2
0
    private static void addPrimaryGroup()
    {
        output += "addPrimaryGroup\n";

        // add
        string name     = "sample123";
        string keywords = "qawsed rftgyh";

        ManagerAssist.addPrimaryGroup(name, keywords);

        // check
        List <string[]> list    = PrimaryGroupMananger.getAllGroups();
        bool            found   = false;
        int             groupId = -1;

        foreach (string[] item in list)
        {
            if (item[1].Equals("sample123"))
            {
                found   = true;
                groupId = int.Parse(item[0]);
                break;
            }
        }
        if (!found)
        {
            output += "Error! addPrimaryGroup执行失败!主分类未加入数据库中。\n";
            errorCount++;
        }
        else
        {
            output += "Ok! addPrimaryGroup执行成功!主分类已加入数据库中。\n";
        }

        PrimaryGroups pg    = new PrimaryGroups(groupId, name);
        List <string> list2 = PrimaryGroupKeyWordsManager.getKeyWordsOfCertainPrimaryGroup(pg);

        if (list2.Count != 2)
        {
            output += "Error! PrimaryGroupKeyWords数目不对!应为2\n";
        }
        else
        {
            output += "Ok! PrimaryGroupKeyWords数目正确!应为2\n";
        }

        if (list2.First().Equals("qawsed") || list2.First().Equals("rftgyh"))
        {
            output += "Ok! PrimaryGroupKeyWords中对应的第一个关键词通过验证!\n";
        }
        else
        {
            output += "Error! PrimaryGroupKeyWords中对应的第一个关键词未通过验证!\n";
            errorCount++;
        }

        List <Tag> tagL = TagManager.getAllTagsByCertainGroupId(groupId);

        if (tagL == null || tagL.Count != 1)
        {
            output += "Error! addPrimaryGroup调用后没有将“其他”子分类插入tag表!\n";
            errorCount++;
        }
        else
        {
            output += "Ok! addPrimaryGroup调用后成功将“其他”子分类插入tag表!\n";
        }

        // delete
        foreach (string item in list2)
        {
            if (!PrimaryGroupKeyWordsManager.deleteRecord(new PrimaryGroupKeyWords(groupId, item)))
            {
                output += "Error! 删除测试关键词失败!\n";
                errorCount++;
            }
        }
        Tag t = new Tag();

        t.TagId = tagL.First().TagId;
        if (!TagManager.deleteTag(t))
        {
            output += "Error! 删除测试主分类下“其他”子分类失败!\n";
            errorCount++;
        }
        PrimaryGroups temp = new PrimaryGroups();

        temp.GroupId = groupId;
        if (!PrimaryGroupMananger.deleteRecord(temp))
        {
            output += "Error! 删除测试主分类失败!\n";
            errorCount++;
        }
    }