Exemplo n.º 1
0
 public void AddResourceTestNormal()
 {
     Corona.CoronaService.CoronaService target = new Corona.CoronaService.CoronaService(AppDomain.CurrentDomain.BaseDirectory + "testdb11.accdb"); // TODO: 初始化为适当的值
     Resource resrc = new Resource("Hainan.jpg", @"C:\Users\name\Pictures\Hainan.jpg"); // TODO: 初始化为适当的值
     target.AddResource(resrc);
     Assert.IsTrue(isnumberic(resrc.ResourceID));
     Assert.AreEqual(resrc.ResourceID, target.GetResource(@"C:\Users\name\Pictures\Hainan.jpg").ResourceID);
 }
Exemplo n.º 2
0
 void dispatcher_ResourceOpened(Resource resc, ResourceOpenedResponseHandler callback)
 {
     //打开文件的文件夹。
     ResourceOpenedResponseEArgs e = new ResourceOpenedResponseEArgs();
     e.resc = resc;
     rescControl.OpenResource(e.resc);
     //其次回调
     if (callback != null)
         callback(e);
 }
Exemplo n.º 3
0
 public void AddResourceTestUnnormal1()
 {
     Corona.CoronaService.CoronaService target = new Corona.CoronaService.CoronaService(AppDomain.CurrentDomain.BaseDirectory + "testdb13.accdb"); // TODO: 初始化为适当的值
     Resource resrc = new Resource("Hainan.jpg", @"C:\Users\name\Pictures\Hainan.jpg"); // TODO: 初始化为适当的值
     target.AddResource(resrc);
     target.RemoveResource(resrc.ResourceID);
     string OldID = resrc.ResourceID;
     target.AddResource(resrc);//添加刚刚删除的标签
     Assert.IsNotNull(resrc.ResourceID);
     Assert.AreNotEqual(OldID,resrc.ResourceID);
 }
Exemplo n.º 4
0
 public void AddResourceTestUnnormal()
 {
     Corona.CoronaService.CoronaService target = new Corona.CoronaService.CoronaService(AppDomain.CurrentDomain.BaseDirectory + "testdb12.accdb");//todo:初始化为适当的值
     Resource resrc = null;
     target.AddResource(resrc);//添加空资源
     Assert.IsTrue(true);
     Resource resrc1 = new Resource("", @"C:\Users\name\Pictures\Hainan.jpg");
     target.AddResource(resrc1);//添加没有名字的资源
     Assert.IsNull(resrc1.ResourceID);
     Resource resrc2=new Resource("3.exe","");
     target.AddResource(resrc2);//添加没有路径的资源
     Assert.IsNull(resrc2.ResourceID);
 }
Exemplo n.º 5
0
        public void allMethodOfMoonCoreTest()
        {
            List<IRequestObject> testObjects = new List<IRequestObject>();
            List<IRequestObject> returnObjects = new List<IRequestObject>();
            Tag exe = new Tag("exe");
            Tag im = new Tag("IM");
            Tag ms = new Tag("MS");

            Resource msn = new Resource("MSN.exe", "C:/microsoft");
            Resource qq = new Resource("QQ.exe", "C:/QQ");
            List<Resource> testResource = new List<Resource>();

               //     Corona.MoonCore.MoonCore_Accessor target = new MoonCore_Accessor();

            target.dispatcher_TagCreated("exe", (e) => { exe = e.tag; });
            target.dispatcher_TagCreated("IM", (e) => { im = e.tag; });
            target.dispatcher_TagCreated("MS", (e) => { ms = e.tag; });

            target.dispatcher_ResourceAdded("G:\\QQ.txt", (e) => { qq = e.resource; });
            //target.dispatcher_ResourceAdded("C:\\microsoft.txt", (e) => { msn = e.resource; });
            testResource.Add(qq);
            System.Threading.Thread.Sleep(100);

            target.dispatcher_RelationCreated(exe, qq, (e) => { exe.TagID = e.TagID; });
            target.dispatcher_RelationCreated(im, qq, (e) => { im.TagID = e.TagID; });
            testObjects.Add(exe);
            testObjects.Add(im);

            //target.dispatcher_RelationCreated(im, msn, null);
            string resourceInfo = string.Empty; // TODO: 初始化为适当的值
            string rescPath = string.Empty; // TODO: 初始化为适当的值
            string expected = string.Empty; // TODO: 初始化为适当的值
            string actual = "";
            target.dispatcher_SearchRequestAsked(testObjects, (e) =>
            {
                returnObjects = e.Result;
            });
            //  target.dispatcher_ResourceAdded(resourceInfo, rescPath, null);
            foreach (IRequestObject ro in returnObjects)
            {
                Tag tag = ro as Tag;
                Resource res = ro as Resource;
                if (ro is Tag)
                    actual += tag.TagName + tag.TagID + tag.ResourceID;
                else if (ro is Resource)
                    actual += res.ResourceName + res.ResourcePath + res.ResourceID + res.TagIDs;
            }
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
Exemplo n.º 6
0
 /// <summary>
 /// 真正创建标签
 /// </summary>
 /// <param name="tag"></param>
 /// <param name="resource"></param>
 /// <param name="relationCreatedCallback"></param>
 /// <param name="tagCreatedCallback"></param>
 void dispatcher_RelationCreated(Tag tag, Resource resource, RelationCreatedResponseHandler callback)
 {
     RelationCreatedResponseEArgs e = new RelationCreatedResponseEArgs();
     //首先将tag加入后台的数据库,并从后台的数据库中获得tagID参数。
     coronaService.AddTag(tag,resource);
     //其次完成回调部分。
     if ((tag.TagID != null) && (resource.ResourceID != null))
     {
         e.TagID = tag.TagID;
         e.ResrcID = resource.ResourceID;
         e.TagName = tag.TagName;
     }
     else
     {
     }
     if (callback != null)
         callback(e);
 }
Exemplo n.º 7
0
        public void AddTagTestNormal()
        {
            Corona.CoronaService.CoronaService target = new Corona.CoronaService.CoronaService(AppDomain.CurrentDomain.BaseDirectory + "testdb8.accdb"); // TODO: 初始化为适当的值
            Tag tag = new Tag("旅游"); // TODO: 初始化为适当的值
            Resource resource = new Resource("1.jpg",@"C:\Users\name\pictures\1.jpg");
            target.AddResource(resource);// TODO: 初始化为适当的值
            target.AddTag(tag, resource);

            Assert.IsTrue(isnumberic(tag.TagID));//tag.TagID是数字
            Assert.AreEqual(resource.ResourceID,tag.ResourceID);//Resource的ID赋给tag
        }
Exemplo n.º 8
0
 public void AddTagTestUnnormal()
 {
     Corona.CoronaService.CoronaService target = new Corona.CoronaService.CoronaService(AppDomain.CurrentDomain.BaseDirectory + "testdb9.accdb");//todo:初始化为适当的值
     Tag tag = new Tag("山西游");//todo:初始化为适当的值
     Resource resource = new Resource("aa.jpg",@"C:\Users\name\pictures\aa.jpg");
     //这里故意没有加入资源,测试异常情况
     Assert.IsNull(tag.ResourceID);
     Assert.IsNull(tag.TagID);
     target.AddTag(tag,resource);//添加没有资源的标签
     Tag tag1 = new Tag(null);//todo:初始化为适当的值
     target.AddResource(resource);
     target.AddTag(tag1,resource);//添加空标签
     Tag tag2 = new Tag(null);
     target.AddTag(tag2,resource);//添加没有名字的标签
     Assert.IsNull(tag2.TagID);
     Assert.IsNull(tag2.ResourceID);
 }
Exemplo n.º 9
0
        public void SearchTagsFromResourcesTest()
        {
            Corona.CoronaService.CoronaService target = new Corona.CoronaService.CoronaService(AppDomain.CurrentDomain.BaseDirectory + "testdb2.accdb"); // TODO: 初始化为适当的值
            Resource res1 = new Resource("1.jpg", @"D:\pictures\1.jpg");
            Resource res2 = new Resource("2.jpg", @"D:\pictures\2.jpg");
            Resource res3 = new Resource("3.jpg", @"D:\pictures\3.jpg");
            target.AddResource(res1); target.AddResource(res2); target.AddResource(res3);
            Tag tag1 = new Tag("河南");
            Tag tag2 = new Tag("北京");
            Tag tag3 = new Tag("内蒙古");
            Tag tag4 = new Tag("人物");
            Tag tag5 = new Tag("风景");
            Tag tag6 = new Tag("风景");
            target.AddTag(tag1, res1);
            target.AddTag(tag4, res1);
            target.AddTag(tag2, res2);
            target.AddTag(tag5, res2);
            target.AddTag(tag3, res3);
            target.AddTag(tag6, res3);
            List<Resource> RList=new List<Resource>();
            RList.Add(res1);
            RList.Add(res2);
            RList.Add(res3);
            List<Tag> TagExpected=new List<Tag>();
            TagExpected.Add(tag1); TagExpected.Add(tag2);TagExpected.Add(tag3);
            TagExpected.Add(tag4);TagExpected.Add(tag5);TagExpected.Add(tag6);
            List<Tag> TagActual;
            TagActual = target.SearchTagsFromResources(RList);//正常情况的测试
            foreach (Tag t in TagActual)
            {
                byte flag=0;
                foreach (Tag ta in TagExpected)
                {
                    if (t.TagID == ta.TagID)
                    {
                        flag = 1;
                        break;
                    }
                }
                if (flag == 0)
                {
                    Assert.Fail();
                }

            }
            foreach (Tag t in TagExpected)
            {
                byte flag = 0;
                foreach (Tag ta in TagActual)
                {
                    if (ta.TagID == t.TagID)
                    {
                        flag = 1;
                        break;
                    }
                }
                if (flag == 0)
                {
                    Assert.Fail();
                }
            }
            List<Resource> RList1 = new List<Resource>();//测空的资源表
            Assert.AreEqual(0,target.SearchTagsFromResources(RList1).Count);
            List<Resource> RList2 = null;//测试Null资源表
            Assert.AreEqual(0,target.SearchTagsFromResources(RList2).Count);
            Resource tempRes = new Resource("tt.jpg",@"C:\pictures");
            List<Resource> RList3 = new List<Resource>();//测试刚刚创建的资源
            RList3.Add(tempRes);
            Assert.AreEqual(0,target.SearchTagsFromResources(RList3).Count);
            target.RemoveResource(res1.ResourceID);
            List<Resource> RList4 = new List<Resource>();//测试刚刚删除的资源
            RList4.Add(res1);
            Assert.AreEqual(0,target.SearchTagsFromResources(RList4).Count);
        }
Exemplo n.º 10
0
 public void RemoveTagTest()
 {
     Corona.CoronaService.CoronaService target = new Corona.CoronaService.CoronaService(AppDomain.CurrentDomain.BaseDirectory + "testdb4.accdb"); // TODO: 初始化为适当的值
     Resource res1 = new Resource("1.jpg", @"D:\pictures\1.jpg");
     target.AddResource(res1);
     Tag tag1 = new Tag("河南");
     Tag tag2 = new Tag("人物");
     Tag tag3 = new Tag("汴京府");
     target.AddTag(tag1, res1);
     target.AddTag(tag2, res1);
     target.AddTag(tag3, res1);
     target.RemoveTag(tag1.TagID);//Remove已经存在数据库中的标签
     List<Resource> RL = new List<Resource>();
     RL.Add(res1);
     List<Tag> TL = null;
     TL = target.SearchTagsFromResources(RL);
     foreach (Tag t in TL)
     {
         if (t.TagID == tag1.TagID)
         {
             Assert.Fail();
             break;
         }
     }
     target.RemoveTag(tag1.TagID);//Remove已经删除过的,有ID
     Assert.IsTrue(true);
     Tag tempTag = new Tag("Homework");
     target.RemoveTag(tempTag.TagID);//测试刚刚新建的,ID此时应该没有赋值
     target.RemoveTag(null);//删除空的
     Assert.IsTrue(true);
 }
Exemplo n.º 11
0
        public void RemoveResourceTest()
        {
            Corona.CoronaService.CoronaService target = new Corona.CoronaService.CoronaService(AppDomain.CurrentDomain.BaseDirectory + "testdb5.accdb");
            Resource res1 = new Resource("1.jpg", @"D:\pictures\1.jpg");
            target.AddResource(res1);
            Tag tag1 = new Tag("河南");

            Tag tag4 = new Tag("人物");

            target.AddTag(tag1, res1);
            target.AddTag(tag4, res1);

            target.RemoveResource(res1.ResourceID);//删除正常的资源
            List<Tag> TL = new List<Tag>();
            TL.Add(tag1); TL.Add(tag4);
            List<Resource> RL = null;
            RL = target.SearchResourcesFromTags(TL);
            Assert.AreEqual(0,RL.Count);
            target.RemoveResource(res1.ResourceID);//删除已经删除的,即应有ID
            Assert.IsTrue(true);
            Resource tempRes = new Resource("12.jpg",@"C:\program files\p");
            target.RemoveResource(tempRes.ResourceID);
            target.RemoveResource(null);//删除空
            Assert.IsTrue(true);
        }
Exemplo n.º 12
0
 public void ModifyTagTest()
 {
     Corona.CoronaService.CoronaService target = new Corona.CoronaService.CoronaService(AppDomain.CurrentDomain.BaseDirectory + "testdb6.accdb"); // TODO: 初始化为适当的值
     Tag tag = new Tag("小游戏"); // TODO: 初始化为适当的值
     Resource res = new Resource("PopCollection.exe",
                                 @"D:\program files\games\PopCollection.exe");
     target.AddResource(res);
     target.AddTag(tag,res);
     target.ModifyTag(tag);
     Tag tag1 = new Tag("Pop小游戏");
     tag1.TagID = tag.TagID;
     tag1.ResourceID = tag.ResourceID;
     target.ModifyTag(tag1);
     List<Resource> RList = new List<Resource>();
     RList.Add(res);
     List<Tag> TList;
     TList=target.SearchTagsFromResources(RList);
     foreach (Tag t in TList)
     {
         if (t.TagID == tag.TagID)
         {
             Assert.AreEqual(tag1.TagName,t.TagName);
             break;
         }
     }
     Tag tag2 = tag;
     tag2.TagName = null;//修改为空名称
     target.ModifyTag(tag2);
     Assert.IsTrue(true);
     Tag tag3 = new Tag();
     tag3.TagName = "Pop";
     tag3.TagID = tag.TagID;
     tag3.ResourceID = tag.ResourceID;
     target.AddTag(tag3,res);
     tag3.TagName="Pop小游戏";//修改为重名的同一个资源的标签
     target.ModifyTag(tag3);
     Assert.IsTrue(true);
     Tag tag4 = new Tag();
     //不知道怎么测——————————————————————————————————————————————————————————————
     tag4.TagName ="~~~~";//tag4是恶意注入的SQL语句
     tag4.TagID =  @"0 or true";
     target.ModifyTag(tag4);
     TList = target.SearchTagsFromResources(RList);
     foreach (Tag t in TList)
     {
         if (t.TagName.Equals("~~~~"))
             Assert.Fail();
     }
 }
Exemplo n.º 13
0
 public void GetResourceTest()
 {
     Corona.CoronaService.CoronaService target = new Corona.CoronaService.CoronaService(AppDomain.CurrentDomain.BaseDirectory + "testdb7.accdb"); // TODO: 初始化为适当的值
     string resourcePath = @"C:\Users\XZC\pictures\3.jpg";// TODO: 初始化为适当的值
     Resource resource = new Resource("3.jpg",resourcePath); // TODO: 初始化为适当的值
     target.AddResource(resource);
     Assert.AreEqual(resource.ResourceID, target.GetResource(resourcePath).ResourceID);//查询正常的路径
     Assert.IsNull(target.GetResource(@"D:\ddd\e.jpg"));//查询不存在的路径
     Assert.IsNull(target.GetResource(null));//查询空的路径
     target.RemoveResource(resource.ResourceID);
     Assert.IsNull(target.GetResource(resourcePath));//查询刚刚删除的资源
 }
Exemplo n.º 14
0
 public void AddTagTestUnnormal1()
 {
     Corona.CoronaService.CoronaService target = new Corona.CoronaService.CoronaService(AppDomain.CurrentDomain.BaseDirectory + "testdb10.accdb"); // TODO: 初始化为适当的值
     Tag tag = new Tag("旅游"); // TODO: 初始化为适当的值
     Resource resource = new Resource("1.jpg", @"C:\Users\name\pictures\1.jpg");
     target.AddResource(resource);// TODO: 初始化为适当的值
     target.AddTag(tag, resource);
     string OldID = tag.TagID;
     target.RemoveTag(tag.TagID);
     target.AddResource(resource);
     target.AddTag(tag,resource);//添加刚刚删除的标签
     string NewID=tag.TagID;
     Assert.AreNotEqual(OldID,NewID);
 }
Exemplo n.º 15
0
 public string test5(string selectedResourceID)
 {
     mutex.WaitOne();
     notrecieved = true;
     List<Resource> resources = new List<Resource>();
     Resource resc = new Resource();
     resc.ResourceID = selectedResourceID;
     resources.Add(resc);
     //SearchTag(resources, ShowTagResults);
     mutex.ReleaseMutex();
     return recieve;
 }
Exemplo n.º 16
0
 public void SearchTagsFromTagsTest()
 {
     Corona.CoronaService.CoronaService target = new Corona.CoronaService.CoronaService(AppDomain.CurrentDomain.BaseDirectory+"testdb1.accdb"); // TODO: 初始化为适当的值
     Resource res1 = new Resource("1.jpg",@"D:\pictures\1.jpg");
     Resource res2 = new Resource("2.jpg",@"D:\pictures\2.jpg");
     Resource res3 = new Resource("3.jpg",@"D:\pictures\3.jpg");
     target.AddResource(res1); target.AddResource(res2); target.AddResource(res3);
     Tag tag1 = new Tag("河南");
     Tag tag2 = new Tag("北京");
     Tag tag3 = new Tag("内蒙古");
     Tag tag4 = new Tag("人物");
     Tag tag5 = new Tag("风景");
     Tag tag6 = new Tag("风景");
     target.AddTag(tag1,res1);
     target.AddTag(tag4,res1);
     target.AddTag(tag2,res2);
     target.AddTag(tag5,res2);
     target.AddTag(tag3,res3);
     target.AddTag(tag6,res3);
     List<Tag> selectedTags =new List<Tag>(); // TODO: 初始化为适当的值
     selectedTags.Add(tag1);
     selectedTags.Add(tag5);
     selectedTags.Add(tag3);
     List<Tag> actual;
     actual = target.SearchTagsFromTags(selectedTags);
     Assert.AreEqual(actual[0].TagName, "河南");
     Assert.AreEqual(actual[1].TagName,"风景");
     Assert.AreEqual(actual[2].TagName, "内蒙古");
     Assert.AreEqual(actual[3].TagName,"人物");
     List<Tag> TList = new List<Tag>();
     List<Tag> actual1 = target.SearchTagsFromTags(TList);//搜索空表
     Assert.AreEqual(0,actual1.Count);
     TList = null;
     actual1 = target.SearchTagsFromTags(TList);//搜索null
     Assert.AreEqual(0,actual1.Count);
     TList=new List<Tag>();
     TList.Add(new Tag("1.exe"));//搜索创建的标签表,没有ID
     actual1 = target.SearchTagsFromTags(TList);
     Assert.AreNotEqual(0,actual1.Count);
     target.RemoveTag(tag1.TagID);
     TList = new List<Tag>();
     TList.Add(tag1);
     actual1 = target.SearchTagsFromTags(TList);//搜索刚刚删除的标签
     Assert.AreNotEqual(0,actual1.Count);
 }
Exemplo n.º 17
0
        public void ICornaServiceTest()
        {
            /* 测试AddResource方法
             * */
            //add the first Resource,and the Id is copy to the Resource
            Resource resrc1 = new Resource("Internet Explorer.exe",
                @"c:\program files\Internet Explorer"); // TODO: 初始化为适当的值
            target.AddResource(resrc1);
            Assert.IsTrue(isnumberic(resrc1.ResourceID));
            //add the second Resource
            Resource resrc2 = new Resource("TTPlayer.exe",
                @"D:\program files\TTPlayer\TTPlayer.exe");//TODO:初始化尾适当的值
            target.AddResource(resrc2);
            Assert.IsTrue(isnumberic(resrc2.ResourceID));

            /* 测试AddTag
            */
            //add the first Tag to the first Resource
            Tag tag1 = new Tag("5.0版本"); // TODO: 初始化为适当的值
            target.AddTag(tag1, resrc1);

            Assert.IsTrue(isnumberic(tag1.TagID));
            //add the second Tag to the second Resource
            Tag tag2 = new Tag("5.5版本");
            target.AddTag(tag2, resrc2);
            Assert.IsTrue(isnumberic(tag2.TagID));
            //add the third Tag to the first Resource
            Tag tag3 = new Tag("浏览器");
            target.AddTag(tag3, resrc1);
            Assert.IsTrue(isnumberic(tag3.TagID));
            //add the forth Tag to the second Resource
            Tag tag4 = new Tag("音乐播放器");
            target.AddTag(tag4, resrc2);
            Assert.IsTrue(isnumberic(tag4.TagID));
            /*测试RemoveTag
             * */
            string tagToRemoveID = tag1.TagID; // TODO: 初始化为适当的值
            target.RemoveTag(tagToRemoveID);
            List<Resource> resList1 = new List<Resource>();
            resList1.Add(resrc1);
            byte flag = 1;
            foreach (Tag t in target.SearchTagsFromResources(resList1))
            {
                if (t.TagID == tag1.TagID)
                {
                    flag = 0;
                    break;
                }
            }
            Assert.AreEqual(1, flag);
            /*测试修改标签ModifyTag
                * */
            //修改标签Tag4(考虑修改名字而不是修改标签的ID)
            //怎么修改标签呢?要传递内容的参数,还是……??
            //  Tag tempTag = tag4;
            // target.ModifyTag(tag4);
            // Assert.AreNotEqual(tempTag.TagName, tag4.TagName);
            /*测试删除资源RemoveResource
             * */
            //删除资源resrc1
            string resrcToRemoveID = resrc1.ResourceID; // TODO: 初始化为适当的值
            target.RemoveResource(resrcToRemoveID);
            List<Tag> tagList1 = new List<Tag>();
            tagList1.Add(tag1);
            tagList1.Add(tag3);
            int flag1 = 1;
            foreach (Resource rs in target.SearchResourcesFromTags(tagList1))
            {
                if (rs.ResourceID == resrc1.ResourceID)
                {
                    flag1 = 0;
                    break;
                }
            }
            Assert.AreEqual(1, flag1);
            //为了便于测试现在把第一个资源在重新添加回去!!,假设AddResource能够为参数的ID属性赋值!
            target.AddResource(resrc1);//这时resrc1的ID属性应该是发生了变化,只是我们不必知道而已
            //把Tag1,Tag3重新添加到第一个资源中资源
            target.AddTag(tag1, resrc1);
            target.AddTag(tag3, resrc1);

            /// <summary>
            ///SearchResourcesFromTags 的测试
            ///</summary>
            List<Tag> selectedTags = new List<Tag>(); // TODO: 初始化为适当的值
            selectedTags.Add(tag1);
            selectedTags.Add(tag2);
            selectedTags.Add(tag3);
            List<Resource> ResListExpected = new List<Resource>(); // TODO: 初始化为适当的值
            ResListExpected.Add(resrc1);
            ResListExpected.Add(resrc2);
            List<Resource> ResListActual;
            ResListActual = target.SearchResourcesFromTags(selectedTags);
            //不判断生成的List是否有重复的元素
            //判断实际生成的List中,每个元素都在预期的List中,否则断言失败;
            foreach (Resource r in ResListActual)
            {
                byte flag2 = 0;
                foreach (Resource t in ResListExpected)
                {
                    if (r.ResourceID == t.ResourceID)
                    {
                        flag2 = 1;
                        break;
                    }
                }
                if (flag2 == 0)
                {
                    Assert.Fail();
                }

            }
            //判断在预期的List中每个元素都属于生成的实际List,否则断言失败;
            foreach (Resource r in ResListExpected)
            {
                byte flag2 = 0;
                foreach (Resource t in ResListActual)
                {
                    if (r.ResourceID == t.ResourceID)
                    {
                        flag2 = 1;
                        break;
                    }
                }
                if (flag2 == 0)
                {
                    Assert.Fail();
                }
            }

            //if tagList is null:

            //      List<Tag> selectedTags1 = null;//TODO: 初始化为适当的值
            //      List<Resource> ResListExpected1 = null;
            //      List<Resource> ResListActual1 = target.SearchResourcesFromTags(selectedTags1);
            //      Assert.AreEqual(ResListExpected1, ResListActual1);
            //如果标签的内容一致,但是不是同一个标签,但是把它看成是一个标签,
            //这时,需要根据标签的内容来进行检索标签;
            Tag tagOfBoth0 = new Tag("创建时间:2009/11/19");
            Tag tagOfBoth1 = new Tag("创建时间:2009/11/19");
            target.AddTag(tagOfBoth0, resrc1);
            target.AddTag(tagOfBoth1, resrc2);
            List<Tag> tagList2 = new List<Tag>();
            tagList2.Add(tagOfBoth0);
            List<Resource> resListActual2;
            resListActual2 = target.SearchResourcesFromTags(tagList2);
            byte flag3 = 0;
            foreach (Resource rs in resListActual2)
            {
                if (rs.ResourceID == resrc1.ResourceID)
                {
                    flag3 = 1;
                    break;
                }
            }
            if (flag3 == 1)
            {
                foreach (Resource rs in resListActual2)
                {
                    if (rs.ResourceID == resrc2.ResourceID)
                    {
                        flag3 = 2;
                        break;
                    }
                }
            }
            Assert.AreEqual(2, flag3);
            /// <summary>
            ///SearchTagsFromResources 的测试
            ///</summary>
            List<Resource> selectedResources = new List<Resource>(); // TODO: 初始化为适当的值
            selectedResources.Add(resrc1);
            selectedResources.Add(resrc2);
            List<Tag> tagListExpected = new List<Tag>(); // TODO: 初始化为适当的值
            tagListExpected.Add(tag1);
            tagListExpected.Add(tag3);
            tagListExpected.Add(tag2);
            tagListExpected.Add(tag4);
            tagListExpected.Add(tagOfBoth0);
            tagListExpected.Add(tagOfBoth1);
            List<Tag> tagListActual;
            tagListActual = target.SearchTagsFromResources(selectedResources);
            foreach (Tag r in tagListActual)
            {
                byte flag2 = 0;
                foreach (Tag t in tagListExpected)
                {
                    if (r.TagID == t.TagID)
                    {
                        flag2 = 1;
                        break;
                    }
                }
                if (flag2 == 0)
                {
                    Assert.Fail();
                }

            }
            //判断在预期的List中每个元素都属于生成的实际List,否则断言失败;
            foreach (Tag r in tagListExpected)
            {
                byte flag2 = 0;
                foreach (Tag t in tagListActual)
                {
                    if (r.ResourceID == t.ResourceID)
                    {
                        flag2 = 1;
                        break;
                    }
                }
                if (flag2 == 0)
                {
                    Assert.Fail();
                }
            }
            //if selectedResources is null
            //      List<Resource> selectedResources1 = new List<Resource>();
            //      List<Tag> tagListExpected1 = null;
            //      List<Tag> tagListActual1;
            //      tagListActual1 = target.SearchTagsFromResources(selectedResources1);
            //      Assert.AreEqual(tagListExpected1, tagListActual1);
            /*SearchTagsFromTagsTest的测试
             *
             * */
            /*List<Tag> selectedTags2 = new List<Tag>();
            selectedTags2.Add(tag1);
            selectedTags2.Add(tag2);
            List<Tag> tagListActual2;
            tagListActual2 = target.SearchTagsFromTags(selectedTags2);
            Assert.IsTrue(tagListActual2.Contains(tag3) && tagListActual2.Contains(tag4) &&
                tagListActual2.Contains(tagOfBoth0) && tagListActual2.Contains(tagOfBoth1) &&
                !tagListActual2.Contains(tag1) && !tagListActual2.Contains(tag2));
            //if taglist is null
            selectedTags2.Clear();
            tagListActual2 = target.SearchTagsFromTags(selectedTags2);
            Assert.IsNull(tagListActual2);*/
        }