Example #1
0
        public void FindAllItems_FindsAll_ArraySizeOK()
        {
            //arrange
            int    personId   = PersonSequencer.getNext();
            string firstName  = "Peter";
            string familyName = "Jansson";
            Person assignee   = new Person(personId, firstName, familyName);

            int    expectedSizeOfToDoItems = 3;
            string description1            = "Walk the dog.";
            string description2            = "Cuddle with cat.";
            string description3            = "Take a walk.";

            ToDoItems todoItems = new ToDoItems();

            todoItems.Clear();

            //add 3 items
            todoItems.AddToDoItem(assignee, description1);
            todoItems.AddToDoItem(assignee, description2);
            todoItems.AddToDoItem(null, description3);

            //act
            ToDo[] itemArray = todoItems.FindAll();

            //assert
            Assert.Equal(expectedSizeOfToDoItems, itemArray.Length);
        }
Example #2
0
        public void FindAllItems_ClearedItems_EmptyArray()
        {
            //arrange
            ToDoItems todoItems = new ToDoItems();

            todoItems.Clear();

            //act
            ToDo[] itemArray = todoItems.FindAll();

            //assert
            Assert.Empty(itemArray);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }