public void ChangeFilterForNodeTest() { HelpFunctions hf = new HelpFunctions(strategyMgr, grantTrees); hf.filterApplication(applicationName, applicationPathName); treeOperation.updateNodes.filterSubtreeWithCurrentFilterStrtegy(idTextNodeCalc); List <Strategy> filterStrategys = Settings.getPossibleFilters(); Type currentFilter = strategyMgr.getSpecifiedFilter().GetType(); int indexNewFilterStrategy = 0; foreach (Strategy strategy in filterStrategys) { if (!strategy.className.Contains(currentFilter.FullName) && !strategy.className.ToLower().Contains("java")) //kann raus wenn Java-Filter vorhanden ist { break; } indexNewFilterStrategy++; } strategyMgr.setSpecifiedFilter(filterStrategys[indexNewFilterStrategy].className); strategyMgr.getSpecifiedFilter().setTreeOperation(treeOperation); strategyMgr.getSpecifiedFilter().setGeneratedGrantTrees(grantTrees); treeOperation.updateNodes.filterSubtreeWithCurrentFilterStrtegy(idTextNodeCalc); OSMElements.OSMElement textNode = treeOperation.searchNodes.getFilteredTreeOsmElementById(idTextNodeCalc); if (textNode.properties.grantFilterStrategy == null || !filterStrategys[indexNewFilterStrategy].userName.Equals(textNode.properties.grantFilterStrategy)) { Assert.Fail("Die Filterstrategie wurde für den Knoten (richtig) nicht geändert!\nBtrachtet wurde der Knoten {0}\nDer filter hätte '{1}' sein sollen", textNode, filterStrategys[indexNewFilterStrategy].userName); } }
public void TestGeneratedIdsOfFilteredTreeUnique() { HelpFunctions hf = new HelpFunctions(strategyMgr, grantTrees); hf.filterApplication(applicationName, applicationPathName); if (grantTrees.filteredTree == null) { Assert.Fail("Es ist kein gefilterter Baum vorhanden"); return; } Object copyedTree = strategyMgr.getSpecifiedTree().Copy(grantTrees.filteredTree); String nodeId; foreach (Object node in strategyMgr.getSpecifiedTree().AllNodes(grantTrees.filteredTree)) { nodeId = strategyMgr.getSpecifiedTree().GetData(node).properties.IdGenerated; foreach (Object nodeCopy in strategyMgr.getSpecifiedTree().AllNodes(copyedTree)) { if (!strategyMgr.getSpecifiedTree().GetData(node).Equals(strategyMgr.getSpecifiedTree().GetData(nodeCopy)) && nodeId.Equals(strategyMgr.getSpecifiedTree().GetData(nodeCopy).properties.IdGenerated)) { Debug.WriteLine("selbe ID :("); Debug.WriteLine("node1 = " + node + "\nnode2 = " + nodeCopy); Assert.Fail(); } } } }
public void TestSaveTree() { String processName = "calc"; String applicationPathName = @"C:\Windows\system32\calc.exe"; HelpFunctions hf = new HelpFunctions(strategyMgr, grantTrees); hf.filterApplication(processName, applicationPathName); if (grantTrees.filteredTree == null) { Assert.Fail("Es ist kein gefilterter Baum vorhanden"); return; } Console.WriteLine("m_testContext.DeploymentDirectory: " + m_testContext.DeploymentDirectory); String folderPathSave = System.IO.Path.Combine(m_testContext.DeploymentDirectory, "filter_test"); guiFuctions.saveProject(folderPathSave); String projectLoadedPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "SavedTrees"); projectLoadedPath = System.IO.Path.Combine(projectLoadedPath, "filteredTree_RechnerUIA"); // String @folderPathSaveTree = Path.GetDirectoryName(@folderPathSave) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(@folderPathSave); //String @projectPathTree = Path.GetDirectoryName(projectLoadedPath) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(projectLoadedPath); if (!CompareToSavedFilteredTrees(System.IO.Path.Combine(folderPathSave, Settings.getFilteredTreeSavedName()), System.IO.Path.Combine(projectLoadedPath, "filteredTree.xml"))) { Assert.Fail("Der gerade gespeicherte Baum stimmt nicht mit den 'Test-Baum' überein!"); } }
public void TestGetNodeByProperties() { HelpFunctions hf = new HelpFunctions(strategyMgr, grantTrees); hf.filterApplication(applicationName, applicationPathName); Assert.IsNotNull(grantTrees.filteredTree); foreach (Object node in strategyMgr.getSpecifiedTree().AllNodes(grantTrees.filteredTree)) { OSMElements.OSMElement osmData = strategyMgr.getSpecifiedTree().GetData(node); OSMElements.OSMElement osmDataWithoutId = osmData.DeepCopy(); osmDataWithoutId.properties.resetIdGenerated = null; List <Object> foundObjects = treeOperation.searchNodes.getNodesByProperties(grantTrees.filteredTree, osmDataWithoutId.properties); Assert.AreEqual(1, foundObjects.Count); Assert.IsTrue(strategyMgr.getSpecifiedTree().Equals(node, foundObjects[0])); } }
public void FilterSubtreeTest() { HelpFunctions hf = new HelpFunctions(strategyMgr, grantTrees); hf.filterApplication(applicationName, applicationPathName); treeOperation.updateNodes.filterSubtreeWithCurrentFilterStrtegy(idTextNodeCalc); IntPtr appHwnd = strategyMgr.getSpecifiedOperationSystem().getHandleOfApplication(applicationName); strategyMgr.getSpecifiedOperationSystem().setForegroundWindow(appHwnd); //Send Key -> Inhalt im Textfeld soll sich ändern System.Windows.Forms.SendKeys.SendWait("{ESC}"); System.Windows.Forms.SendKeys.SendWait("24"); treeOperation.updateNodes.filterSubtreeWithCurrentFilterStrtegy(idTextNodeCalc); OSMElements.OSMElement textNode = treeOperation.searchNodes.getFilteredTreeOsmElementById(idTextNodeCalc); if (!textNode.properties.nameFiltered.Equals("24")) { Assert.Fail("Der Knoten wurde nicht richtig geändert oder geupdatet!\nBetrachteter Knoten:\n{0}", textNode); } }
public void TestGetIdFilteredNodeByHwnd() { HelpFunctions hf = new HelpFunctions(strategyMgr, grantTrees); hf.filterApplication(applicationName, applicationPathName); Assert.IsNotNull(grantTrees.filteredTree); foreach (Object node in strategyMgr.getSpecifiedTree().AllNodes(grantTrees.filteredTree)) { OSMElements.OSMElement osmData = strategyMgr.getSpecifiedTree().GetData(node); String foundId = treeOperation.searchNodes.getIdFilteredNodeByHwnd(osmData.properties.hWndFiltered); if (IntPtr.Zero.Equals(osmData.properties.hWndFiltered)) { Assert.AreEqual(null, foundId); } else { Assert.AreEqual(osmData.properties.IdGenerated, foundId); } } }