public void Remove_RemoveFirst_RemoveOnlyOne() { //arrange ToDo myToDo = null; string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; 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 void Remove_RemoveNull_NothingRemovedNoCrash() { //arrange ToDo myNullToDo = null; string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; string description4 = "Do the home work."; 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(myNullToDo); int myAdjustedNumber = todoItems.Size(); //assert Assert.Equal(myAdjustedNumber, expectedNumberOfItems); }
public void FindItemById_UnknownId_NoneReturned() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; 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 FindItemById_FindOne_CorrectDescription() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; 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 Clear_clearList_zero() { //arrange int expectedSizeOfToDoItems = 0; string description = "Wash the car."; ToDoItems todoItems = new ToDoItems(); ToDo returnedTodo = todoItems.AddToDoItem(null, description); Assert.Equal(1, todoItems.Size()); //act todoItems.Clear(); //assert Assert.Equal(expectedSizeOfToDoItems, todoItems.Size()); }
public void ClearToDoTest() { //Arrange ToDoItems toDoItems = new ToDoItems(); int expected = 0; //Act toDoItems.ClearToDo(); int arraySize = toDoItems.Size(); //Assert Assert.Equal(arraySize, expected); }
public void FindSizeTest() { //Arrange ToDoItems toDoItems = new ToDoItems(); int size = 1; int toDoId = 1; PersonSequencer.Reset(); string toDo = "Learn to code"; toDoItems.AddNewToDo(toDoId, toDo); //Act int result = toDoItems.Size(); //Assert Assert.Equal(size, result); }
public void AddTodoItem_WithoutAssignee_SizeDescription() { //arrange Person assignee = null; int expectedSizeOfToDoItems = 1; string description = "Shop for groceries."; ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //act ToDo returnedTodo = todoItems.AddToDoItem(assignee, description); //assert Assert.Equal(expectedSizeOfToDoItems, todoItems.Size()); Assert.Equal(description, returnedTodo.Description); }
public void AddTodoItem_WithoutDescription_DescriptionEmpty() { //arrange Person assignee = null; int expectedSizeOfToDoItems = 1; string expectedDescription = ""; string description = null; ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //act ToDo addedTodo = todoItems.AddToDoItem(assignee, description); //assert Assert.Equal(expectedSizeOfToDoItems, todoItems.Size()); Assert.Equal(expectedDescription, addedTodo.Description); }
public void AddTodoItem_WithAssignee_sizeCorrect_descriptionCorrect() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Anna"; string familyName = "Jansson"; Person assignee = new Person(personId, firstName, familyName); int expectedSizeOfToDoItems = 1; string description = "Wash the car."; ToDoItems todoItems = new ToDoItems(); //act ToDo returnedTodo = todoItems.AddToDoItem(assignee, description); //assert Assert.Equal(expectedSizeOfToDoItems, todoItems.Size()); Assert.Equal(description, returnedTodo.Description); }
public void RemoveToDoObjectTest() { //Arrange ToDoItems toDo = new ToDoItems(); TodoSequencer.ResetID(); int result = 1; int idToDoRemove = 2; ToDo toDo1 = toDo.AddNewToDo(1, "Learn to code"); ToDo toDo2 = toDo.AddNewToDo(2, "Get a job"); //Act toDo.RemoveToDoObject(idToDoRemove); int size = toDo.Size(); ToDo[] remaining = toDo.FindAll(); //Assert Assert.Equal(result, size); Assert.Contains(toDo1, remaining); Assert.DoesNotContain(toDo2, remaining); }