public void SetUp()
        {
            _library = new GenericBTLibrary();

            _tree  = new TestTask(null, "tree1", new ModelTask[0]);
            _tree2 = new TestTask(null, "tree2", new ModelTask[0]);
        }
Esempio n. 2
0
        /**
         * Creates a BT library that contains all the BTs contained in the libraries
         * of <code>libraries</code>. If several trees are referenced by the same
         * name, only the last one (according to its order in the input libraries)
         * will remain.
         *
         * @param libraries
         *            the list with all the libraries whose BTs will contain the
         *            returned BT library.
         * @return a BT library that contains all the BTs contained in the libraries
         *         of <code>libraries</code>.
         */

        public static IBTLibrary createBTLibrary(List <IBTLibrary> libraries)
        {
            var result = new GenericBTLibrary();

            foreach (var btLibrary in libraries)
            {
                result.AddBTLibrary(btLibrary);
            }

            return(result);
        }
        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);
        }
Esempio n. 4
0
        /**
         * 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);
        }
        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);
        }