예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }