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); }
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); }
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)); //查询刚刚删除的资源 }
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); }
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); }
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); }
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); }
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));//查询刚刚删除的资源 }