Ejemplo n.º 1
0
        public void ExceptionTest()
        {
            var collection = new ObservableCollection <int>();

            AssertThrow <ArgumentNullException>(
                () => ((ObservableCollection <int>)null).AddChangeHandlers((int i, int j) => { }, (i, j) => { }, () => { }),
                () => collection.AddChangeHandlers(null, (int i, int j) => { }, () => { }),
                () => collection.AddChangeHandlers((int i, int j) => { }, null, () => { }),
                () => collection.AddChangeHandlers((int i, int j) => { }, (i, j) => { }, null),
                () => ((ObservableCollection <int>)null).Project((int i) => i),
                () => collection.Project((Func <int, int>)null));
        }
Ejemplo n.º 2
0
        private void AssertChange(Action <ObservableCollection <int> > change)
        {
            var o       = new ObservableCollection <int>(Enumerable.Range(0, this.Random.Next(4, 10)));
            var c       = new List <int>();
            var handler = o.AddChangeHandlers(
                (int index, int item) => c.Insert(index, item), (index, item) => c.RemoveAt(index), c.Clear);

            AssertChange(o, change, c, handler);

            using (var projection = o.Project((int i) => i))
            {
                AssertChange(o, change, projection);
            }
        }