コード例 #1
0
        public void InsertRange_Past_End_Should_Throw_Exception()
        {
            var target = new AvaloniaList <int>();

            Assert.Throws <ArgumentOutOfRangeException>(() => target.InsertRange(1, new List <int>()
            {
                1
            }));
        }
コード例 #2
0
        public void Inserting_Items_Should_Raise_CollectionChanged()
        {
            var target = new AvaloniaList <int>(new[] { 1, 2 });
            var raised = false;

            target.CollectionChanged += (s, e) =>
            {
                Assert.Equal(target, s);
                Assert.Equal(NotifyCollectionChangedAction.Add, e.Action);
                Assert.Equal(new[] { 3, 4 }, e.NewItems.Cast <int>());
                Assert.Equal(1, e.NewStartingIndex);

                raised = true;
            };

            target.InsertRange(1, new[] { 3, 4 });

            Assert.True(raised);
        }
コード例 #3
0
        public void InsertRange_With_Null_Should_Throw_Exception()
        {
            var target = new AvaloniaList <int>();

            Assert.Throws <ArgumentNullException>(() => target.InsertRange(1, null));
        }
コード例 #4
0
        public void InsertRange_Past_End_Should_Throw_Exception()
        {
            var target = new AvaloniaList<int>();

            Assert.Throws<ArgumentOutOfRangeException>(() => target.InsertRange(1, new List<int>() { 1 }));
        }
コード例 #5
0
        public void InsertRange_With_Null_Should_Throw_Exception()
        {
            var target = new AvaloniaList<int>();

            Assert.Throws<ArgumentNullException>(() => target.InsertRange(1, null));
        }
コード例 #6
0
        public void Inserting_Items_Should_Raise_CollectionChanged()
        {
            var target = new AvaloniaList<int>(new[] { 1, 2 });
            var raised = false;

            target.CollectionChanged += (s, e) =>
            {
                Assert.Equal(target, s);
                Assert.Equal(NotifyCollectionChangedAction.Add, e.Action);
                Assert.Equal(new[] { 3, 4 }, e.NewItems.Cast<int>());
                Assert.Equal(1, e.NewStartingIndex);

                raised = true;
            };

            target.InsertRange(1, new[] { 3, 4 });

            Assert.True(raised);
        }