コード例 #1
0
        public void Move_CorrectlySetsTopLeftPosAndMovesContainingObjects()
        {
            var grid = new UniversalGrid <string>(10, 20);

            var thing1   = "A".AsSpatialObject(1, 1);
            var thing2   = "B".AsSpatialObject(1, 2);
            var moves    = 0;
            var modified = false;

            grid.ItemMoved += (s, e) =>
            {
                moves++;
            };

            grid.Modified += (s, e) =>
            {
                modified = true;
            };

            grid.SetObjects(thing1, thing2);

            grid.Move(new Point2D()
            {
                X = 2, Y = 1
            });

            Assert.That(modified);
            Assert.That(grid.TopLeft, Is.EqualTo(new Point2D()
            {
                X = 2, Y = 1
            }));
            Assert.That(grid.AllObjects.Count(), Is.EqualTo(2));
            Assert.That(thing1.TopLeft, Is.EqualTo(new Point2D()
            {
                X = 3, Y = 2
            }));
            Assert.That(thing2.TopLeft, Is.EqualTo(new Point2D()
            {
                X = 3, Y = 3
            }));
            Assert.That(moves, Is.EqualTo(2));
        }