Exemplo n.º 1
0
        public void Run()
        {
            while (true)
            {
                string   input = Console.ReadLine();
                ICommand Command;
                switch (input.ToUpper())
                {
                case "CLEAR":
                    Command = new ClearCommand();
                    Command.Execute();
                    break;

                case "VERSION":
                    Command = new VersionCommand();
                    Command.Execute();
                    break;

                default:
                    Command = new NullCommand();
                    Command.Execute();
                    break;
                }
            }
        }
        public void ReturnAnErrorResponseWhenExecuted()
        {
            var nullCommand     = new NullCommand();
            var commandResponse = nullCommand.Execute();

            Assert.That(commandResponse.Status, Is.EqualTo(CommandResponseStatus.Error));
        }
Exemplo n.º 3
0
        public void Test_Command_Writes_Ok_Message()
        {
            var nullMessage = new NullMessage();
            nullMessage.MessageId = 43;

            var command = new NullCommand();

            MemoryStream stream = new MemoryStream();

            command.Execute(nullMessage, stream);

            var sentMessage = new OkMessage();

            sentMessage.Decode(stream.GetBuffer());

            Assert.Equal(nullMessage.MessageId, sentMessage.MessageId);
        }
Exemplo n.º 4
0
        public void ShouldReturnOnlyStartingPosition()
        {
            var       startingPosition = new Position(2, -3);
            const int steps            = 3;
            const int positionLimit    = 10;

            var command = new NullCommand(steps);

            var(lastPosition, positions) = command.Execute(startingPosition, positionLimit);

            var expectedLastPosition = new Position(2, -3);
            var expectedPositions    = new List <Position>
            {
                new Position(2, -3)
            };

            lastPosition.Should().Be(expectedLastPosition);
            positions.Should().BeEquivalentTo(expectedPositions);
        }
Exemplo n.º 5
0
 public void ActIsImplemented()
 {
     nullCommand.Execute();
 }