public void FindItemById_FindOne_CorrectDescription() { //arrange int personId = PersonSequencer.nextPersonId(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Gå ut med hunden"; string description2 = "Kela med katten"; TodoSequencer.reset(); TodoItems todoItems = new TodoItems(); todoItems.Clear(); //add 2 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); int size = todoItems.Size(); //act Todo foundLastItem = todoItems.FindById(size); Todo foundFirstItem = todoItems.FindById(1); //assert Assert.Equal(description2, foundLastItem.Description); Assert.Equal(description1, foundFirstItem.Description); }
public void FindItemById_UnknownId_NoneReturned() { //arrange int personId = PersonSequencer.nextPersonId(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Gå ut med hunden"; string description2 = "Kela med katten"; TodoSequencer.reset(); TodoItems todoItems = new TodoItems(); todoItems.Clear(); //add 2 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); int size = todoItems.Size(); //act Todo foundItem = todoItems.FindById(size + 3); //assert Assert.Null(foundItem); }
public void Remove_RemoveNull_NothingRemovedNoCrash() { //arrange Todo myToDo = null; string description1 = "Gå ut med hunden"; string description2 = "Kela med katten"; string description3 = "Promenera"; string description4 = "Läxor"; int expectedNumberOfItems = 4; TodoSequencer.reset(); TodoItems todoItems = new TodoItems(); todoItems.Clear(); //add 4 items todoItems.AddToDoItem(null, description1); todoItems.AddToDoItem(null, description2); todoItems.AddToDoItem(null, description3); todoItems.AddToDoItem(null, description4); //act todoItems.Remove(myToDo); int myAdjustedNumber = todoItems.Size(); //assert Assert.Equal(myAdjustedNumber, expectedNumberOfItems); }
public void Remove_RemoveFirst_RemoveOnlyOne() { //arrange Todo myToDo = null; string description1 = "Gå ut med hunden"; string description2 = "Kela med katten"; string description3 = "Promenera"; int expectedNumberOfItems = 2; TodoSequencer.reset(); TodoItems todoItems = new TodoItems(); todoItems.Clear(); //add 3 items int myInitialNumber = todoItems.Size(); myToDo = todoItems.AddToDoItem(null, description1); todoItems.AddToDoItem(null, description2); todoItems.AddToDoItem(null, description3); //act todoItems.Remove(myToDo); int myAdjustedNumber = todoItems.Size(); //assert Assert.Equal(description1, myToDo.Description); Assert.NotEqual(myInitialNumber, myAdjustedNumber); Assert.Equal(expectedNumberOfItems, myAdjustedNumber); }
public Todo(string description, bool status, Person assignee) { this.todoId = TodoSequencer.CreateNextTodoId(); this.description = description; this.done = status; this.assignee = assignee; }
public void RunFindUnassignedTodoItems() { //Arrange TodoItems tasks = new TodoItems(); People people = new People(); PersonSequencer.Reset(); TodoSequencer.Reset(); tasks.Clear(); people.Clear(); Person firstPerson = people.NewPerson("Anders", "Karlsson"); Person secondPerson = people.NewPerson("Bengt", "Andersson"); Todo firstTodo = tasks.NewTodo("Cleaning floor"); Todo secondTodo = tasks.NewTodo("Making clear code"); firstTodo.Assignee = firstPerson; //secondTodo.Assignee = secondPerson; Todo[] newArray = new Todo[0]; //Act Todo[] actual = tasks.FindUnassignedTodoItems(); //Assert Assert.NotEqual(newArray, actual); }
public void RemoveArrElement_TestThatAGivenObjectIsDeletedFromTheArray() { //Arrange string todo_1_description = "Code a calculator application"; string todo_2_description = "Code a Todo application"; string todo_3_description = "Code a Hangman application"; string todo_4_description = "Test calculator application"; string todo_5_description = "Test Todo application"; TodoSequencer.reset(); TodoItems todoItems = new TodoItems(); Todo todo_1 = todoItems.CreateTodo(todo_1_description); Todo todo_2 = todoItems.CreateTodo(todo_2_description); Todo todo_3 = todoItems.CreateTodo(todo_3_description); Todo todo_4 = todoItems.CreateTodo(todo_4_description); Todo todo_5 = todoItems.CreateTodo(todo_5_description); Todo[] result = { todo_1, todo_3, todo_4, todo_5 }; //Act todoItems.RemoveArrElement(todo_2); //Assert Assert.Equal(result, todoItems.FindAll()); }
public void FindByAssigneeInt_NotFound_Arraysize0() { //arrange int personId = PersonSequencer.nextPersonId(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Gå ut med hunden"; string description2 = "Kela med katten"; string description3 = "Promenera"; TodoSequencer.reset(); TodoItems todoItems = new TodoItems(); todoItems.Clear(); //add 3 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); todoItems.AddToDoItem(null, description3); //act Todo[] foundItemsArray = todoItems.FindByAssignee(personId + 10); //assert Assert.Empty(foundItemsArray); }
public void FindUnassignedTest() { // Arrange People people = new People(); TodoItems todo = new TodoItems(); PersonSequencer.Reset(); TodoSequencer.Reset(); Person lasse = people.NewPerson("Lasse", "Nääf"); Person albin = people.NewPerson("Albin", "Ek"); Todo job1 = todo.NewTodoItem("Do this", false, lasse); Todo job2 = todo.NewTodoItem("Do this", true, lasse); Todo job3 = todo.NewTodoItem("Do this", true, albin); Todo jobRight = todo.NewTodoItem("This is the one"); Todo jobRight2 = todo.NewTodoItem("This is the other one"); // Act Todo[] actual = todo.FindUnassignedTodoItems(); // Assert Assert.True(actual.Length == 2); Assert.Contains(jobRight, actual); Assert.Contains(jobRight2, actual); Assert.DoesNotContain(job1, actual); Assert.DoesNotContain(job2, actual); Assert.DoesNotContain(job3, actual); }
public void RemoveTodoItemTest() { // Arrange TodoItems todo = new TodoItems(); TodoSequencer.Reset(); int expected = 4; int taskId = 2; //creates many todo items Todo job1 = todo.NewTodoItem("Do this"); Todo job2 = todo.NewTodoItem("Do that"); Todo job3 = todo.NewTodoItem("Do this again"); Todo job4 = todo.NewTodoItem("This is the job"); Todo job5 = todo.NewTodoItem("This is the other job"); // Act todo.RemoveTodoItem(taskId); int size = todo.Size(); // get size Todo[] actual = todo.FindAllTodo(); //get array // Assert Assert.Equal(expected, size); Assert.Contains(job1, actual); Assert.DoesNotContain(job2, actual);// checkthat it has actually been removed Assert.Contains(job3, actual); Assert.Contains(job4, actual); Assert.Contains(job5, actual); }
public void FindByAssigneePersonTest() { // Arrange People people = new People(); TodoItems todo = new TodoItems(); PersonSequencer.Reset(); TodoSequencer.Reset(); Person lasse = people.NewPerson("Lasse", "Nääf"); Person albin = people.NewPerson("Albin", "Ek"); Todo job1 = todo.NewTodoItem("Do this", false, lasse); Todo job2 = todo.NewTodoItem("Do this", true, lasse); Todo job3 = todo.NewTodoItem("Do this", true, albin); // Act Todo[] actual = todo.FindByAssignee(lasse); //uses person object as parameter Todo[] actual2 = todo.FindByAssignee(albin); // Assert Assert.True(actual.Length == 2); Assert.True(actual2.Length == 1); Assert.Contains(job1, actual); Assert.Contains(job2, actual); Assert.Contains(job3, actual2); }
public void FindByDoneStatusTest() { // Arrange People people = new People(); TodoItems todo = new TodoItems(); PersonSequencer.Reset(); TodoSequencer.Reset(); Person lasse = people.NewPerson("Lasse", "Nääf"); Person nils = people.NewPerson("Nils", "Korv"); Person albin = people.NewPerson("Albin", "Ek"); Todo job1 = todo.NewTodoItem("Do this", false, lasse);// sets false to check that it is excluded in method Todo job2 = todo.NewTodoItem("Do this", true, nils); Todo job3 = todo.NewTodoItem("Do this", true, albin); // Act Todo[] actual = todo.FindByDoneStatus(); // Assert Assert.True(actual.Length == 2);// checks that its actually two objects instead of three Assert.Contains(job2, actual); Assert.Contains(job3, actual); Assert.DoesNotContain(job1, actual); }
public void TodoFindByIdTest() { // Arrange int todoId = 1; int todoId2 = 2; int todoId3 = 3; TodoItems todo = new TodoItems(); TodoSequencer.Reset(); todo.NewTodoItem("Do this"); todo.NewTodoItem("Do that"); // Act Todo actual = todo.FindByIdTodo(todoId); Todo actual2 = todo.FindByIdTodo(todoId2); Todo actual3 = todo.FindByIdTodo(todoId3); // Assert Assert.Contains("Do this", actual.ToDoInformation()); Assert.Contains("Do that", actual2.ToDoInformation()); Assert.True(actual3 == null); }
public void FindUnassigned_FindOnlyOne_Arraysize3() { //arrange int personId = PersonSequencer.nextPersonId(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Gå ut med hunden"; string description2 = "Kela med katten"; string description3 = "Promenera"; TodoSequencer.reset(); TodoItems todoItems = new TodoItems(); todoItems.Clear(); //add 4 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(null, description1); todoItems.AddToDoItem(null, description2); todoItems.AddToDoItem(null, description3); //act Todo[] foundItemsArray = todoItems.FindUnassignedTodoItems(); //assert Assert.Equal(3, foundItemsArray.Length); Assert.Equal(description1, foundItemsArray[0].Description); }
public void FindByDoneStatus_TestThatATodoObjectIsFoundAndReturnedUsingItsDoneStatus() { //Arrange string todo_1_description = "Code a calculator application"; bool todo_1_status = true; string todo_2_description = "Code a Todo application"; bool todo_2_status = true; string todo_3_description = "Code a Hangman application"; bool todo_3_status = false; TodoSequencer.reset(); TodoItems todoItems = new TodoItems(); Todo todo_1 = todoItems.CreateTodo(todo_1_description); todo_1.Done = todo_1_status; Todo todo_2 = todoItems.CreateTodo(todo_2_description); todo_2.Done = todo_2_status; Todo todo_3 = todoItems.CreateTodo(todo_3_description); todo_3.Done = todo_3_status; Todo[] expected = { todo_1, todo_2 }; //Act Todo[] result = todoItems.FindByDoneStatus(true); //Assert Assert.Equal(expected, result); }
public void FindByDoneStatus_FindOnlyNotDone_Arraysize3() { //arrange int personId = PersonSequencer.nextPersonId(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Gå ut med hunden"; string description2 = "Kela med katten"; string description3 = "Promenera"; TodoSequencer.reset(); TodoItems todoItems = new TodoItems(); todoItems.Clear(); //add 3 not done todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); todoItems.AddToDoItem(assignee, description3); //set one of the items to done. Todo itemToBeDone = todoItems.FindById(1); itemToBeDone.Done = true; //act Todo[] foundItemsArray = todoItems.FindByDoneStatus(false); //assert Assert.Equal(2, foundItemsArray.Length); }
public void FindByDoneStatus_FindOnlyOne_Arraysize1() { //arrange int personId = PersonSequencer.nextPersonId(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Gå ut med hunden"; string description2 = "Kela med katten"; TodoSequencer.reset(); TodoItems todoItems = new TodoItems(); todoItems.Clear(); //add 2 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); //set one item to done. Todo itemToBeDone = todoItems.FindById(1); itemToBeDone.Done = true; //act Todo[] foundItemsArray = todoItems.FindByDoneStatus(true); //assert Assert.Single(foundItemsArray); Assert.Equal(description1, foundItemsArray[0].Description); }
public void IncreaseTodoSequencer() //vi testar klassen TodoSequencer, att räkna upp { //Arrange int todoId1 = TodoSequencer.CreateNextTodoId(); int todoId2 = TodoSequencer.CreateNextTodoId(); //Act //Assert Assert.True(todoId1 < todoId2); }
public void NextTodoId_getNextTodoId_id() { //arrange TodoSequencer.reset(); int expectedNextId = 1; //act int nextId = TodoSequencer.nextTodoId(); //assert Assert.Equal(expectedNextId, nextId); }
public void IncresTodoTest() { // Arrange int oldvalue = TodoSequencer.NextToDoId(); int expectation = oldvalue + 1; //This my own countup add oldvalue to + 1 and thats my expectation // Act int newvalue = TodoSequencer.NextToDoId(); // Asser Assert.Equal(expectation, newvalue); }
public void nextTodoIdTest_TestThatTodoIdIsIncrementedAndReturned() { //Arrange int expected = 1; //Act TodoSequencer.reset(); int result = TodoSequencer.nextTodoId(); //Assert Assert.Equal(expected, result); }
public void Reset_to_zero() { //Arrange int todoId = 15; //Act TodoSequencer.Reset(); todoId = TodoSequencer.NextTodoId(); //Assert Assert.Equal(1, todoId); }
public void TestIncreaseToDoSequence() { //Arrange int toDoId = 0; int nextToDoID = 1; //Act int newTdID = TodoSequencer.NextToDo(); //Assert Assert.Equal(newTdID, nextToDoID); }
public void ResetTodoSequencer() //vi testar klassen TodoSequencer, att nollställa { //Arrange int todoId3 = TodoSequencer.CreateNextTodoId(); int todoId4 = TodoSequencer.CreateNextTodoId(); //Act TodoSequencer.ResetTodoId(); //denna nollställer bara, inget returvärde (void) int todoId5 = TodoSequencer.CreateNextTodoId(); //Assert Assert.True(todoId5 == 1); }
public void TodoIDTest1() { // This method test that Todo ID at the begining is not incremented and should be 0 //Arrange int expectedTodoIdValue = 0; int actualTodoIDValue = 0; //Act TodoSequencer.reset(); actualTodoIDValue = TodoSequencer.todoId; //Assert Assert.Equal(expectedTodoIdValue, actualTodoIDValue); }
public void TodoIdCountsUp() { // Arrange int oldvalue = TodoSequencer.NextTodoId(); int expected = oldvalue + 1; // Act int result = TodoSequencer.NextTodoId(); // Asssert Assert.Equal(expected, result); }
public void resetTest_TestThatTodoIdIsResetToZero() { //Arrange int expected = 1; //Act TodoSequencer.nextTodoId(); TodoSequencer.nextTodoId(); TodoSequencer.nextTodoId(); TodoSequencer.reset(); //Assert Assert.Equal(expected, TodoSequencer.nextTodoId()); }
public void TestTdResetSequence() { //Arrange TodoSequencer.NextToDo(); int toDoTdReset = 1; //Act TodoSequencer.ResetID(); int resetTdId = TodoSequencer.NextToDo(); //Assert Assert.Equal(resetTdId, toDoTdReset); }
public void TodoConstructionTest_TestForProperConstructionOfTodoObject() { //Arrange int todoId = 1; string description = "Description of todo_1"; TodoSequencer.reset(); //Act Todo todo = new Todo(todoId, description); //Assert Assert.Equal(todoId, todo.todoId); Assert.Equal(description, todo.Description); }
public void FindAllTest() { //Arrange TodoSequencer.ResetID(); ToDoItems toDo = new ToDoItems(); toDo.AddNewToDo(1, "Win the lotto"); toDo.AddNewToDo(2, "Learn to code"); //Act ToDo[] result = toDo.FindAll(); //Assert Assert.True(result.Length == 2); }