Exemple #1
0
        public void TestMethod1()
        {
            SortableObservableCollection <int> list1 = new SortableObservableCollection <int>();
            var list2  = new SortableObservableCollection <int>();
            var random = new Random();
            var ready  = false;
            var thread = new Thread(() =>
            {
                for (int i = 0; i < 100000; i++)
                {
                    list2.Insert(0, random.Next());
                    while (list2.Count > 100)
                    {
                        list2.RemoveAt(list2.Count - 1);
                    }
                }
                ready = true;
            });

            thread.Start();
            for (int i = 0; i < 1000000; i++)
            {
                list1.Sync(list2);
            }
            while (!ready)
            {
                Thread.Sleep(1);
            }
            Assert.AreEqual(list1.Count, list2.Count);
            for (int i = 0; i < list1.Count; i++)
            {
                Assert.AreEqual(list1[i], list2[i]);
            }
        }
Exemple #2
0
        public void RemoveR(double r)
        {
            int  i     = 0;
            bool valid = false;

            for (i = 0; i < _profile.Count; i++)
            {
                if (r == _profile[i].X)
                {
                    valid = true;
                    break;
                }
            }
            if (valid)
            {
                _profile.RemoveAt(i);
            }
        }