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(); } } }
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(); } }