public void MyTestInitialize()
 {
     my_queue   = new Queue <DSInteger>();
     my_p_queue = new PriorityQueue <DSInteger>(true);
     addInitialQueueItems(my_queue);
     addInitialQueueItems(my_p_queue);
 }
 private void testIsEmpty(BasicQueue <DSInteger> the_queue)
 {
     //simple isEmpty() check with items and without
     Assert.AreEqual(false, the_queue.isEmpty());
     the_queue.clear();
     Assert.AreEqual(true, the_queue.isEmpty());
 }
Beispiel #3
0
        public void InitCheckedListBox <T>(BasicQueue <T> lstSortInfo, bool onlyGroup) where T : GroupInfo
        {
            checkedListBox1.Items.Clear();
            foreach (T item in lstSortInfo)
            {
                checkedListBox1.Items.Add(item, true);
            }

            foreach (KeyValuePair <SortType, SortAttribute> item in EnumAttrDict <SortType, SortAttribute> .Instance.Dictionary)
            {
                if (Exist(lstSortInfo, item.Key))
                {
                    continue;
                }

                //如果只要分组,且当前属性不是分组,则返回
                if (onlyGroup && item.Value.OnlyGroup == false)
                {
                    continue;
                }
                SortInfo clbi = new SortInfo();
                clbi.Text = item.Value.Description;
                clbi.Type = item.Key;
                checkedListBox1.Items.Add(clbi, false);
            }

            checkedListBox1.Focus();
            if (checkedListBox1.SelectedItem == null)
            {
                btnUp.Enabled = btnDown.Enabled = btnShow.Enabled = btnHide.Enabled = false;
            }
        }
 private void addInitialQueueItems(BasicQueue <DSInteger> the_queue)
 {
     the_queue.enqueue(new DSInteger(100));
     the_queue.enqueue(new DSInteger(50));
     the_queue.enqueue(new DSInteger(200));
     the_queue.enqueue(new DSInteger(25));
     the_queue.enqueue(new DSInteger(400));
 }
 private void testSize(BasicQueue <DSInteger> the_queue)
 {
     Assert.AreEqual(5, the_queue.size());
     the_queue.dequeue();
     Assert.AreEqual(4, the_queue.size());
     the_queue.clear();
     Assert.AreEqual(0, the_queue.size());
 }
        private void testClear(BasicQueue <DSInteger> the_queue)
        {
            //make sure there are items
            Assert.AreEqual(false, the_queue.isEmpty());

            //make sure they are cleared
            the_queue.clear();
            Assert.AreEqual(true, the_queue.isEmpty());
            Assert.AreEqual(null, the_queue.dequeue());
        }
        private void testPoll(BasicQueue <DSInteger> the_queue)
        {
            //assert that calling poll does not remove the first item
            Assert.AreEqual(100, the_queue.poll().value);
            Assert.AreEqual(100, the_queue.poll().value);

            //make sure that poll works even after a dequeue() operation
            the_queue.dequeue();
            Assert.AreEqual(50, the_queue.poll().value);
        }
        private void testEnqueue(BasicQueue <DSInteger> the_queue)
        {
            //make sure the last element removed is the last one added
            DSInteger next = null, last = null;

            while ((next = the_queue.dequeue()) != null)
            {
                last = next;
            }
            Assert.AreEqual(400, last.value);
        }
Beispiel #9
0
 private bool Exist <T>(BasicQueue <T> lstSortInfo, SortType type) where T : GroupInfo
 {
     foreach (T item in lstSortInfo)
     {
         if (item.Type == type)
         {
             return(true);
         }
     }
     return(false);
 }
        private void testContains(BasicQueue <DSInteger> the_queue)
        {
            //make sure the items that should be there are there
            Assert.AreEqual(true, the_queue.contains(new DSInteger(100)));
            Assert.AreEqual(true, the_queue.contains(new DSInteger(50)));
            Assert.AreEqual(true, the_queue.contains(new DSInteger(200)));
            Assert.AreEqual(true, the_queue.contains(new DSInteger(25)));
            Assert.AreEqual(true, the_queue.contains(new DSInteger(400)));

            //make sure there are no false positives
            Assert.AreEqual(false, the_queue.contains(new DSInteger(90)));
        }
        private void testDequeue(BasicQueue <DSInteger> the_queue)
        {
            //make sure the elements are removed with a LIFO methodology
            Assert.AreEqual(100, the_queue.dequeue().value);
            Assert.AreEqual(50, the_queue.dequeue().value);
            Assert.AreEqual(200, the_queue.dequeue().value);
            Assert.AreEqual(25, the_queue.dequeue().value);
            Assert.AreEqual(400, the_queue.dequeue().value);

            //make sure no remain after all dequeues
            Assert.AreEqual(true, the_queue.isEmpty());
        }
 private void testToString(BasicQueue <DSInteger> the_queue)
 {
     //just test for no exceptions, leave the output to the programmer, user
     try
     {
         the_queue.ToString();
     }
     catch (Exception the_ex)
     {
         Assert.Fail();
     }
 }
Beispiel #13
0
        /// <summary>
        /// 构建问题队列
        /// </summary>
        /// <param name="questionnaire">指定调查问卷</param>
        /// <returns></returns>
        private IQueue <Question> QuestionQueueBuilder(Questionnaire questionnaire)
        {
            Guid currentUserGuid = Guid.Parse((from claim in HttpContext.User.Claims
                                               where claim.Type == "guid"
                                               select claim.Value).FirstOrDefault());
            List <Guid> guids = JsonConvert.DeserializeObject <List <Guid> >(questionnaire.Question);
            IOrderedQueryable <Question> questionRecords = from s in noteContext.Question
                                                           where s.Version != Guid.Empty
                                                           orderby s.Ctime descending
                                                           select s;
            IEnumerable <Question> orderd = from guid in guids
                                            join question in questionRecords on guid equals question.QuestionGuid
                                            select question;
            IQueue <Question> questionQueue = new BasicQueue <Question>(Guid.NewGuid(), currentUserGuid, noteContext, orderd.ToArray());

            return(questionQueue);
        }
 private void testAdd(BasicQueue <DSInteger> the_queue)
 {
     //same as enqueue() test
 }