Ejemplo n.º 1
0
        public void Move_InvokesAction()
        {
            var grid = new UniversalGrid <string>(3, 3);

            var thing1 = "A".AsSpatialObject(1, 1);

            bool actionInvoked = false;

            grid.AddAction((x, m) => m.Any(p => p.Y > 1), (g, x) => {
                actionInvoked = true;
            }); // Add a rule which prevents Y from exceeding 2

            grid.SetObject(thing1);

            thing1.Move(Direction.Right); // 2, 1

            Assert.That(actionInvoked, Is.False);

            thing1.Move(Direction.Down); // 2, 2

            Assert.That(actionInvoked, Is.True);
        }