public void CanUpdatePlayerLocation() { var model = new Model(_level, _mobs, behaviourModel); var originalPlayerLocation = model.Mobiles.WithName("player").Location; var message = new ControllerMessage{Body = "down", Header = "player"}; model.InputBuffer.Send(message); var newPlayerLocation = model.Mobiles.Tiles.FirstOrDefault(p => p.Name == "player").Location; Assert.AreNotEqual(originalPlayerLocation, newPlayerLocation); Assert.AreEqual(originalPlayerLocation.Y + 1, newPlayerLocation.Y); }
public void CanListenForMessages() { var listener = new MessageListener<ControllerMessage>(); var mediator = new ControllerMessageMediator(); mediator.Subscribe("test", listener); var testMessage = new ControllerMessage { Header = "test", Body = "testing123" }; var uselessMessage = new ControllerMessage { Header = "poop", Body = "xxxx" }; var callCount = 0; listener.MessageRecieved += m => callCount++; mediator.Send(testMessage); mediator.Send(uselessMessage); Assert.AreEqual(1, callCount); }