예제 #1
0
        public void RemoveRangeTest()
        {
            this.test.RemoveRange(3, 2);
            for (int i = 0; i < 2; i++)
            {
                this.basis.RemoveAt(3);
            }

            UnitTestHelper.AssertAreEqual(this.basis.Values, this.test, this.test.Count);

            this.test.RemoveRange(this.test.Count - 1, 1);
            this.basis.RemoveAt(this.basis.Count - 1);
            UnitTestHelper.AssertAreEqual(this.basis.Values, this.test, this.test.Count);

            UnitTestHelper.TestException(() => this.test.RemoveRange(this.test.Count - 1, 2), typeof(ArgumentOutOfRangeException));
            UnitTestHelper.TestException(() => this.test.RemoveRange(100, 1), typeof(ArgumentOutOfRangeException));
            UnitTestHelper.TestException(() => this.basis.RemoveAt(100), typeof(ArgumentOutOfRangeException));
        }
        public void CopyToTest()
        {
            var testArray  = new double[10];
            var basisArray = new double[10];

            this.test.CopyTo(testArray, 0);
            this.basis.Values.CopyTo(basisArray, 0);
            Assert.AreEqual(testArray.Length, 10);
            for (var i = 0; i < testArray.Length; i++)
            {
                Assert.AreEqual(basisArray[i], testArray[i]);
            }

            var smallArray = new double[1];

            UnitTestHelper.TestException(() => this.test.CopyTo(smallArray, 0), typeof(ArgumentException));
            UnitTestHelper.TestException(() => this.basis.Values.CopyTo(smallArray, 0), typeof(ArgumentException));
        }
        public void ViewCopyToTest()
        {
            var view      = this.test.GetView(ObservableKeyedCache <double, double> .ObservableKeyedView.ViewMode.Fixed, 2, 44, 0, null);
            var viewArray = new double[3];
            var testArray = new double[] { 2, 10, 15 };

            view.CopyTo(viewArray, 0);
            Assert.AreEqual(viewArray.Length, 3);

            for (var i = 0; i < viewArray.Length; i++)
            {
                Assert.AreEqual(viewArray[i], testArray[i]);
            }

            var smallArray = new double[1];

            UnitTestHelper.TestException(() => view.CopyTo(smallArray, 0), typeof(ArgumentException));
        }