From 96fbc820178ac042440b9a4280cd5ab50fe8c6e8 Mon Sep 17 00:00:00 2001 From: abdi Date: Thu, 9 Jan 2025 16:10:35 +0100 Subject: [PATCH 1/2] forgot to commit before now, have done by the principles of tdd --- domain-model.md | 38 ++++ tdd-todo-list.CSharp.Main/Extension.cs | 145 +++++++++++- tdd-todo-list.CSharp.Main/ToDoList.cs | 131 +++++++++++ tdd-todo-list.CSharp.Main/ToDoTask.cs | 42 ++++ tdd-todo-list.CSharp.Test/CoreTests.cs | 239 +++++++++++++++++++- tdd-todo-list.CSharp.Test/ExtensionTests.cs | 20 ++ tdd-todo-list.sln | 1 + 7 files changed, 612 insertions(+), 4 deletions(-) create mode 100644 domain-model.md create mode 100644 tdd-todo-list.CSharp.Main/ToDoTask.cs diff --git a/domain-model.md b/domain-model.md new file mode 100644 index 00000000..67975d43 --- /dev/null +++ b/domain-model.md @@ -0,0 +1,38 @@ +## Calculator Project + +# User Stories + + + +-I want to add tasks to my todo list. + +-I want to see all the tasks in my todo list. + +-I want to change the status of a task between incomplete and complete. + +-I want to be able to get only the complete tasks. + +-I want to be able to get only the incomplete tasks. + +-I want to search for a task and receive a message that says it wasn't found if it doesn't exist. + +-I want to remove tasks from my list. + +-I want to see all the tasks in my list ordered alphabetically in ascending order. + +-I want to see all the tasks in my list ordered alphabetically in descending order. + + + +| Classes | Methods/Properties | Scenario | Outputs | +|-----------------|----------------------------------------------------|---------------------------------|------------------ +|ToDoList.cs |AddTasks(string task) |add task to task list |an extra task in the task list +|ToDoList.cs |ShowALLTasks() |shows all tasks in list |presentation of all the tasks in the list +|ToDoList.cs |changeStatus(string task) |change to(complete/incomplete) | +|ToDoList.cs |findComplete() |finds complete tasks complete tasks +|ToDoList.cs |findIncomplete() |finds incomplete tasks |incomplete tasks +|ToDoList.cs |findIncomplete() |finds incomplete tasks |incomplete tasks +|ToDoList.cs |searchTask(string task) |checks if task exists |message if it does not exist +|ToDoList.cs |removetask(string task) |removes a given task | +|ToDoList.cs |ascendingOrder() |orders alphabetically(ascending) |tasks in ascending alphabetical order +|ToDoList.cs |descendingOrder() |orders alphabetically(descending)|tasks in descending alphabetical order diff --git a/tdd-todo-list.CSharp.Main/Extension.cs b/tdd-todo-list.CSharp.Main/Extension.cs index e4c08912..0e1222ad 100644 --- a/tdd-todo-list.CSharp.Main/Extension.cs +++ b/tdd-todo-list.CSharp.Main/Extension.cs @@ -1,12 +1,155 @@ -using System; + +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Xml.Linq; + + namespace tdd_todo_list.CSharp.Main { public class TodoListExtension { + List todolist = new List(); + public string addTask(string name) + { + ToDoTask task = new ToDoTask(); + task.Name = name; + todolist.Add(task); + return todolist.Last().Name; + + + + } + + public string changeStatus(string name) + + { + + ToDoTask? task = todolist.Find(x => x.Name == name); + if (task != null) + { + if (task.Status == "incomplete") + { + task.Status = "complete"; + return task.Status; + + } + else + { + task.Status = "incomplete"; + return task.Status; + + + + } + } + return "did not exist in list"; + + + } + + public List GetCompletedList() + { + List completedList = new List(); + + foreach (ToDoTask task in todolist) + { + if (task.Status == "complete") + { + completedList.Add(task); + + } + } + return completedList; + } + + public List GetIncompletedList() + { + List incompletedList = new List(); + + foreach (ToDoTask task in todolist) + { + if (task.Status == "incomplete") + { + incompletedList.Add(task); + + } + } + return incompletedList; + } + + + public int listSize() + { + return todolist.Count; + } + + public string RemoveTask(string taskname) + { + ToDoTask? taskToRemove = todolist.Find(task => task.Name == taskname); + if (taskToRemove != null) + { + todolist.Remove(taskToRemove); + return taskToRemove.Name; + } + return "fantes ikke i listen"; + } + + public string SearchTask(string taskname) + { + + ToDoTask? task = todolist.Find(x => x.Name == taskname); + if (task != null) + { + return task.Name; + + } + return "this task does not exist"; + } + + public string showList() + + { + string allTasks = ""; + foreach (ToDoTask task in todolist) + { + + allTasks += " " + task.Name + ": " + task.Status + "\n"; + + } + Console.WriteLine(allTasks); + + + + return allTasks; + + } + + public List SortAlphabetical() + + { + List sorted = todolist.OrderBy(x => x.Name).ToList(); + return sorted; + } + + public List SortAlphabeticalDescending() + { + List sorted = todolist.OrderByDescending(x => x.Name).ToList(); + return sorted; + } + public string getTaskById(int id) + { + ToDoTask? task = todolist.Find(x => x.Id == id); + if (task != null) + { + return task.Name; + } + return "this id does not exist!"; + + } + } } diff --git a/tdd-todo-list.CSharp.Main/ToDoList.cs b/tdd-todo-list.CSharp.Main/ToDoList.cs index 835cb600..36c5802a 100644 --- a/tdd-todo-list.CSharp.Main/ToDoList.cs +++ b/tdd-todo-list.CSharp.Main/ToDoList.cs @@ -3,10 +3,141 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Xml.Linq; namespace tdd_todo_list.CSharp.Main { public class TodoList + { + List todolist = new List(); + public string addTask(string name) + { + ToDoTask task = new ToDoTask(); + task.Name = name; + todolist.Add(task); + return todolist.Last().Name; + + + + } + + public string changeStatus(string name) + + { + + ToDoTask? task = todolist.Find(x => x.Name == name); + if (task != null) { + if (task.Status == "incomplete") + { + task.Status = "complete"; + return task.Status; + + } + else + { + task.Status = "incomplete"; + return task.Status; + + + + } + } + return "did not exist in list"; + + + } + + public List GetCompletedList() + { + List completedList = new List(); + + foreach (ToDoTask task in todolist) + { + if (task.Status == "complete") + { + completedList.Add(task); + + } + } + return completedList; + } + + public List GetIncompletedList() + { + List incompletedList = new List(); + + foreach (ToDoTask task in todolist) + { + if (task.Status == "incomplete") + { + incompletedList.Add(task); + + } + } + return incompletedList; + } + + + + public int listSize() + { + return todolist.Count; + } + + public string RemoveTask(string taskname) + { + ToDoTask? taskToRemove = todolist.Find(task => task.Name == taskname); + if (taskToRemove != null) + { + todolist.Remove(taskToRemove); + return taskToRemove.Name; + } + return "fantes ikke i listen"; + } + + public string SearchTask(string taskname) + { + + ToDoTask? task = todolist.Find(x => x.Name == taskname); + if (task != null) + { + return task.Name; + + } + return "this task does not exist"; + } + + public string showList() + + { + string allTasks = ""; + foreach (ToDoTask task in todolist) + { + + allTasks += " " +task.Name +": " + task.Status+ "\n"; + + } + Console.WriteLine(allTasks); + + + + return allTasks; + + } + + public List SortAlphabetical() + + { + List sorted = todolist.OrderBy(x => x.Name).ToList(); + return sorted; + } + + public List SortAlphabeticalDescending() + { + List sorted = todolist.OrderByDescending(x => x.Name).ToList(); + return sorted; + } + } } diff --git a/tdd-todo-list.CSharp.Main/ToDoTask.cs b/tdd-todo-list.CSharp.Main/ToDoTask.cs new file mode 100644 index 00000000..4dfbaa36 --- /dev/null +++ b/tdd-todo-list.CSharp.Main/ToDoTask.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace tdd_todo_list.CSharp.Main +{ + public class ToDoTask + + { + string name=" "; + static int idCounter = 0; + int id; + string status; + + public ToDoTask() + { + status = "incomplete"; + id = idCounter; + idCounter++; + + } + public int Id + { + get { return id; } + } + + + public string Name + { + get { return name; } + set { name = value; } + } + + public string Status + { + get { return status; } + set { status = value; } + } + } +} diff --git a/tdd-todo-list.CSharp.Test/CoreTests.cs b/tdd-todo-list.CSharp.Test/CoreTests.cs index 084cce19..fa4922d4 100644 --- a/tdd-todo-list.CSharp.Test/CoreTests.cs +++ b/tdd-todo-list.CSharp.Test/CoreTests.cs @@ -1,5 +1,6 @@ using tdd_todo_list.CSharp.Main; using NUnit.Framework; +using System.Diagnostics.CodeAnalysis; namespace tdd_todo_list.CSharp.Test { @@ -8,10 +9,242 @@ public class CoreTests { [Test] - public void FirstTest() + public void addingTasks() { TodoList core = new TodoList(); - Assert.Pass(); + + core.addTask("clean your room"); + int result = core.listSize(); + int expected = 1; + + + + Assert.IsTrue(result == expected); + } + + [Test] + public void viewTasks() + { + TodoList core = new TodoList(); + + + core.addTask("clean your room"); + core.addTask("do dishes"); + core.addTask("do homework"); + core.addTask("do groceries"); + core.changeStatus("do dishes"); + + string result = core.showList(); + string expected = + + " clean your room: incomplete\n" + " " + + "do dishes: complete\n" + " " + + "do homework: incomplete\n" + " " + + "do groceries: incomplete\n"; + + + + Assert.IsTrue(result == expected); + } + [Test] + + public void SetStatus() + { + TodoList core = new TodoList(); + core.addTask("clean your room"); + core.addTask("do dishes"); + core.addTask("do homework"); + core.addTask("do groceries"); + string result = core.changeStatus("do homework"); + result = core.changeStatus("do homework"); + string expected = "incomplete"; + Assert.IsTrue(result == expected); + + } + + [Test] + public void OnlyCompleted() + { + //arrange + TodoList core = new TodoList(); + + + //action + core.addTask("clean your room"); + core.addTask("do dishes"); + core.addTask("do homework"); + core.addTask("do groceries"); + + core.changeStatus("clean your room"); + core.changeStatus("do homework"); + core.changeStatus("do groceries"); + //her er resultat + List result = core.GetCompletedList(); + // hva skal fasiten være + //hva faen skal jeg sammenlikne resultatet med, + // + + + + + + + Assert.That(result.Count == 3); + + + + + } + [Test] + public void OnlyInCompleted() + { + //arrange + TodoList core = new TodoList(); + + + //action + core.addTask("clean your room"); + core.addTask("do dishes"); + core.addTask("do homework"); + core.addTask("do groceries"); + + core.changeStatus("clean your room"); + core.changeStatus("do homework"); + core.changeStatus("do groceries"); + + core.changeStatus("do homework"); + core.changeStatus("do groceries"); + + //her er resultat + List result = core.GetIncompletedList(); + // hva skal fasiten være + //hva faen skal jeg sammenlikne resultatet med, + // + + + + + + + Assert.That(result.Count == 3); + + + + + } + + [Test] + public void TaskNotExists() + { + TodoList core = new TodoList(); + core.addTask("clean your room"); + core.addTask("do dishes"); + core.addTask("do homework"); + core.addTask("do groceries"); + string taskname = "do push ups"; + + + string result = core.SearchTask(taskname); + string expected = "this task does not exist"; + + Assert.That(result == expected); + + } + [Test] + public void TaskExists() + { + TodoList core = new TodoList(); + core.addTask("clean your room"); + core.addTask("do dishes"); + core.addTask("do homework"); + core.addTask("do groceries"); + string taskname = "do groceries"; + + + string result = core.SearchTask(taskname); + string expected = "do groceries"; + + Assert.That(result == expected); + + } + [Test] + public void RemovingFromList() + { + TodoList core = new TodoList(); + core.addTask("clean your room"); + core.addTask("do dishes"); + core.addTask("do homework"); + core.addTask("do groceries"); + string expected = "do dishes"; + + + string result = core.RemoveTask("do dishes"); + + Assert.That(result == expected && core.listSize() == 3); + + + } + [Test] + + public void AlphabeticalAscending() + { + TodoList core = new TodoList(); + core.addTask("clean your room"); + core.addTask("do dishes"); + core.addTask("a little nap"); + core.addTask("do groceries"); + + List tempresult = core.SortAlphabetical(); + List result = new List(); + + foreach (ToDoTask task in tempresult) + { + result.Add(task.Name); + } + + + List expected = new List() + { + "a little nap", + "clean your room", + "do dishes", + "do groceries", + }; + Assert.AreEqual(expected, result); + + + + } + [Test] + public void AlphabeticalDescending() + { + TodoList core = new TodoList(); + core.addTask("clean your room"); + core.addTask("do dishes"); + core.addTask("a little nap"); + core.addTask("do groceries"); + + List tempresult = core.SortAlphabeticalDescending(); + List result = new List(); + + foreach (ToDoTask task in tempresult) + { + result.Add(task.Name); + } + + + List expected = new List() + { + + "do groceries", + "do dishes", + "clean your room", + "a little nap", + }; + Assert.AreEqual(expected, result); + + } } -} \ No newline at end of file + + } \ No newline at end of file diff --git a/tdd-todo-list.CSharp.Test/ExtensionTests.cs b/tdd-todo-list.CSharp.Test/ExtensionTests.cs index bdc82ad7..0cf7f6aa 100644 --- a/tdd-todo-list.CSharp.Test/ExtensionTests.cs +++ b/tdd-todo-list.CSharp.Test/ExtensionTests.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using NUnit.Framework; namespace tdd_todo_list.CSharp.Test { @@ -13,6 +14,25 @@ public class ExtensionTests public ExtensionTests() { _extension = new TodoListExtension(); + } + [Test] + public void IdCheck() + { + TodoListExtension extension= new TodoListExtension(); + + extension.addTask("clean your room"); + extension.addTask("do dishes"); + extension.addTask("do homework"); + extension.addTask("do groceries"); + string expected = "do homework"; + + String result = extension.getTaskById(2); + Assert.That(result, Is.EqualTo(expected)); + + + + + } } } diff --git a/tdd-todo-list.sln b/tdd-todo-list.sln index 66d24763..2a5e0bbd 100644 --- a/tdd-todo-list.sln +++ b/tdd-todo-list.sln @@ -10,6 +10,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{663B0373-6031-46F8-ADD5-9AF01A5E82D5}" ProjectSection(SolutionItems) = preProject .github\workflows\core-criteria.yml = .github\workflows\core-criteria.yml + domain-model.md = domain-model.md .github\workflows\extension-criteria.yml = .github\workflows\extension-criteria.yml README.md = README.md EndProjectSection From c7b7b7d3d73f7aed377c837958d61e03ba9dec60 Mon Sep 17 00:00:00 2001 From: abdi Date: Sun, 12 Jan 2025 19:40:49 +0100 Subject: [PATCH 2/2] extensions are done --- domain-model.md | 28 +++-- tdd-todo-list.CSharp.Main/Extension.cs | 40 ++++++- tdd-todo-list.CSharp.Main/ToDoList.cs | 10 +- tdd-todo-list.CSharp.Main/ToDoTask.cs | 12 +- tdd-todo-list.CSharp.Test/CoreTests.cs | 124 +++++++++----------- tdd-todo-list.CSharp.Test/ExtensionTests.cs | 37 +++++- 6 files changed, 156 insertions(+), 95 deletions(-) diff --git a/domain-model.md b/domain-model.md index 67975d43..b7005375 100644 --- a/domain-model.md +++ b/domain-model.md @@ -22,17 +22,27 @@ -I want to see all the tasks in my list ordered alphabetically in descending order. +-I want to be able to get a task by a unique ID. + +-I want to update the name of a task by providing its ID and a new name. + +-I want to be able to change the status of a task by providing its ID. + +-I want to be able to see the date and time that I created each task. + | Classes | Methods/Properties | Scenario | Outputs | |-----------------|----------------------------------------------------|---------------------------------|------------------ -|ToDoList.cs |AddTasks(string task) |add task to task list |an extra task in the task list -|ToDoList.cs |ShowALLTasks() |shows all tasks in list |presentation of all the tasks in the list +|ToDoList.cs |AddTask(string task) |add task to task list |an extra task in the task list +|ToDoList.cs |ShowList() |shows all tasks in list |presentation of all the tasks in the list |ToDoList.cs |changeStatus(string task) |change to(complete/incomplete) | -|ToDoList.cs |findComplete() |finds complete tasks complete tasks -|ToDoList.cs |findIncomplete() |finds incomplete tasks |incomplete tasks -|ToDoList.cs |findIncomplete() |finds incomplete tasks |incomplete tasks -|ToDoList.cs |searchTask(string task) |checks if task exists |message if it does not exist -|ToDoList.cs |removetask(string task) |removes a given task | -|ToDoList.cs |ascendingOrder() |orders alphabetically(ascending) |tasks in ascending alphabetical order -|ToDoList.cs |descendingOrder() |orders alphabetically(descending)|tasks in descending alphabetical order +|ToDoList.cs |GetCompletedTasks() |finds complete tasks complete tasks +|ToDoList.cs |GetIncompletedTasks() |finds incomplete tasks |incomplete tasks +|ToDoList.cs |SearchTask(string task) |checks if task exists |message if it does not exist +|ToDoList.cs |RemoveTask(string task) |removes a given task | +|ToDoList.cs |SortAlphabeticalAscendingO() |orders alphabetically(ascending) |tasks in ascending alphabetical order +|ToDoList.cs |SortAlphabeticalDescendingO() |orders alphabetically(descending)|tasks in descending alphabetical order +|ToDoListExtension.cs |GetTaskById(int id) |returns a task by giving an id | +|ToDoListExtension.cs |UpdateName(int id, string name) |changes name of the task with the given id | +|ToDoListExtension.cs |UpdateStatusById(int id) |updates status on the task with the given id| diff --git a/tdd-todo-list.CSharp.Main/Extension.cs b/tdd-todo-list.CSharp.Main/Extension.cs index 0e1222ad..c406ec96 100644 --- a/tdd-todo-list.CSharp.Main/Extension.cs +++ b/tdd-todo-list.CSharp.Main/Extension.cs @@ -13,10 +13,12 @@ namespace tdd_todo_list.CSharp.Main public class TodoListExtension { List todolist = new List(); - public string addTask(string name) + int idcounter = 0; + public string AddTask(string name) { ToDoTask task = new ToDoTask(); task.Name = name; + task.Id = idcounter++; todolist.Add(task); return todolist.Last().Name; @@ -24,7 +26,7 @@ public string addTask(string name) } - public string changeStatus(string name) + public string ChangeStatus(string name) { @@ -82,7 +84,7 @@ public List GetIncompletedList() } - public int listSize() + public int ListSize() { return todolist.Count; } @@ -110,7 +112,7 @@ public string SearchTask(string taskname) return "this task does not exist"; } - public string showList() + public string ShowList() { string allTasks = ""; @@ -143,6 +145,11 @@ public List SortAlphabeticalDescending() public string getTaskById(int id) { ToDoTask? task = todolist.Find(x => x.Id == id); + foreach (ToDoTask todo in todolist) + { + Console.WriteLine(todo.Id); + } + if (task != null) { return task.Name; @@ -151,5 +158,30 @@ public string getTaskById(int id) } + public void UpdateName(int id, string name) + { + ToDoTask? task = todolist.Find(x => x.Id == id); + if (task!= null) + { + task.Name = name; + } + + + } + public String UpdateStatusById(int id) + { + ToDoTask? task = todolist.Find(x => x.Id == id); + if (task != null) + { + ChangeStatus(task.Name); + return task.Status; + } + return "the id does not exist"; + + } + + + + } } diff --git a/tdd-todo-list.CSharp.Main/ToDoList.cs b/tdd-todo-list.CSharp.Main/ToDoList.cs index 36c5802a..36ecbec4 100644 --- a/tdd-todo-list.CSharp.Main/ToDoList.cs +++ b/tdd-todo-list.CSharp.Main/ToDoList.cs @@ -11,18 +11,20 @@ public class TodoList { List todolist = new List(); - public string addTask(string name) + + public string AddTask(string name) { ToDoTask task = new ToDoTask(); task.Name = name; todolist.Add(task); + return todolist.Last().Name; } - public string changeStatus(string name) + public string ChangeStatus(string name) { @@ -80,7 +82,7 @@ public List GetIncompletedList() - public int listSize() + public int ListSize() { return todolist.Count; } @@ -108,7 +110,7 @@ public string SearchTask(string taskname) return "this task does not exist"; } - public string showList() + public string ShowList() { string allTasks = ""; diff --git a/tdd-todo-list.CSharp.Main/ToDoTask.cs b/tdd-todo-list.CSharp.Main/ToDoTask.cs index 4dfbaa36..eea00f49 100644 --- a/tdd-todo-list.CSharp.Main/ToDoTask.cs +++ b/tdd-todo-list.CSharp.Main/ToDoTask.cs @@ -9,21 +9,23 @@ namespace tdd_todo_list.CSharp.Main public class ToDoTask { - string name=" "; - static int idCounter = 0; - int id; + string name = ""; + + int id = 0; string status; + DateTime now = DateTime.Now; public ToDoTask() { status = "incomplete"; - id = idCounter; - idCounter++; + Console.WriteLine(now.ToString()); + } public int Id { get { return id; } + set { id = value; } } diff --git a/tdd-todo-list.CSharp.Test/CoreTests.cs b/tdd-todo-list.CSharp.Test/CoreTests.cs index fa4922d4..4270f0e1 100644 --- a/tdd-todo-list.CSharp.Test/CoreTests.cs +++ b/tdd-todo-list.CSharp.Test/CoreTests.cs @@ -13,8 +13,8 @@ public void addingTasks() { TodoList core = new TodoList(); - core.addTask("clean your room"); - int result = core.listSize(); + core.AddTask("clean your room"); + int result = core.ListSize(); int expected = 1; @@ -28,13 +28,13 @@ public void viewTasks() TodoList core = new TodoList(); - core.addTask("clean your room"); - core.addTask("do dishes"); - core.addTask("do homework"); - core.addTask("do groceries"); - core.changeStatus("do dishes"); + core.AddTask("clean your room"); + core.AddTask("do dishes"); + core.AddTask("do homework"); + core.AddTask("do groceries"); + core.ChangeStatus("do dishes"); - string result = core.showList(); + string result = core.ShowList(); string expected = " clean your room: incomplete\n" + " " @@ -51,12 +51,12 @@ public void viewTasks() public void SetStatus() { TodoList core = new TodoList(); - core.addTask("clean your room"); - core.addTask("do dishes"); - core.addTask("do homework"); - core.addTask("do groceries"); - string result = core.changeStatus("do homework"); - result = core.changeStatus("do homework"); + core.AddTask("clean your room"); + core.AddTask("do dishes"); + core.AddTask("do homework"); + core.AddTask("do groceries"); + string result = core.ChangeStatus("do homework"); + result = core.ChangeStatus("do homework"); string expected = "incomplete"; Assert.IsTrue(result == expected); @@ -70,20 +70,17 @@ public void OnlyCompleted() //action - core.addTask("clean your room"); - core.addTask("do dishes"); - core.addTask("do homework"); - core.addTask("do groceries"); - - core.changeStatus("clean your room"); - core.changeStatus("do homework"); - core.changeStatus("do groceries"); - //her er resultat + core.AddTask("clean your room"); + core.AddTask("do dishes"); + core.AddTask("do homework"); + core.AddTask("do groceries"); + + core.ChangeStatus("clean your room"); + core.ChangeStatus("do homework"); + core.ChangeStatus("do groceries"); + List result = core.GetCompletedList(); - // hva skal fasiten være - //hva faen skal jeg sammenlikne resultatet med, - // - + @@ -103,44 +100,33 @@ public void OnlyInCompleted() //action - core.addTask("clean your room"); - core.addTask("do dishes"); - core.addTask("do homework"); - core.addTask("do groceries"); + core.AddTask("clean your room"); + core.AddTask("do dishes"); + core.AddTask("do homework"); + core.AddTask("do groceries"); - core.changeStatus("clean your room"); - core.changeStatus("do homework"); - core.changeStatus("do groceries"); + core.ChangeStatus("clean your room"); + core.ChangeStatus("do homework"); + core.ChangeStatus("do groceries"); - core.changeStatus("do homework"); - core.changeStatus("do groceries"); + core.ChangeStatus("do homework"); + core.ChangeStatus("do groceries"); - //her er resultat List result = core.GetIncompletedList(); - // hva skal fasiten være - //hva faen skal jeg sammenlikne resultatet med, - // - - - - - + Assert.That(result.Count == 3); - - - } [Test] public void TaskNotExists() { TodoList core = new TodoList(); - core.addTask("clean your room"); - core.addTask("do dishes"); - core.addTask("do homework"); - core.addTask("do groceries"); + core.AddTask("clean your room"); + core.AddTask("do dishes"); + core.AddTask("do homework"); + core.AddTask("do groceries"); string taskname = "do push ups"; @@ -154,10 +140,10 @@ public void TaskNotExists() public void TaskExists() { TodoList core = new TodoList(); - core.addTask("clean your room"); - core.addTask("do dishes"); - core.addTask("do homework"); - core.addTask("do groceries"); + core.AddTask("clean your room"); + core.AddTask("do dishes"); + core.AddTask("do homework"); + core.AddTask("do groceries"); string taskname = "do groceries"; @@ -171,16 +157,16 @@ public void TaskExists() public void RemovingFromList() { TodoList core = new TodoList(); - core.addTask("clean your room"); - core.addTask("do dishes"); - core.addTask("do homework"); - core.addTask("do groceries"); + core.AddTask("clean your room"); + core.AddTask("do dishes"); + core.AddTask("do homework"); + core.AddTask("do groceries"); string expected = "do dishes"; string result = core.RemoveTask("do dishes"); - Assert.That(result == expected && core.listSize() == 3); + Assert.That(result == expected && core.ListSize() == 3); } @@ -189,10 +175,10 @@ public void RemovingFromList() public void AlphabeticalAscending() { TodoList core = new TodoList(); - core.addTask("clean your room"); - core.addTask("do dishes"); - core.addTask("a little nap"); - core.addTask("do groceries"); + core.AddTask("clean your room"); + core.AddTask("do dishes"); + core.AddTask("a little nap"); + core.AddTask("do groceries"); List tempresult = core.SortAlphabetical(); List result = new List(); @@ -219,10 +205,10 @@ public void AlphabeticalAscending() public void AlphabeticalDescending() { TodoList core = new TodoList(); - core.addTask("clean your room"); - core.addTask("do dishes"); - core.addTask("a little nap"); - core.addTask("do groceries"); + core.AddTask("clean your room"); + core.AddTask("do dishes"); + core.AddTask("a little nap"); + core.AddTask("do groceries"); List tempresult = core.SortAlphabeticalDescending(); List result = new List(); diff --git a/tdd-todo-list.CSharp.Test/ExtensionTests.cs b/tdd-todo-list.CSharp.Test/ExtensionTests.cs index 0cf7f6aa..9daf1b6f 100644 --- a/tdd-todo-list.CSharp.Test/ExtensionTests.cs +++ b/tdd-todo-list.CSharp.Test/ExtensionTests.cs @@ -20,10 +20,11 @@ public void IdCheck() { TodoListExtension extension= new TodoListExtension(); - extension.addTask("clean your room"); - extension.addTask("do dishes"); - extension.addTask("do homework"); - extension.addTask("do groceries"); + extension.AddTask("clean your room"); + + extension.AddTask("do dishes"); + extension.AddTask("do homework"); + extension.AddTask("do groceries"); string expected = "do homework"; String result = extension.getTaskById(2); @@ -33,6 +34,34 @@ public void IdCheck() + } + + [Test] + public void NameCheck() + { + TodoListExtension extension = new TodoListExtension(); + String expected = "skip breakfast"; + extension.AddTask("wake up"); + extension.AddTask("brush teeth"); + extension.AddTask("eat breakfast"); + extension.UpdateName(2, "skip breakfast"); + String result=extension.getTaskById(2); + + Assert.That (result, Is.EqualTo(expected)); + + } + [Test] + public void TestChangeStatusById() + { + TodoListExtension extension = new TodoListExtension(); + String expected = "complete"; + extension.AddTask("wake up"); + extension.AddTask("brush teeth"); + extension.AddTask("eat breakfast"); + String result = extension.UpdateStatusById(1); + + + Assert.That(result == expected); } } }