コード例 #1
0
        public void FindByAssigneePerson_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.FindByAssignee(assignee);

            //assert
            Assert.Single(foundItemsArray);
        }
コード例 #2
0
        public void FindByAssigneePerson_NullPerson_ReturnsUnassignedItems()
        {
            //findbyAssignee(null) will return the unassigned items

            //arrange
            int    personId   = PersonSequencer.getNext();
            string firstName  = "Fredrik";
            string familyName = "Persson";
            Person assignee1  = new Person(personId, firstName, familyName);

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

            Person assignee3 = null;

            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(assignee1, description1);
            todoItems.AddToDoItem(assignee2, description2);
            todoItems.AddToDoItem(assignee3, description3);

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

            //assert
            Assert.Single(foundItemsArray);
        }
コード例 #3
0
        public void FindByAssigneeInt_FindTwo_Arraysize2()
        {
            //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);

            //assert
            Assert.Equal(2, foundItemsArray.Length);
        }
コード例 #4
0
        public void FindByAssigneeTest()
        {
            //Arrange
            People    people = new People();
            ToDoItems toDo   = new ToDoItems();

            PersonSequencer.Reset();
            TodoSequencer.ResetID();

            Person Jane = people.AddNewPerson(1, "Jane", "Doe");
            Person John = people.AddNewPerson(2, "John", "Doe");

            ToDo item1 = toDo.AddNewToDoNew(1, "Win lotto", false, Jane);
            ToDo item2 = toDo.AddNewToDoNew(2, "Learn to code", true, John);

            //Act

            ToDo[] result  = toDo.FindByAssignee(1);
            ToDo[] result2 = toDo.FindByAssignee(2);

            //Assert
            Assert.Contains(item1, result);
            Assert.Contains(item2, result2);
        }