public void ThrowsException_WhenTheCommandIsNullOrEmpty()
        {
            //arrange
            string nullTestCommand  = null;
            string emptyTestCommand = "";

            IParser testParser = new Traveller.Core.Providers.CommandParser();

            //act and assert
            Assert.ThrowsException <ArgumentNullException>(() => testParser.ParseParameters(nullTestCommand));
            Assert.ThrowsException <ArgumentException>(() => testParser.ParseParameters(emptyTestCommand));
        }
        public void ReturnsEmptyListFromStrings_WhenTheCommandHasNoParameters(string fullCommand)
        {
            //arrange
            IParser testParser = new Traveller.Core.Providers.CommandParser();

            //act
            IList <string> testList = testParser.ParseParameters(fullCommand);

            //act and assert
            Assert.IsNotNull(testList);
            Assert.AreEqual(0, testList.Count);
            //That means it`s not null, but it`s empty.
        }
        public void ThrowsException_WhenOneOFTheParametersIsNull()
        {
            //arrange
            Mock <ICommandFactory> commandFactoryMock = new Mock <ICommandFactory>();
            ICommandFactory        nullCommandFactory = null;
            string testCommand      = "testCommand";
            string nullTestCommand  = null;
            string emptyTestCommand = "";

            IParser testParser = new Traveller.Core.Providers.CommandParser();

            //act and assert
            Assert.ThrowsException <ArgumentNullException>(() => testParser.ParseCommand(nullTestCommand, commandFactoryMock.Object));
            Assert.ThrowsException <ArgumentException>(() => testParser.ParseCommand(emptyTestCommand, commandFactoryMock.Object));
            Assert.ThrowsException <ArgumentNullException>(() => testParser.ParseCommand(testCommand, nullCommandFactory));
        }
        public void ReturnsListFromStringsWithoutTheActualCoomand_WhenTheCommandHasParameters(string fullCommand)
        {
            //arrange
            IParser       testParser = new Traveller.Core.Providers.CommandParser();
            int           expectedNumberOfParameters = fullCommand.Split().Length - 1;
            List <string> expectedParametersList     = fullCommand.Split().ToList();

            expectedParametersList.RemoveAt(0);

            //act
            List <string> testList = testParser.ParseParameters(fullCommand).ToList();

            //assert
            Assert.AreEqual(expectedNumberOfParameters, testList.Count);
            CollectionAssert.AreEquivalent(expectedParametersList, testList);
        }
        public void ReturnsCommand_WhenParametersAreCorrect()
        {
            //arrange
            Mock <ICommandFactory> commandFactoryMock = new Mock <ICommandFactory>();
            string  testCommand = "testCommand";
            IParser testParser  = new Traveller.Core.Providers.CommandParser();

            Mock <ICommand> expectedCommand = new Mock <ICommand>();

            commandFactoryMock.Setup(x => x.CreateCommand(testCommand))
            .Returns(expectedCommand.Object);

            //act
            ICommand testCommandObject = testParser.ParseCommand(testCommand, commandFactoryMock.Object);

            //assert
            Assert.AreEqual(expectedCommand.Object, testCommandObject);
        }