public void ItShouldThrowExceptionForInvalidCommandParameterCombination() { ArgumentList arguments = new ArgumentList(new string[] { "add", null }, new string[] { "--help", "add" }); string actual = arguments.GetParameter(1); string expected = "1"; Assert.AreEqual(expected, actual); }
public void ItShouldReturnThirdArgumentAsSecondParamater() { ArgumentList arguments = new ArgumentList(new string[] { "add", "1", "2" }, new string[] { "--help", "add" }); string actual = arguments.GetParameter(2); string expected = "2"; Assert.AreEqual(expected, actual); }
public void ItShouldThrowExceptionForInvalidCommand() { ArgumentList arguments = new ArgumentList(new string[] { "--help" }, new string[] { "add" }); string actual = arguments.GetCommand(); string expected = "--help"; Assert.AreEqual(expected, actual); }
public void ItShouldReturnLenghtOfArgumentList() { ArgumentList arguments = new ArgumentList(new string[] { "add" }, new string[] { "--help", "add" }); int actual = arguments.GetLength(); int expected = 1; Assert.AreEqual(expected, actual); }
public void ItShouldReturnFirstArgumentAsCommand() { ArgumentList arguments = new ArgumentList(new string[] { "--help" }, new string[] { "--help" }); string actual = arguments.GetCommand(); string expected = "--help"; Assert.AreEqual(expected, actual); }
public void ItShouldGetTypeOfChangeForDate() { ArgumentList arguments = new ArgumentList(new string[] { "change", "1", "--dueDate", "2/21/2016" }, new string[] { "--help", "change" }); int actual = arguments.GetTypeOfChange(); int expected = 1; Assert.AreEqual(expected, actual); }
public void ItShouldAddToTaskList() { var testAddCommand = new AddCommand(); var arguments = new ArgumentList(new string[] { "add", "I added something" }, new string[] { "add" }); var taskList = new TaskList(); testAddCommand.Execute(arguments, taskList, new TagList(), new TagFolder()); string actual = taskList.GetTask(0).TaskDescription; string expected = "I added something"; Assert.AreEqual(expected, actual); }
public void ItShouldAddDueDateToTaskList() { var testAddCommand = new AddCommand(); var arguments = new ArgumentList(new string[] { "add", "I added something", "2/7/2016" }, new string[] { "add" }); var taskList = new TaskList(); testAddCommand.Execute(arguments, taskList, new TagList(), new TagFolder()); string actual = taskList.GetTask(0).DueDate.Date.ToString("d"); string expected = "2/7/2016"; Assert.AreEqual(expected, actual); }
public void ItShouldNotAddSameTaskToTaskList() { var testAddCommand = new AddCommand(); var arguments = new ArgumentList(new string[] { "add", "I added something" }, new string[] { "add" }); var taskList = new TaskList(); Task testTask1 = new Task(); testTask1.TaskDescription = "I added something"; taskList.AddTask(ref testTask1); testAddCommand.Execute(arguments, taskList, new TagList(), new TagFolder()); int actual = taskList.GetListSize(); int expected = 1; Assert.AreEqual(expected, actual); }
public static void Main(string[] args) { try { var commands = new string[] { "add", "done", "remove", "--help", "list", "filter", "change", "due", "tag", "untag", "delete", "filterTag", "folder", "filterFolder" }; var arguments = new ArgumentList(args, commands); var taskList = new TaskList(); var tagList = new TagList(); var tagFolder = new TagFolder(); var loader = new FileIO(); loader.LoadTasks(taskList); loader.LoadTags(ref tagList); loader.LoadFolder(ref tagFolder); var dictionary = new Dictionary<string, ICommand>(); dictionary.Add(commands[0], new AddCommand()); dictionary.Add(commands[1], new DoneCommand()); dictionary.Add(commands[2], new RemoveCommand()); dictionary.Add(commands[3], new HelpCommand()); dictionary.Add(commands[4], new ListCommand()); dictionary.Add(commands[5], new FilterCommand()); dictionary.Add(commands[6], new ChangeCommand()); dictionary.Add(commands[7], new DueCommand()); dictionary.Add(commands[8], new TagCommand()); dictionary.Add(commands[9], new UntagCommand()); dictionary.Add(commands[10], new DeleteCommand()); dictionary.Add(commands[11], new FilterTagCommand()); dictionary.Add(commands[12], new FolderCommand()); dictionary.Add(commands[13], new FilterFolderCommand()); var invoker = new Invoker(dictionary); ICommand command = invoker.GetCommand(arguments.GetCommand()); command.Execute(arguments, taskList, tagList, tagFolder); } catch (ArgumentException) { Console.WriteLine("Invalid Command"); } catch (IndexOutOfRangeException) { DisplayHelp(); } catch (FormatException) { Console.WriteLine("Invalid date entered"); } }
public void ItShouldThrowExceptionForUnitializedArgumentList() { ArgumentList arguments = new ArgumentList(new string[0], new string[0]); string actual = arguments.GetCommand(); string expected = "--help"; Assert.AreEqual(expected, actual); }
public void ItShouldFilterTasksThatArePastDue() { var testAddCommand = new AddCommand(); var arguments1 = new ArgumentList(new string[] { "add", "I added something", DateTime.Today.ToString("d") }, new string[] { "add" }); var arguments2 = new ArgumentList(new string[] { "add", "I added something else", "1/7/2016" }, new string[] { "add" }); var taskList = new TaskList(); testAddCommand.Execute(arguments1, taskList, new TagList(), new TagFolder()); testAddCommand.Execute(arguments2, taskList, new TagList(), new TagFolder()); var actual = taskList.FilterDue("past")[0].TaskDescription; var expected = "I added something else"; Assert.AreEqual(expected, actual); }