Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
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);
        }