コード例 #1
0
        [Test] public void InsertRangeInsertCollectionIntoEmptyList()
        {
            var sut = new CopyOnWriteList <T>();

            sut.InsertRange(0, Samples);
            CollectionAssert.AreEqual(Samples, sut);
        }
コード例 #2
0
        public void InsertRangeInsertsCollectionInRightPosition(Position position)
        {
            var index      = PositionToIndex(position);
            var samples    = Samples;
            var sampleSize = SampleSize;
            var sut        = new CopyOnWriteList <T>(samples);
            var c          = new[]
            {
                TestData <T> .M1,
                TestData <T> .M2,
                TestData <T> .M3,
            };

            sut.InsertRange(index, c);
            for (int i = 0; i < index; i++)
            {
                Assert.That(sut[i], Is.EqualTo(samples[i]));
            }
            var addCount = c.Length;

            for (int i = 0; i < addCount; i++)
            {
                Assert.That(sut[index + i], Is.EqualTo(c[i]));
            }
            for (int i = index + addCount; i < sampleSize; i++)
            {
                Assert.That(sut[i + addCount], Is.EqualTo(samples[i]));
            }
        }
コード例 #3
0
        [Test] public void InsertRangeChokesOnNullCollection()
        {
            var sut = new CopyOnWriteList <T>(Samples);
            var e   = Assert.Catch <ArgumentNullException>(() => sut.InsertRange(0, null));

            Assert.That(e.ParamName, Is.EqualTo("collection"));
        }
コード例 #4
0
        public void InsertRangeChokesOnBadIndex(Position position)
        {
            var index = PositionToIndex(position);
            var sut   = new CopyOnWriteList <T>(Samples);
            var e     = Assert.Catch <ArgumentOutOfRangeException>(() => sut.InsertRange(index, Samples));

            Assert.That(e.ParamName, Is.EqualTo("index"));
        }