public void When_library_added_all_trees_added() { var library = new GenericBTLibrary(); library.AddBT(_firstTree, _tree); library.AddBT(_secondTree, _tree2); _library.AddBTLibrary(library); Assert.AreEqual(_tree.Name, _library.GetBT(_firstTree).Name); Assert.AreEqual(_tree2.Name, _library.GetBT(_secondTree).Name); }
public void When_tree_added_can_be_retrieved() { _library.AddBT(_firstTree, _tree); _library.AddBT(_secondTree, _tree2); Assert.AreEqual(_tree.Name, _library.GetBT(_firstTree).Name); }
public void When_library_added_with_existing_trees_then_previous_trees_overwritten() { const string libraryTreeName = "libraryTree"; _library.AddBT(_firstTree, _tree); var library = new GenericBTLibrary(); library.AddBT(_firstTree, new TestTask(null, libraryTreeName, new ModelTask[0])); library.AddBT(_secondTree, _tree2); _library.AddBTLibrary(library); Assert.AreEqual(libraryTreeName, _library.GetBT(_firstTree).Name); Assert.AreNotEqual(_tree.Name, _library.GetBT(_firstTree).Name); Assert.AreEqual(_tree2.Name, _library.GetBT(_secondTree).Name); }
/** * Creates a BT library that contains all the behaviour trees in * <code>behaviourTrees</code>. The name of the trees are specified in * <code>names</code>, so, for instance, the i-th element in * <code>names</code> represents the name of the i-th tree in * <code>behaviourTrees</code>. If several trees are referenced by the same * name, only the last one (according to its order in the input lists) will * remain. * * @param behaviourTrees * the list with the trees that the BT library will contain. * @param names * the list with the names of the trees. * @return a BT library that contains all the behaviour trees in the list * <code>behaviourTrees</code>. */ public static IBTLibrary createBTLibrary(List <ModelTask> behaviourTrees, List <string> names) { var result = new GenericBTLibrary(); var treesIterator = behaviourTrees.GetEnumerator(); var namesIterator = names.GetEnumerator(); while (treesIterator.MoveNext() && namesIterator.MoveNext()) { result.AddBT(namesIterator.Current, treesIterator.Current); } return(result); }