예제 #1
0
        public void Should_throw_when_changing_position_of_non_existent_element()
        {
            var screen = new Screen();

            screen.Add(new Circle());
            m.ElementIndexChange(screen.Shapes, new Circle());
        }
예제 #2
0
        private static void ClassChanged(object sender, NotifyCollectionChangedEventArgs args)
        {
            switch (args.Action)
            {
            case NotifyCollectionChangedAction.Move:
                M.ElementIndexChange((Class)sender, (Student)args.OldItems[0], args.OldStartingIndex);
                Cache = new ObservableCollection <Student>((Class)sender);
                break;

            case NotifyCollectionChangedAction.Add:
            case NotifyCollectionChangedAction.Replace:
            case NotifyCollectionChangedAction.Remove:
                if (args.OldItems != null)
                {
                    foreach (var student in args.OldItems.Cast <Student>())
                    {
                        M.ElementRemove((Class)sender, student, Cache.IndexOf(student));
                        student.PropertyChanging -= StudentChanging;
                    }
                }

                if (args.NewItems != null)
                {
                    foreach (var student in args.NewItems.Cast <Student>())
                    {
                        M.ElementAdd((Class)sender, student);
                        student.PropertyChanging += StudentChanging;
                    }
                }

                Cache = new ObservableCollection <Student>((Class)sender);
                break;

            default:
                throw new NotSupportedException();
            }
        }