Пример #1
0
        public void FindByAssigneeInt_NotFound_Arraysize0()
        {
            //arrange
            int    personId   = PersonSequencer.nextPersonId();
            string firstName  = "Fredrik";
            string familyName = "Persson";
            Person assignee   = new Person(personId, firstName, familyName);

            string description1 = "Gå ut med hunden";
            string description2 = "Kela med katten";
            string description3 = "Promenera";

            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);
        }
Пример #2
0
        public void Remove_RemoveFirst_RemoveOnlyOne()
        {
            //arrange
            Todo   myToDo                = null;
            string description1          = "Gå ut med hunden";
            string description2          = "Kela med katten";
            string description3          = "Promenera";
            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);
        }
Пример #3
0
        public void FindByDoneStatus_FindOnlyNotDone_Arraysize3()
        {
            //arrange
            int    personId   = PersonSequencer.nextPersonId();
            string firstName  = "Fredrik";
            string familyName = "Persson";
            Person assignee   = new Person(personId, firstName, familyName);

            string description1 = "Gå ut med hunden";
            string description2 = "Kela med katten";
            string description3 = "Promenera";

            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);
        }
Пример #4
0
        public void FindItemById_FindOne_CorrectDescription()
        {
            //arrange
            int    personId   = PersonSequencer.nextPersonId();
            string firstName  = "Fredrik";
            string familyName = "Persson";
            Person assignee   = new Person(personId, firstName, familyName);

            string description1 = "Gå ut med hunden";
            string description2 = "Kela med katten";

            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);
        }
Пример #5
0
        public void FindItemById_UnknownId_NoneReturned()
        {
            //arrange
            int    personId   = PersonSequencer.nextPersonId();
            string firstName  = "Fredrik";
            string familyName = "Persson";
            Person assignee   = new Person(personId, firstName, familyName);

            string description1 = "Gå ut med hunden";
            string description2 = "Kela med katten";

            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);
        }
Пример #6
0
        public void FindByDoneStatus_TestThatATodoObjectIsFoundAndReturnedUsingItsDoneStatus()
        {
            //Arrange
            string todo_1_description = "Code a calculator application";
            bool   todo_1_status      = true;

            string todo_2_description = "Code a Todo application";
            bool   todo_2_status      = true;

            string todo_3_description = "Code a Hangman application";
            bool   todo_3_status      = false;

            TodoSequencer.reset();
            TodoItems todoItems = new TodoItems();

            Todo todo_1 = todoItems.CreateTodo(todo_1_description);

            todo_1.Done = todo_1_status;
            Todo todo_2 = todoItems.CreateTodo(todo_2_description);

            todo_2.Done = todo_2_status;
            Todo todo_3 = todoItems.CreateTodo(todo_3_description);

            todo_3.Done = todo_3_status;

            Todo[] expected = { todo_1, todo_2 };

            //Act
            Todo[] result = todoItems.FindByDoneStatus(true);

            //Assert
            Assert.Equal(expected, result);
        }
Пример #7
0
        public void Remove_RemoveNull_NothingRemovedNoCrash()
        {
            //arrange
            Todo   myToDo                = null;
            string description1          = "Gå ut med hunden";
            string description2          = "Kela med katten";
            string description3          = "Promenera";
            string description4          = "Läxor";
            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(myToDo);
            int myAdjustedNumber = todoItems.Size();

            //assert
            Assert.Equal(myAdjustedNumber, expectedNumberOfItems);
        }
Пример #8
0
        public void RemoveArrElement_TestThatAGivenObjectIsDeletedFromTheArray()
        {
            //Arrange
            string todo_1_description = "Code a calculator application";
            string todo_2_description = "Code a Todo application";
            string todo_3_description = "Code a Hangman application";
            string todo_4_description = "Test calculator application";
            string todo_5_description = "Test Todo application";

            TodoSequencer.reset();
            TodoItems todoItems = new TodoItems();

            Todo todo_1 = todoItems.CreateTodo(todo_1_description);
            Todo todo_2 = todoItems.CreateTodo(todo_2_description);
            Todo todo_3 = todoItems.CreateTodo(todo_3_description);
            Todo todo_4 = todoItems.CreateTodo(todo_4_description);
            Todo todo_5 = todoItems.CreateTodo(todo_5_description);

            Todo[] result = { todo_1, todo_3, todo_4, todo_5 };

            //Act
            todoItems.RemoveArrElement(todo_2);

            //Assert
            Assert.Equal(result, todoItems.FindAll());
        }
Пример #9
0
        public void FindUnassigned_FindOnlyOne_Arraysize3()
        {
            //arrange
            int    personId   = PersonSequencer.nextPersonId();
            string firstName  = "Fredrik";
            string familyName = "Persson";
            Person assignee   = new Person(personId, firstName, familyName);

            string description1 = "Gå ut med hunden";
            string description2 = "Kela med katten";
            string description3 = "Promenera";

            TodoSequencer.reset();
            TodoItems todoItems = new TodoItems();

            todoItems.Clear();

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

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

            //assert
            Assert.Equal(3, foundItemsArray.Length);
            Assert.Equal(description1, foundItemsArray[0].Description);
        }
Пример #10
0
        public void FindByDoneStatus_FindOnlyOne_Arraysize1()
        {
            //arrange
            int    personId   = PersonSequencer.nextPersonId();
            string firstName  = "Fredrik";
            string familyName = "Persson";
            Person assignee   = new Person(personId, firstName, familyName);

            string description1 = "Gå ut med hunden";
            string description2 = "Kela med katten";

            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);
        }
        public void NextTodoId_getNextTodoId_id()
        {
            //arrange
            TodoSequencer.reset();
            int expectedNextId = 1;
            //act
            int nextId = TodoSequencer.nextTodoId();

            //assert
            Assert.Equal(expectedNextId, nextId);
        }
Пример #12
0
        public void nextTodoIdTest_TestThatTodoIdIsIncrementedAndReturned()
        {
            //Arrange
            int expected = 1;

            //Act
            TodoSequencer.reset();
            int result = TodoSequencer.nextTodoId();

            //Assert
            Assert.Equal(expected, result);
        }
        public void TodoIDTest1()
        {
            // This method test that Todo ID at the begining is not incremented and should be 0
            //Arrange
            int expectedTodoIdValue = 0;
            int actualTodoIDValue   = 0;

            //Act
            TodoSequencer.reset();
            actualTodoIDValue = TodoSequencer.todoId;

            //Assert
            Assert.Equal(expectedTodoIdValue, actualTodoIDValue);
        }
Пример #14
0
        public void resetTest_TestThatTodoIdIsResetToZero()
        {
            //Arrange
            int expected = 1;

            //Act
            TodoSequencer.nextTodoId();
            TodoSequencer.nextTodoId();
            TodoSequencer.nextTodoId();
            TodoSequencer.reset();

            //Assert
            Assert.Equal(expected, TodoSequencer.nextTodoId());
        }
Пример #15
0
        public void TodoConstructionTest_TestForProperConstructionOfTodoObject()
        {
            //Arrange
            int    todoId      = 1;
            string description = "Description of todo_1";

            TodoSequencer.reset();

            //Act
            Todo todo = new Todo(todoId, description);

            //Assert
            Assert.Equal(todoId, todo.todoId);
            Assert.Equal(description, todo.Description);
        }
        public void TodoIDTest2()
        {
            // This method test that Todo ID is getting incremented by nextToDoId().
            //Arrange
            int expectedTodoIdValue = 0;
            int actualTodoIDValue   = 0;

            //Act
            TodoSequencer.reset();
            TodoSequencer.nextToDoId();
            actualTodoIDValue = TodoSequencer.todoId;
            expectedTodoIdValue++;

            //Assert
            Assert.Equal(expectedTodoIdValue, actualTodoIDValue);
        }
        public void TodoIDTest3()
        {
            // This method test that Todo ID is getting reset to 0 by reset().

            //Arrange
            int expectedTodoIdValue = 0;
            int actualTodoIDValue   = 0;

            //Act
            TodoSequencer.nextToDoId(); //sets a non zero toDoId value
            TodoSequencer.reset();
            actualTodoIDValue = TodoSequencer.todoId;

            //Assert
            Assert.Equal(expectedTodoIdValue, actualTodoIDValue);
        }
Пример #18
0
        public void FindById_TestThatATodoObjectIsFoundAndReturnedUsingItsTodoId()
        {
            //Arrange
            string todo_1_description = "Code a calculator application";
            string todo_2_description = "Code a Todo application";

            TodoSequencer.reset();
            TodoItems todoItems = new TodoItems();
            Todo      todo_1    = todoItems.CreateTodo(todo_1_description);
            Todo      todo_2    = todoItems.CreateTodo(todo_2_description);

            Todo expected = todo_2;

            //Act
            Todo todo = todoItems.FindById(2);

            //Assert
            Assert.Equal(expected, todo);
        }
        public void Reset_ResetId_NextToDoId()
        {
            //arrange
            TodoSequencer.reset();
            int expectedResetId = 1;
            // consume 2 id's
            int nextId = TodoSequencer.nextTodoId();

            nextId = TodoSequencer.nextTodoId();


            //act
            TodoSequencer.reset();
            int newId = TodoSequencer.nextTodoId();

            //assert
            Assert.NotEqual(nextId, newId);
            Assert.Equal(expectedResetId, newId);
        }
Пример #20
0
        public void Clear_TestThatPersonObjectsAreClearedFromPersonArray()
        {
            //Arrange
            string todo_1_description = "Code a calculator application";
            string todo_2_description = "Code a Todo application";

            int expected = 0;

            TodoSequencer.reset();
            TodoItems todoItems = new TodoItems();
            Todo      todo_1    = todoItems.CreateTodo(todo_1_description);
            Todo      todo_2    = todoItems.CreateTodo(todo_2_description);

            //Act
            todoItems.Clear();

            //Assert
            Assert.Equal(expected, todoItems.Size());
        }
Пример #21
0
        public void FindByAssignee_TestThatATodoObjectWithNoAssigneeIsFoundAndReturned()
        {
            //Arrange
            string todo_1_description = "Code a calculator application";
            string todo_2_description = "Code a Todo application";
            string todo_3_description = "Code a Hangman application";

            string person_1_Firstname = "Neri";
            string person_1_Lastname  = "Chris";
            string person_2_Firstname = "Joey";
            string person_2_Lastname  = "Ken";

            TodoSequencer.reset();
            TodoItems todoItems = new TodoItems();
            People    people    = new People();

            Person person_1 = people.CreatePerson(person_1_Firstname, person_1_Lastname);
            Person person_2 = people.CreatePerson(person_2_Firstname, person_2_Lastname);

            Todo todo_1 = todoItems.CreateTodo(todo_1_description);

            todo_1.Assignee = null;

            Todo todo_2 = todoItems.CreateTodo(todo_2_description);

            todo_2.Assignee = person_2;

            Todo todo_3 = todoItems.CreateTodo(todo_3_description);

            todo_3.Assignee = person_2;

            Todo[] expected = { todo_1 };

            //Act
            Todo[] result = todoItems.FindByAssignee(null);

            //Assert
            Assert.Equal(expected, result);
        }
Пример #22
0
        public void CreateTodo_TestThatATodoObjectIsCreatedAndReturned()
        {
            //Arrange
            int    todo_1_TodoId      = 1;
            string todo_1_description = "Code a calculator application";

            int    todo_2_TodoId      = 2;
            string todo_2_description = "Code a Todo application";

            TodoSequencer.reset();
            TodoItems todoItems = new TodoItems();

            //Act
            Todo todo_1 = todoItems.CreateTodo(todo_1_description);
            Todo todo_2 = todoItems.CreateTodo(todo_2_description);

            //Assert
            Assert.Equal(todo_1_TodoId, todoItems.FindAll()[0].todoId);
            Assert.Equal(todo_1_description, todoItems.FindAll()[0].Description);

            Assert.Equal(todo_2_TodoId, todoItems.FindAll()[1].todoId);
            Assert.Equal(todo_2_description, todoItems.FindAll()[1].Description);
        }