Esempio n. 1
0
        public void CanRemoveNodeAndCategoryByFunctionId()
        {
            var nodeName   = "TheNoodle";
            var catName    = "TheCat";
            var descr      = "TheCat";
            var path       = @"C:\turtle\graphics.dyn";
            var guid1      = Guid.NewGuid();
            var dummyInfo1 = new CustomNodeInfo(guid1, nodeName, catName, descr, path);

            // add custom node
            search.Add(dummyInfo1);

            // confirm it's in the dictionary
            Assert.AreEqual(1, search.SearchDictionary.NumElements);

            // remove custom node
            search.RemoveNodeAndEmptyParentCategory(guid1);

            // it's gone
            Assert.AreEqual(0, search.SearchDictionary.NumElements);
            var results = search.Search(nodeName);

            Assert.AreEqual(0, results.Count());
        }
Esempio n. 2
0
        /// <summary>
        /// Helper method for custom node adding and removing
        /// </summary>
        public static void AssertAddAndRemoveCustomNode(SearchModel searchModel, string nodeName, string catName, string descr = "Bla",
                                                        string path = "Bla")
        {
            var dummyInfo = new CustomNodeInfo(Guid.NewGuid(), nodeName, catName, descr, path);

            searchModel.Add(dummyInfo);

            var res = searchModel.Search(nodeName).ToList();

            Assert.AreNotEqual(0, res.Count());
            Assert.AreEqual(res[0].Name, nodeName);
            Assert.IsTrue(searchModel.ContainsCategory(catName));

            searchModel.RemoveNodeAndEmptyParentCategory(nodeName);
            res = searchModel.Search(nodeName).ToList();

            Assert.AreEqual(0, res.Count());
            Assert.IsFalse(searchModel.ContainsCategory(catName));
        }