Ejemplo n.º 1
0
        public void TestFindAll()
        {
            //Arrange
            arrayOfItemsV1.CreateANewTodoItem("Byt till vinterdäck", false, null);
            arrayOfItemsV1.CreateANewTodoItem("Damma", true, null);

            //Act
            int size = arrayOfItemsV1.Size();

            Todo[] testTodoItemsArray = arrayOfItemsV1.FindAll();

            //Asset
            Assert.True(size == testTodoItemsArray.Length);
        }
Ejemplo n.º 2
0
        public void FindByDoneStatus()
        {
            // Arrange
            TodoItems todoItems = new TodoItems();

            todoItems.Clear();
            todoItems.CreateTodo("A description");
            todoItems.CreateTodo("Another description");
            Todo[] allTodos = todoItems.FindAll();

            // Act
            allTodos[0].Done = true;
            allTodos[1].Done = false;
            Todo[] doneTodos    = todoItems.FindByDoneStatus(true);
            Todo[] notDoneTodos = todoItems.FindByDoneStatus(false);


            // Assert
            Assert.Equal(allTodos[0], doneTodos[0]);
            Assert.Equal(allTodos[1], notDoneTodos[0]);


            Assert.Single(doneTodos);
            Assert.Single(notDoneTodos);
        }
Ejemplo n.º 3
0
        public void TestFindBytodoItem()
        {
            //Arrange
            Person person = new Person(1856, "Garan", "Persson");


            TodoItems todoItem = new TodoItems();

            todoItem.Clear();


            todoItem.NewTodo("hahaha");           //0
            todoItem.NewTodo("Some stuff to do"); //1
            todoItem.NewTodo("Hohoho");           //2

            Todo[] allTodos = todoItem.FindAll();
            allTodos[1].Assignee = person;
            //act
            Todo[] allAssignee = todoItem.FindByAssignee(person);
            Todo[] Unsigneed   = todoItem.FindUnassignedTodoItem();
            //Assert
            Assert.Equal("Some stuff to do", allAssignee[0].Description);
            Assert.Null(Unsigneed[0].Assignee);
            Assert.Null(Unsigneed[1].Assignee);
        }
Ejemplo n.º 4
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());
        }
Ejemplo n.º 5
0
        public void FindAllItems_FindsAll_CorrectArraySize()
        {
            //arrange
            int    personId   = PersonSequencer.nextPersonId();
            string firstName  = "Peter";
            string familyName = "Jansson";
            Person assignee   = new Person(personId, firstName, familyName);

            int    expectedSizeOfToDoItems = 3;
            string description1            = "Vattna blommor";
            string description2            = "Dammsuga";
            string description3            = "Putsa fönster";

            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);
        }
Ejemplo n.º 6
0
        public void TestFindDoneByStatus()
        {
            //Arrange
            TodoItems todoItem = new TodoItems();

            todoItem.Clear();
            todoItem.NewTodo("String");
            todoItem.NewTodo("Hobo");
            todoItem.NewTodo("Jörge");

            //Hobo is taked out from the list Now i have onely two obejct left
            Todo[] allTodos = todoItem.FindAll();
            allTodos[1].Done = true;
            //Act

            //This is catching teknik
            Todo[] storeFalse = todoItem.FindByDoneStatus(false);
            Todo[] storeTrue  = todoItem.FindByDoneStatus(true);

            //Assert
            Assert.Equal("String", storeFalse[0].Description);
            Assert.Equal("Jörge", storeFalse[1].Description);
            Assert.Equal("Hobo", storeTrue[0].Description);
            Assert.Equal(2, storeFalse.Length);
            Assert.Single(storeTrue);
        }
Ejemplo n.º 7
0
        public void RemoveTodo()
        {
            // Arrange
            TodoItems todoItems = new TodoItems();

            todoItems.Clear();
            todoItems.CreateTodo("A description");
            todoItems.CreateTodo("Another description");
            todoItems.CreateTodo("Good description");
            Todo[] allTodos = todoItems.FindAll();

            // Act
            todoItems.RemoveTodo(allTodos[^ 1]);
Ejemplo n.º 8
0
        public void CheckFindAll_Ok()
        {
            //Arrange
            Todo todo1 = TodoItems.AddNewTodo("Robert Berr");
            Todo todo2 = TodoItems.AddNewTodo("Find the Fox");

            //Act
            Todo[] allArray = TodoItems.FindAll();

            //Assert
            Assert.Equal(todo1, allArray[0]);
            Assert.Equal(todo2, allArray[1]);
        }
Ejemplo n.º 9
0
        public void FindAllItems_ClearedItems_EmptyArray()
        {
            //arrange
            TodoItems todoItems = new TodoItems();

            todoItems.Clear();

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

            //assert
            Assert.Empty(itemArray);
        }
Ejemplo n.º 10
0
        public void RemovePerson()
        {
            //Arrange
            TodoItems todoItem = new TodoItems();

            todoItem.Clear();
            todoItem.NewTodo("Decription");
            todoItem.NewTodo("Do");


            //Act
            int size = todoItem.Size();

            Todo[] todos = todoItem.FindAll();

            todoItem.Remove(todos[0]);


            //Assert
            Assert.Equal(size - 1, todoItem.Size());
            Assert.Equal("Do", todoItem.FindAll()[0].Description);
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
        public void CheckTodoClear_Ok()
        {
            //Arrange
            TodoItems.AddNewTodo("Do this first");
            TodoItems.AddNewTodo("Then you have to do this");
            TodoItems.AddNewTodo("Finaly do this");

            //Act
            TodoItems.Clear();
            Todo[] allArray = TodoItems.FindAll();

            //Assert
            Assert.Empty(allArray);
        }
Ejemplo n.º 13
0
        public void FindByIdExistingTodo()
        {
            //Arrange
            TodoItems newTodoItems = new TodoItems();

            newTodoItems.Clear();
            newTodoItems.NewTodo("This is Description");

            //act
            Todo expected = newTodoItems.FindAll()[0];
            Todo actual   = newTodoItems.FindById(expected.TodoId);

            //Assert
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 14
0
        public void CreateTodoAddsTodo()
        {
            // Arrange
            TodoItems todoItems = new TodoItems();

            todoItems.Clear();
            string desc = "Good description";

            // Act
            todoItems.CreateTodo(desc);
            Todo actualTodo = todoItems.FindAll()[0];

            // Assert
            Assert.Equal(desc, actualTodo.Description);
        }
Ejemplo n.º 15
0
        public void CheckCreateNewTodo_Ok()
        {
            //Arrange
            Todo todo1 = TodoItems.AddNewTodo("Eat a burger");
            Todo todo2 = TodoItems.AddNewTodo("Buy another beer");
            Todo todo3 = TodoItems.AddNewTodo("Get a coffee");
            Todo todo4 = TodoItems.AddNewTodo("Send dad a bottle");

            //Act
            Todo chosenOne = TodoItems.AddNewTodo("Send dad a bottle");

            Todo[] allArray = TodoItems.FindAll();

            //Assert
            Assert.Equal(allArray[allArray.Length - 1], chosenOne);
        }
Ejemplo n.º 16
0
        public void FindAll_ReturnsTheTodoItemsWeAdded()
        {
            // Arrange
            TodoItems todoItems = new TodoItems();

            todoItems.Clear();
            string desc = "A description";

            todoItems.CreateTodo(desc);

            // Act
            Todo todo = todoItems.FindAll()[0];

            // Assert
            Assert.Equal(desc, todo.Description);
        }
Ejemplo n.º 17
0
        public void FindById_GivenNonExistingId_ReturnsNull()
        {
            // Arrange
            TodoItems todoItems = new TodoItems();

            todoItems.Clear();
            todoItems.CreateTodo("A good description");
            Todo todo = todoItems.FindAll()[0];
            int  nonExistingTodoId = todo.TodoId + 54;

            // Act
            Todo foundTodo = todoItems.FindById(nonExistingTodoId);

            // Assert
            Assert.Null(foundTodo);
        }
Ejemplo n.º 18
0
        public void TodoItems_TestCase_9c()
        {
            //testing the FindAll() method of TodoItems class:
            //test to check that a NOT NULL todoArray object is being returned by FindAll().

            //Arrange
            Todo[] expectedTodoArray;

            //Act
            TodoItems todoItems = new TodoItems();

            expectedTodoArray = todoItems.FindAll();

            //Assert
            Assert.NotNull(expectedTodoArray); //should be not null
        }
Ejemplo n.º 19
0
        [Fact]  // ResizeTodoArray
        public void TestNewTodoArray()
        {
            //Arrange
            TodoItems newTodoItems = new TodoItems();

            newTodoItems.Clear();
            newTodoItems.NewTodo("This is Description");
            int expectedSize = 1;
            //Act
            int  actualSize = newTodoItems.Size();
            Todo actualTodo = newTodoItems.FindAll()[0];

            //Assert
            Assert.Equal(expectedSize, actualSize);
            Assert.Equal("This is Description", actualTodo.Description);
        }
Ejemplo n.º 20
0
        public void FindAll()
        {
            //Arrange
            TodoItems newTodoItems = new TodoItems();

            newTodoItems.Clear();
            newTodoItems.NewTodo("This is Description");
            newTodoItems.NewTodo("This is not a Description");


            //act
            Todo[] actual = newTodoItems.FindAll();

            //Assert
            Assert.Equal("This is Description", actual[0].Description);
            Assert.Equal("This is not a Description", actual[1].Description);
        }
Ejemplo n.º 21
0
        public void FindById_ReturnsTheTodoWithSameId()
        {
            // Arrange
            TodoItems todoItems = new TodoItems();

            todoItems.Clear();
            string desc = "A description";

            todoItems.CreateTodo(desc);
            Todo expectedTodo = todoItems.FindAll()[0];

            // Act
            Todo foundTodo = todoItems.FindById(expectedTodo.TodoId);

            // Assert
            Assert.Equal(expectedTodo, foundTodo);
        }
Ejemplo n.º 22
0
        public void CheckRemoveTodoItem_Ok()
        {
            //Arrange
            TodoItems.AddNewTodo("Find a salad");
            TodoItems.AddNewTodo("Eat Chili con carne");
            TodoItems.AddNewTodo("Drink some water");
            TodoItems.AddNewTodo("Finish the assignment");
            Todo[] todoFullArray = TodoItems.FindAll();

            //Act
            TodoItems.RemoveTodoItem(1);
            TodoItems.RemoveTodoItem(3);
            Todo[] nonRemovedTodoArray = TodoItems.FindAll();

            //Assert
            Assert.Equal(todoFullArray[1], nonRemovedTodoArray[0]);
            Assert.Equal(todoFullArray[3], nonRemovedTodoArray[1]);
        }
Ejemplo n.º 23
0
        public void FindByDoneStatus_Ok()
        {
            //Arrange
            Todo todo1 = TodoItems.AddNewTodo("Eat a burger");
            Todo todo2 = TodoItems.AddNewTodo("Buy another beer");
            Todo todo3 = TodoItems.AddNewTodo("Get a coffee");
            Todo todo4 = TodoItems.AddNewTodo("Send dad a bottle");

            //Act
            Todo[] todoArray = TodoItems.FindAll();
            todoArray[1].Done = true;
            todoArray[3].Done = true;
            Todo[] doneArray = TodoItems.FindByDoneStatus(true);

            //Assert
            Assert.Equal(todoArray[1], doneArray[0]);
            Assert.Equal(todoArray[3], doneArray[1]);
        }
Ejemplo n.º 24
0
        public void Remove()
        {
            string todo_1_description = " run ";
            string todo_2_description = " work ";
            string todo_3_description = " eat";


            TodoItems todoItems = new TodoItems();

            Todo todo_1 = todoItems.Newtodo(todo_1_description);
            Todo todo_2 = todoItems.Newtodo(todo_2_description);
            Todo todo_3 = todoItems.Newtodo(todo_3_description);



            todoItems.Remove(todo_2);

            Assert.DoesNotContain(todo_2, todoItems.FindAll());
        }
Ejemplo n.º 25
0
        public void ClearSetsSizeToZeroAndRemovesAllTodoItems()
        {
            // Arrange
            TodoItems todoItems = new TodoItems();

            todoItems.CreateTodo("Good Description");
            todoItems.CreateTodo("Better Description");
            todoItems.CreateTodo("Best Description");
            int expectedSize = 0;

            // Act
            todoItems.Clear();
            int sizeAfterClear             = todoItems.Size();
            int findAllArraySizeAfterClear = todoItems.FindAll().Length;

            // Assert
            Assert.Equal(expectedSize, sizeAfterClear);
            Assert.Equal(expectedSize, findAllArraySizeAfterClear);
        }
Ejemplo n.º 26
0
        public void TodoItems_TestCase_9a()
        {
            //test to check TodoArray is not NULL & empty.

            //Arrange
            Todo[] expectedTodoArray;
            int    expectedTodoArraySize = 0;
            int    actualTodoArraySize   = 0;


            //Act
            TodoItems todoItems = new TodoItems();

            expectedTodoArray   = todoItems.FindAll();
            actualTodoArraySize = todoItems.Size();

            //Assert
            Assert.NotNull(expectedTodoArray);
            Assert.Equal(expectedTodoArraySize, actualTodoArraySize);
        }
Ejemplo n.º 27
0
        public void FindByAssigneeStatusOverload_Ok()
        {
            //Arrange
            Todo todo1 = TodoItems.AddNewTodo("Eat a pizza");
            Todo todo2 = TodoItems.AddNewTodo("Buy another salad");
            Todo todo3 = TodoItems.AddNewTodo("Get a tea");
            Todo todo4 = TodoItems.AddNewTodo("Send mom a bottle");

            //Act
            Person todoPerson = People.AddNewPerson("Adam", "Tuckerberg");

            Todo[] todoArray = TodoItems.FindAll();
            todoArray[0].Assignee = todoPerson;
            todoArray[2].Assignee = todoPerson;

            Todo[] findByAssigneeArray = TodoItems.FindByAssignee(todoPerson);

            //Assert
            Assert.Equal(todoPerson, findByAssigneeArray[0].Assignee);
            Assert.Equal(todoPerson, findByAssigneeArray[1].Assignee);
        }
Ejemplo n.º 28
0
        public void FindByUnAssigned_Ok()
        {
            //Arrange
            Todo todo1 = TodoItems.AddNewTodo("Eat a salad");
            Todo todo2 = TodoItems.AddNewTodo("Buy another car");
            Todo todo3 = TodoItems.AddNewTodo("Get a flower");
            Todo todo4 = TodoItems.AddNewTodo("Send mom the flower");

            //Act
            Person todoPerson = People.AddNewPerson("Krister", "Österberg");

            Todo[] todoArray = TodoItems.FindAll();
            todoArray[0].Assignee = todoPerson;
            todoArray[2].Assignee = todoPerson;

            Todo[] findByUnAssigneeArray = TodoItems.FindUnassignedTodoItems();

            //Assert
            Assert.Equal(todo2, findByUnAssigneeArray[0]);
            Assert.Equal(todo4, findByUnAssigneeArray[1]);
        }
Ejemplo n.º 29
0
        public void FindByAssignee()
        {
            // Arrange
            TodoItems todoItems = new TodoItems();

            todoItems.Clear();
            todoItems.CreateTodo("A description");
            todoItems.CreateTodo("Another description");
            Todo[] allTodos = todoItems.FindAll();

            // Act
            Person person = new Person(12, "Sam ", "Anderson");

            allTodos[1].Assignee = person;
            Todo[] assignedTodos = todoItems.FindByAssignee(person);

            // Assert
            Assert.Equal(allTodos[1], assignedTodos[0]);

            Assert.Single(assignedTodos);
        }
Ejemplo n.º 30
0
        public void FindByAssigneeStatus_Ok()
        {
            //Arrange
            Todo todo1 = TodoItems.AddNewTodo("Eat a burger");
            Todo todo2 = TodoItems.AddNewTodo("Buy another beer");
            Todo todo3 = TodoItems.AddNewTodo("Get a coffee");
            Todo todo4 = TodoItems.AddNewTodo("Send dad a bottle");

            //Act
            Person todoPerson = People.AddNewPerson("Bengan", "Anderssen");

            Todo[] todoArray = TodoItems.FindAll();
            todoArray[0].Assignee = todoPerson;
            todoArray[2].Assignee = todoPerson;

            Todo[] findByAssigneeArray = TodoItems.FindByAssignee(todoPerson.PersonId);

            //Assert
            Assert.Equal(todoPerson, findByAssigneeArray[0].Assignee);
            Assert.Equal(todoPerson, findByAssigneeArray[1].Assignee);
        }