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 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); }