Beispiel #1
0
        public void Should_undo_redo_collection_position_change()
        {
            var screen = new Screen();
            Circle circle1, circle2;
            screen.Add(circle1 = new Circle());
            screen.Add(circle2 = new Circle());
            m.Reset();

            screen.MoveToFront(1);
            Assert.AreSame(circle2, screen.Shapes[0]);
            Assert.AreSame(circle1, screen.Shapes[1]);

            m.Undo();
            Assert.AreSame(circle1, screen.Shapes[0]);
            Assert.AreSame(circle2, screen.Shapes[1]);

            m.Redo();
            Assert.AreSame(circle2, screen.Shapes[0]);
            Assert.AreSame(circle1, screen.Shapes[1]);
        }
Beispiel #2
0
        public void Should_undo_redo_collection_removal()
        {
            var screen = new Screen();
            var circle = new Circle();
            screen.Add(circle);
            m.Reset();

            screen.Remove(circle);
            UndoCount(1);

            m.Undo();
            Assert.AreSame(circle, screen.Shapes[0]);

            m.Redo();
            Assert.AreEqual(0, screen.Shapes.Count);
        }
Beispiel #3
0
        public void Should_undo_redo_collection_changes_in_explicit_batch()
        {
            var screen = new Screen();
            m.BeginBatch();
            try {
                var circle = new Circle();
                screen.Add(new Circle {Radius = 10});
                screen.Add(circle);
                screen.MoveToFront(1);
                screen.Remove(circle);
            } finally {
                m.EndBatch();
            }
            Assert.AreEqual(1, screen.Shapes.Count);
            UndoCount(1);

            m.Undo();
            Assert.AreEqual(0, screen.Shapes.Count);
        }
Beispiel #4
0
 public void Should_throw_when_removing_non_existent_element()
 {
     var screen = new Screen();
     screen.Remove(new Circle());
 }
Beispiel #5
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());
 }
Beispiel #6
0
        public void Should_fire_collection_removal_event()
        {
            var screen = new Screen();
            var circle = new Circle();
            screen.Add(circle);

            int count = 0;
            m.Changed += (_, args) => {
                Assert.AreEqual(typeof (ElementRemovalEvent<Circle>), args.Event.GetType());
                Assert.AreSame(screen.Shapes, ((ElementRemovalEvent<Circle>)args.Event).Collection);
                Assert.AreSame(circle, ((ElementRemovalEvent<Circle>)args.Event).Element);
                Assert.AreEqual(0, ((ElementRemovalEvent<Circle>)args.Event).Index);
                count++;
            };
            screen.Remove(circle);
            m.Undo();
            Assert.AreEqual(2, count);
        }
Beispiel #7
0
        public void Should_fire_collection_element_position_change_event()
        {
            var screen = new Screen();
            var circle = new Circle();
            screen.Add(new Circle());
            screen.Add(circle);

            int count = 0;
            m.Changed += (_, args) => {
                Assert.AreEqual(typeof(ElementIndexChangeEvent<Circle>), args.Event.GetType());
                Assert.AreSame(screen.Shapes, ((ElementIndexChangeEvent<Circle>)args.Event).Collection);
                Assert.AreSame(circle, ((ElementIndexChangeEvent<Circle>)args.Event).Element);
                Assert.AreEqual(1, ((ElementIndexChangeEvent<Circle>)args.Event).Index);
                count++;
            };
            screen.MoveToFront(1);
            m.Undo();
            Assert.AreEqual(2, count);
        }