Example #1
0
        public void AddRangeTest()
        {
            double[] range = { 320, 45, 16, -19, 1, 12 };

            var eventCount = 0;
            var itemCount  = 0;
            NotifyCollectionChangedEventHandler testCollectionChanged = (s, e) => { this.CollectionChangedHandler(e, ref eventCount, ref itemCount); };

            this.test.DetailedCollectionChanged += testCollectionChanged;

            this.test.AddRange(range);
            foreach (var item in range)
            {
                this.basis.Add(item, item);
            }

            Assert.AreEqual(eventCount, 1);
            Assert.AreEqual(itemCount, range.Length);
            Assert.AreEqual(this.basis.Count, this.test.Count);
            UnitTestHelper.AssertAreEqual(this.basis.Values, this.test, this.test.Count);

            this.test.DetailedCollectionChanged -= testCollectionChanged;
        }
        public void ViewAddTest()
        {
            var view1 = this.test.GetView(ObservableKeyedCache <double, double> .ObservableKeyedView.ViewMode.Fixed, 2, 44, 0, null);
            var view2 = this.test.GetView(ObservableKeyedCache <double, double> .ObservableKeyedView.ViewMode.Fixed, 2, 44, 0, null);
            var view3 = this.test.GetView(ObservableKeyedCache <double, double> .ObservableKeyedView.ViewMode.Fixed, 1, 46, 0, null);

            view1.Add(12);
            view1.Add(22);

            Assert.AreEqual(view1.Count, 5);
            Assert.AreEqual(view3.Count, 6);
            Assert.AreEqual(this.test.Count, 12);
            UnitTestHelper.AssertAreEqual(view1, view2, view1.Count);

            view3.Add(1);
            view3.Add(43);
            view3.Add(45);

            Assert.AreEqual(view1.Count, 6);
            Assert.AreEqual(view3.Count, 9);
            Assert.AreEqual(this.test.Count, 15);
            UnitTestHelper.AssertAreEqual(view1, view2, view1.Count);
        }
        public void Initialize()
        {
            this.basis = new SortedList<double, double>();

            var eventCount = 0;
            var itemCount = 0;
            NotifyCollectionChangedEventHandler testCollectionChanged = (s, e) => { this.CollectionChangedHandler(e, ref eventCount, ref itemCount); };
            this.test = new ObservableKeyedCache<double, double>((d) => d);
            this.test.DetailedCollectionChanged += testCollectionChanged;

            double[] values = { 15, 65, -1, 2, 44, 100, 123, -456, 0, 10 };
            foreach (var value in values)
            {
                this.basis.Add(value, value);
                this.test.Add(value);
            }

            Assert.AreEqual(eventCount, values.Length);
            Assert.AreEqual(itemCount, values.Length);
            Assert.AreEqual(this.basis.Count, values.Length);
            UnitTestHelper.AssertAreEqual(this.basis.Values, this.test, values.Length);

            this.test.DetailedCollectionChanged -= testCollectionChanged;
        }
Example #4
0
 public void AddTest()
 {
     this.test.Add(6);
     this.basis.Add(6, 6);
     UnitTestHelper.AssertAreEqual(this.basis.Values, this.test, this.test.Count);
 }