Exemple #1
0
        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);
        }
Exemple #2
0
        public void FindUnassigned_FindOnlyOne_Arraysize1()
        {
            //arrange
            int    personId   = PersonSequencer.getNext();
            string firstName  = "Fredrik";
            string familyName = "Persson";
            Person assignee   = new Person(personId, firstName, familyName);

            personId = PersonSequencer.getNext();
            Person assignee2 = new Person(personId, "Clara", familyName);

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

            ToDoSequencer.Reset();
            ToDoItems todoItems = new ToDoItems();

            todoItems.Clear();

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

            //act
            ToDo[] foundItemsArray = todoItems.FindUnassignedTodoItems();

            //assert
            Assert.Single(foundItemsArray);
            Assert.Equal(description3, foundItemsArray[0].Description);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        public void FindByDoneStatus_FindOnlyNotDone_Arraysize3()
        {
            //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.";
            string description3 = "Take a walk.";

            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);
        }
Exemple #5
0
        public void FindByAssigneeInt_NotFound_Arraysize0()
        {
            //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.";
            string description3 = "Take a walk.";

            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);
        }
Exemple #6
0
        public void FindByDoneStatus_FindOnlyOne_Arraysize1()
        {
            //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);

            //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);
        }
Exemple #7
0
        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);
        }
Exemple #8
0
        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 NextTodoId_getNextTodoId_id()
        {
            //arrange
            ToDoSequencer.Reset();
            int expectedNextId = 1;

            //act
            int fetchedNextId = ToDoSequencer.NextId();

            //assert
            Assert.Equal(expectedNextId, fetchedNextId);
        }
        public void Reset_ResetIdGetNewIdsReset_RightToDoIdFromNewGet()
        {
            //arrange
            ToDoSequencer.Reset();
            int expectedResetId = 1;

            //act
            // consume 2 id's to make a first grip of the static member
            int nextId = ToDoSequencer.NextId();

            nextId = ToDoSequencer.NextId();

            ToDoSequencer.Reset();
            int newId = ToDoSequencer.NextId();

            //assert
            Assert.NotEqual(nextId, newId);
            Assert.Equal(expectedResetId, newId);
        }