public void ExecuteContinousInvalidCommand() { var stateManager = new StateManager(); var game = new TestGameImplementation(); game.Initialize <DefaultPlayer>(null); var commands = CommandFactory.GetCommands(new Assembly[] { Assembly.GetExecutingAssembly() }); if (commands.Count() == 0) { Assert.Fail("No commands were fetched from the factory."); } stateManager.Initialize(game.Player, commands); stateManager.PerformCommand(new ReceivedInputMessage("CommandWithInput")); Assert.IsTrue(game.Messages.Count > 0); Assert.IsNotNull(game.Player.StateManager.CurrentState); Assert.IsTrue(game.Player.StateManager.CurrentState.GetType() == typeof(ReceivingInputState)); stateManager.PerformCommand(new ReceivedInputMessage("someRandomStuff")); Assert.IsTrue(game.Messages.Count > 0); Assert.IsNotNull(game.Player.StateManager.CurrentState); Assert.IsTrue(game.Player.StateManager.CurrentState.GetType() == typeof(TestState)); stateManager.PerformCommand(new ReceivedInputMessage("randomMessage")); Assert.IsTrue(game.Messages.Pop() == "Invalid command used!" + Environment.NewLine); }
public void ExecuteContinousInvalidCommand() { var stateManager = new StateManager(); var game = new TestGameImplementation(); game.Initialize<DefaultPlayer>(null); var commands = CommandFactory.GetCommands(new Assembly[] { Assembly.GetExecutingAssembly() }); if (commands.Count() == 0) { Assert.Fail("No commands were fetched from the factory."); } stateManager.Initialize(game.Player, commands); stateManager.PerformCommand(new ReceivedInputMessage("CommandWithInput")); Assert.IsTrue(game.Messages.Count > 0); Assert.IsNotNull(game.Player.StateManager.CurrentState); Assert.IsTrue(game.Player.StateManager.CurrentState.GetType() == typeof(ReceivingInputState)); stateManager.PerformCommand(new ReceivedInputMessage("someRandomStuff")); Assert.IsTrue(game.Messages.Count > 0); Assert.IsNotNull(game.Player.StateManager.CurrentState); Assert.IsTrue(game.Player.StateManager.CurrentState.GetType() == typeof(TestState)); stateManager.PerformCommand(new ReceivedInputMessage("randomMessage")); Assert.IsTrue(game.Messages.Pop() == "Invalid command used!" + Environment.NewLine); }
public void ExecuteConventionBasedCommand() { var stateManager = new StateManager(); var game = new TestGameImplementation(); game.Initialize <DefaultPlayer>(null); var commands = CommandFactory.GetCommands(new Assembly[] { Assembly.GetExecutingAssembly() }); if (commands.Count() == 0) { Assert.Fail("No commands were fetched from the factory."); } stateManager.Initialize(game.Player, commands); stateManager.PerformCommand(new ReceivedInputMessage("CommandForTesting")); Assert.IsTrue(game.Messages.Count > 0); Assert.IsNotNull(game.Player.StateManager.CurrentState); Assert.IsTrue(game.Player.StateManager.CurrentState.GetType() == typeof(TestState)); }
public void ExecuteConventionBasedCommand() { var stateManager = new StateManager(); var game = new TestGameImplementation(); game.Initialize<DefaultPlayer>(null); var commands = CommandFactory.GetCommands(new Assembly[] { Assembly.GetExecutingAssembly() }); if (commands.Count() == 0) { Assert.Fail("No commands were fetched from the factory."); } stateManager.Initialize(game.Player, commands); stateManager.PerformCommand(new ReceivedInputMessage("CommandForTesting")); Assert.IsTrue(game.Messages.Count > 0); Assert.IsNotNull(game.Player.StateManager.CurrentState); Assert.IsTrue(game.Player.StateManager.CurrentState.GetType() == typeof(TestState)); }