Example #1
0
        public void PickElements()
        {
            int randIndex = -1;
            int uniqueNum = 0;

            // If ElementList has element(s) then clear both lists and rebuilt
            if (ElementList.Count > 0)
            {
                ElementList.Clear();
                NumberList.Clear();

                _build(); // rebuild _numberList data
            }

            // Loop trhough number of elements need to add
            for (int i = 0; i < ElementNumber; i++)
            {
                // Generate a random index position between 1 to SetSize (inclusive)
                randIndex = _Random.Next(1, SetSize);
                uniqueNum = NumberList.ElementAt(randIndex);
                // Determine its a duplicate number
                while (ElementList.Contains(uniqueNum))
                {
                    // Then again generate number
                    randIndex = _Random.Next(1, SetSize);
                    uniqueNum = NumberList.ElementAt(randIndex);
                }

                // If its a unique number then add to element list
                ElementList.Add(uniqueNum);
            }

            // Sort the ElementList
            ElementList.Sort();
        }
Example #2
0
        public void AddListToDataCategory()
        {
            var list = new ElementList <Element>("test");
            var data = new Data <string>("data", "value", -1, "", true);

            data.AddCategory(list);
            Assert.IsTrue(data.Categories.Contains(list));
            Assert.IsTrue(list.Contains(data));
        }