Exemplo n.º 1
0
        public bool Add(CustomNodeInfo nodeInfo)
        {
            var nodeEle = new CustomNodeSearchElement(nodeInfo);

            if (SearchDictionary.Contains(nodeEle))
            {
                return(this.Refactor(nodeInfo));
            }

            SearchDictionary.Add(nodeEle, nodeEle.Name);
            SearchDictionary.Add(nodeEle, nodeInfo.Category + "." + nodeEle.Name);

            TryAddCategoryAndItem(nodeInfo.Category, nodeEle);

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Add a custom node to search.
        /// </summary>
        /// <param name="workspace">A dynWorkspace to add</param>
        /// <param name="name">The name to use</param>
        public void Add(string name, string category, string description, Guid functionId)
        {
            if (name == "Home")
            {
                return;
            }

            // create the node in search
            var nodeEle = new NodeSearchElement(name, description, functionId);

            if (SearchDictionary.Contains(nodeEle))
            {
                return;
            }

            SearchDictionary.Add(nodeEle, nodeEle.Name);
            SearchDictionary.Add(nodeEle, category + "." + nodeEle.Name);

            TryAddCategoryAndItem(category, nodeEle);

            NodeCategories[category].NumElements++;
        }
Exemplo n.º 3
0
        public void TesGetItems()
        {
            // Arrange
            var searchDictionary = new SearchDictionary <string>();
            var tag1             = Guid.NewGuid().ToString();
            var tag2             = Guid.NewGuid().ToString();

            //It will generate the numbers from 1 to 10, starting from 1
            IEnumerable <string> ranges1 = from value in Enumerable.Range(1, 10)
                                           select value.ToString();

            //It will generate the numbers from 1 to 10, starting from 1
            IEnumerable <string> ranges2 = from value in Enumerable.Range(1, 10)
                                           select value.ToString();

            //Act
            searchDictionary.Add(ranges1, tag1); //Add 10 strings using the tag1
            searchDictionary.Add(ranges2, tag2); //Add 10 strings using the tag2

            //This will execute the method internal IEnumerable<V> ByTag(string tag)
            var ienumTags = searchDictionary.ByTag(tag1);

            var tags = searchDictionary.GetTags("5");       //This will return 2 tags

            var weights = searchDictionary.GetWeights("5"); //This will return 2 weights

            //Assert
            //This will validate that the method ByTag returns the 10 strings inserted
            Assert.AreEqual(ienumTags.Count(), 10);

            //This will validate that the dictionary contains the value "6"
            Assert.IsTrue(searchDictionary.Contains("6"));//This will execute the method bool Contains(V a)

            //Check that the two different tags are returned for the "5" value
            Assert.AreEqual(tags.Count(), 2);

            //Check that the two different weights are returned for the "5" value
            Assert.AreEqual(weights.Count(), 2);
        }