public void ShellItemRegistryDecoratorTest() { var shellItem = new MockShellItem("Test", 0x99); var regKey = new RegistryKeyWrapper(null, "testUser", "testPath"); int existingPropCount = shellItem.GetAllProperties().Count; //test injection of additional properties var regShellItem = new RegistryShellItemDecorator(shellItem, regKey); Assert.IsTrue(regShellItem.GetAllProperties().Count > existingPropCount); }
public void FilterUserTest() { var user1 = "User1"; var user2 = "User2"; var parent1 = new MockShellItem(); parent1.AddProperty("RegistryOwner", user1); var parent2 = new MockShellItem(); parent2.AddProperty("RegistryOwner", user2); var eventList = new List <MockEvent>() { new MockEvent("item1", DateTime.Now, parent1, "Access"), new MockEvent("item2", DateTime.MaxValue, parent1, "Create"), new MockEvent("item3", DateTime.MinValue, parent2, "Modified"), }; var testList = new List <Node>() { new MockNode(eventList.ElementAt(0)), new MockNode(eventList.ElementAt(1)), new MockNode(eventList.ElementAt(2)) }; var startListSize = testList.Count; //test same name resetVisibility(testList); new EventUserFilter(user1).Apply(ref testList); Assert.AreEqual(2, countVisible(testList)); Assert.AreEqual(startListSize, testList.Count); //test no name resetVisibility(testList); new EventUserFilter().Apply(ref testList); Assert.AreEqual(3, countVisible(testList)); Assert.AreEqual(startListSize, testList.Count); //test multiName resetVisibility(testList); new EventUserFilter(user1, user2).Apply(ref testList); Assert.AreEqual(3, countVisible(testList)); Assert.AreEqual(startListSize, testList.Count); }
public void FilterParentTest() { var parent1 = new MockShellItem(); var parent2 = new MockShellItem(); var eventList = new List <MockEvent>() { new MockEvent("item1", DateTime.Now, parent1, "Access"), new MockEvent("item2", DateTime.MaxValue, parent1, "Create"), new MockEvent("item3", DateTime.MinValue, parent2, "Modified"), }; var testList = new List <Node>() { new MockNode(eventList.ElementAt(0)), new MockNode(eventList.ElementAt(1)), new MockNode(eventList.ElementAt(2)) }; var startListSize = testList.Count; List <Node> testListCopy; //reset this list each test because we are removing references from this list. //check same parent resetVisibility(testList); testListCopy = new List <Node>(testList); new EventParentFilter(parent1).Apply(ref testListCopy); Assert.AreEqual(2, countVisible(testListCopy)); Assert.AreEqual(startListSize, testListCopy.Count); //check diff parent resetVisibility(testList); testListCopy = new List <Node>(testList); new EventParentFilter(parent2).Apply(ref testListCopy); Assert.AreEqual(1, countVisible(testListCopy)); Assert.AreEqual(startListSize, testListCopy.Count); //check unknown parent resetVisibility(testList); testListCopy = new List <Node>(testList); new EventParentFilter(new MockShellItem()).Apply(ref testListCopy); Assert.AreEqual(0, countVisible(testListCopy)); Assert.AreEqual(startListSize, testListCopy.Count); }
public void FilterAnyStringTest() { var parent1 = new MockShellItem("item1", 0x02); var parent2 = new MockShellItem("item3", 0x02); var eventList = new List <MockEvent>() { new MockEvent(parent1.Name, DateTime.Now, parent1, "Access"), new MockEvent(parent1.Name, DateTime.MaxValue, parent1, "Create"), new MockEvent(parent2.Name, DateTime.MinValue, parent2, "Modified"), }; var testList = new List <Node>() { new MockNode(eventList.ElementAt(0)), new MockNode(eventList.ElementAt(1)), new MockNode(eventList.ElementAt(2)) }; var startListSize = testList.Count; List <Node> testListCopy; //reset this list each test because we are removing references from this list. //check for unique attribute to some items resetVisibility(testList); testListCopy = new List <Node>(testList); new AnyStringFilter("item1", false).Apply(ref testListCopy); Assert.AreEqual(2, countVisible(testListCopy)); Assert.AreEqual(startListSize, testListCopy.Count); //check for partial match to all items resetVisibility(testList); testListCopy = new List <Node>(testList); new AnyStringFilter("item", false).Apply(ref testListCopy); Assert.AreEqual(3, countVisible(testListCopy)); Assert.AreEqual(startListSize, testListCopy.Count); //check for regex expression ( .* = match all) resetVisibility(testList); testListCopy = new List <Node>(testList); new AnyStringFilter(".*", true).Apply(ref testListCopy); Assert.AreEqual(3, countVisible(testListCopy)); Assert.AreEqual(startListSize, testListCopy.Count); //check for external attribute matching outside of IEvent (test type byte value) resetVisibility(testList); testListCopy = new List <Node>(testList); new AnyStringFilter("02", false).Apply(ref testListCopy); Assert.AreEqual(3, countVisible(testListCopy)); Assert.AreEqual(startListSize, testListCopy.Count); //test for no results resetVisibility(testList); testListCopy = new List <Node>(testList); new AnyStringFilter("SeeShell", false).Apply(ref testListCopy); Assert.AreEqual(0, countVisible(testListCopy)); Assert.AreEqual(startListSize, testListCopy.Count); //test for regex timeout //TODO Find hard enough regex that actually takes time no matter the PC? }