public void addMacroEntryTest_index() { Macro_Accessor target = new Macro_Accessor(); MacroEntry child = new MacroEntry("testPlugin", PluginType.IFilterOqat, "testmemento"); int index = 1; MacroEntry father = target.rootEntry; target.addMacroEntry(new MacroEntry("testPlugin2", PluginType.IFilterOqat, "testmementoX"), father); target.addMacroEntry(new MacroEntry("testPlugin2", PluginType.IFilterOqat, "testmementoY"), father); target.addMacroEntry(child, father, index); Assert.IsTrue(target.rootEntry.macroEntries.Contains(child), "Filter was not added to macro."); Assert.AreEqual<MacroEntry>(target.rootEntry.macroEntries[index], child, "Filter was not added at correct index."); }
public void addMacroEntryTest_eventhandler() { string mementoname = "testmemento"; PluginManagerTest.TestHelper(new string[] { "PF_Invert.dll" }); Oqat.ViewModel.PluginManager_Accessor pluginManager = new Oqat.ViewModel.PluginManager_Accessor(); pluginManager.addMemento("Invert", new Memento(mementoname, new PF_Invert.Invert().getMemento())); Macro_Accessor target = new Macro_Accessor(); object sender = null; MementoEventArgs e = new MementoEventArgs(mementoname, "Invert"); target.addMacroEntry(sender, e); Assert.AreEqual(1, target.rootEntry.macroEntries.Count, "No macroentry was added."); Assert.AreEqual(mementoname, target.rootEntry.macroEntries[0].mementoName, "Macroentry not added by event."); }
public void addMacroEntryTest_notRootentry() { Macro_Accessor target = new Macro_Accessor(); MacroEntry child = new MacroEntry("testPlugin", PluginType.IFilterOqat, "testmemento"); MacroEntry father = null; target.addMacroEntry(child, father); //expect filter not to be set as root but rather added as child Assert.AreNotEqual(child.mementoName, target.rootEntry.mementoName, "Filter was set as rootentry."); Assert.IsTrue(target.rootEntry.macroEntries.Contains(child), "Filter was not added to macro."); }
public void setMementoTest_ok() { Macro_Accessor target = new Macro_Accessor(); string mementoname = "setmementotestmemento"; string entrymementoname = "settestMemento"; MacroEntry macroentry = new MacroEntry("testPlugin", PluginType.IMacro, entrymementoname); MacroEntry subentry = new MacroEntry("testPlugin2", PluginType.IFilterOqat, "testMemento2"); macroentry.macroEntries.Add(subentry); Memento memento = new Memento(mementoname, macroentry); target.setMemento(memento); Assert.AreEqual<string>(entrymementoname, target.rootEntry.mementoName, "The memento's state was not loaded."); Assert.AreEqual(subentry, macroentry.macroEntries[0]); }
public void removeMacroEntryTest_ok() { Macro_Accessor target = new Macro_Accessor(); MacroEntry child = new MacroEntry("testplugin", PluginType.IFilterOqat, "testmemento"); target.addMacroEntry(child, target.rootEntry); target.removeMacroEntry(child); Assert.IsFalse(target.rootEntry.macroEntries.Contains(child), "Entry was not removed."); }
public void setMementoTest_nullstate() { Macro_Accessor target = new Macro_Accessor(); string mementoname = "testmemento"; Memento memento = new Memento(mementoname, null); target.setMemento(memento); Assert.AreNotEqual<string>(mementoname, target.rootEntry.mementoName, "The invalid memento was partly loaded."); Assert.IsNotNull(target.rootEntry.macroEntries, "Macro was set to null."); }
public void moveMacroEntryTest() { Macro_Accessor target = new Macro_Accessor(); MacroEntry child = new MacroEntry("testplugin", PluginType.IFilterOqat, "testmemento"); target.addMacroEntry(child, target.rootEntry); MacroEntry child2 = new MacroEntry("testpluginmacro", PluginType.IMacro, "testmemento2"); target.addMacroEntry(child2, target.rootEntry); MacroEntry toMoveMacro = child; MacroEntry target1 = child2; int index = 0; target.moveMacroEntry(toMoveMacro, target1, index); Assert.AreEqual(1, target.rootEntry.macroEntries.Count, "Entry was not moved away."); Assert.IsTrue(target.rootEntry.macroEntries[0].macroEntries.Contains(child), "Entry was not moved to new parent."); }
public void removeMacroEntryTest_nonexistent() { Macro_Accessor target = new Macro_Accessor(); MacroEntry child = new MacroEntry("testplugin", PluginType.IFilterOqat, "testmemento"); target.addMacroEntry(child, target.rootEntry); MacroEntry rem = new MacroEntry("blaplugin", PluginType.IFilterOqat, "blamemento"); target.removeMacroEntry(rem); Assert.IsTrue(target.rootEntry.macroEntries.Contains(child), "Entry was unexpectedly removed."); }
public void getMementoTest() { Macro_Accessor target = new Macro_Accessor(); string mementoname = "setmementotestmemento"; MacroEntry macroentry = new MacroEntry("testPlugin", PluginType.IFilterOqat, "testMemento"); MacroEntry subentry = new MacroEntry("testPlugin2", PluginType.IFilterOqat, "testMemento2"); macroentry.macroEntries.Add(subentry); Memento memento = new Memento(mementoname, macroentry); target.setMemento(memento); Memento actual; actual = target.getMemento(); Assert.IsNotNull(actual, "Memento not returned."); Assert.AreEqual(mementoname, actual.name); Assert.IsNotNull(actual.state, "Memento is empty"); Assert.AreEqual(subentry, ((MacroEntry)actual.state).macroEntries[0]); }
public void clearMacroEntryListTest() { Macro_Accessor target = new Macro_Accessor(); target.addMacroEntry(this, new MementoEventArgs("TestMacroEntry", "notExistingPluginName")); target.addMacroEntry(this, new MementoEventArgs("memName", "Macro")); PrivateObject macroAccessor = new PrivateObject(target); MacroEntry rootEntry = macroAccessor.GetProperty("rootEntry", null) as MacroEntry; Assert.IsNotNull(rootEntry, "Macro didnt process the add operation correctly."); Assert.IsTrue(1 == rootEntry.macroEntries.Count, "Add macro operation didnt change the entries property."); target.clearMacroEntryList(); Assert.IsTrue(0 == rootEntry.macroEntries.Count, "Clear operation didnt remove all items."); }
public void addMacroEntryTest_twice() { Macro_Accessor target = new Macro_Accessor(); MacroEntry child = new MacroEntry("testPlugin", PluginType.IFilterOqat, "testmemento"); MacroEntry father = target.rootEntry; target.addMacroEntry(child, father); target.addMacroEntry(child, father); Assert.IsTrue(target.rootEntry.macroEntries.Contains(child), "Filter was not added to macro."); Assert.AreEqual(2, target.rootEntry.macroEntries.Count); }
public void addMacroEntryTest_self() { Macro_Accessor target = new Macro_Accessor(); MacroEntry child = new MacroEntry("testPlugin", PluginType.IMacro, "testmemento"); MacroEntry father = target.rootEntry; target.addMacroEntry(child, father); target.addMacroEntry(child, child); Assert.IsTrue(target.rootEntry.macroEntries.Contains(child), "Entry was not added to macro."); Assert.AreEqual(0, target.rootEntry.macroEntries[0].macroEntries.Count, "Macro was unexpectedly added to itself."); }
public void addMacroEntryTest_rootentry() { Macro_Accessor target = new Macro_Accessor(); MacroEntry child = new MacroEntry("testPlugin", PluginType.IMacro, "testmemento"); child.macroEntries.Add(new MacroEntry("testplugin2", PluginType.IFilterOqat, "testmemento2")); MacroEntry father = null; target.addMacroEntry(child, father); Assert.AreEqual(child.mementoName, target.rootEntry.mementoName, "Rootentry was not set correctly."); Assert.AreEqual(1, target.rootEntry.macroEntries.Count, "Rootentry children were not set."); }