Exemplo n.º 1
0
        public void RunFindUnassignedTodoItems()
        {
            //Arrange

            TodoItems tasks  = new TodoItems();
            People    people = new People();

            PersonSequencer.Reset();
            TodoSequencer.Reset();
            tasks.Clear();
            people.Clear();

            Person firstPerson = people.NewPerson("Anders", "Karlsson");

            Person secondPerson = people.NewPerson("Bengt", "Andersson");

            Todo firstTodo = tasks.NewTodo("Cleaning floor");

            Todo secondTodo = tasks.NewTodo("Making clear code");

            firstTodo.Assignee = firstPerson;

            //secondTodo.Assignee = secondPerson;

            Todo[] newArray = new Todo[0];

            //Act
            Todo[] actual = tasks.FindUnassignedTodoItems();

            //Assert
            Assert.NotEqual(newArray, actual);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public void RunNewTodo()
        {
            //Arrange
            TodoItems tasks = new TodoItems();

            string firstDescription  = "Clean floor";
            string secondDescription = "Code";

            tasks.Clear();
            //Act
            Todo firstTodo  = tasks.NewTodo(firstDescription);
            Todo secondTodo = tasks.NewTodo(secondDescription);

            //Assert
            Assert.NotEqual(firstTodo, secondTodo);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        public void RunItemRemove()
        {
            //Arange
            TodoItems tasks = new TodoItems();

            TodoSequencer.Reset();
            tasks.Clear();

            Todo firstTodo = tasks.NewTodo("Cleaning floor");

            Todo secondTodo = tasks.NewTodo("Making clear code");

            Todo thirdTodo = tasks.NewTodo("Fixing mistakes");

            Todo[] newArray = new Todo[0];

            //Act
            Todo[] actual = tasks.Remove(2);

            //Assert
            Assert.NotEqual(newArray, actual);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        public void RunFindByDoneStatus()
        {
            //Arrange
            string firstDescription  = "nothing";
            string secondDescription = "something";

            TodoItems tasks = new TodoItems();

            tasks.Clear();

            Todo firstTodo  = tasks.NewTodo(firstDescription);
            Todo secondTodo = tasks.NewTodo(secondDescription);

            Todo[] newArray = new Todo[0];

            //Act

            Todo[] actual = tasks.FindByDoneStatus(false);

            //Assert

            Assert.NotEqual(newArray, actual);
        }
Exemplo n.º 9
0
        public void RunFindAll()
        {
            //Arrange

            string firstDescription  = "Making dinner";
            string secondDescription = "Send emails";

            TodoItems tasks = new TodoItems();

            tasks.Clear();
            Todo firstTodo  = tasks.NewTodo(firstDescription);
            Todo secondTodo = tasks.NewTodo(secondDescription);

            Todo[] actual = tasks.FindAll();

            Todo[] newArray = new Todo[2] {
                firstTodo, secondTodo
            };

            //Act & Assert

            Assert.Equal(newArray, actual);
        }
Exemplo n.º 10
0
        public void RunFindByAssigneePersonId()
        {
            //Arange
            TodoItems tasks  = new TodoItems();
            People    people = new People();

            PersonSequencer.Reset();
            TodoSequencer.Reset();
            tasks.Clear();
            people.Clear();

            Person firstPerson = people.NewPerson("Anders", "Karlsson");

            Person secondPerson = people.NewPerson("Bengt", "Andersson");

            Todo firstTodo = tasks.NewTodo("Cleaning floor");

            Todo secondTodo = tasks.NewTodo("Making clear code");

            firstTodo.Assignee = firstPerson;

            secondTodo.Assignee = secondPerson;

            Todo[] newArray = new Todo[1] {
                firstTodo
            };

            //Act
            Todo[] actual = tasks.FindByAssignee(2);

            //Assert
            Assert.NotEqual(newArray, actual);

            // Cannot see the person object in test results
            // Assert.Equal(newArray, actual);
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
        public void TodoArrayLength()
        {
            //Arrange
            TodoItems newTodoItems = new TodoItems();

            newTodoItems.Clear();
            newTodoItems.NewTodo("This is Description");
            int expected = 1;
            //Act
            int actual = newTodoItems.Size();


            //Assert
            Assert.Equal(expected, actual);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
        [Fact] // FindByIdNonExistingTodo
        public void FindByIdNonExistingTodo()
        {
            //Arrange
            TodoItems newTodoItems = new TodoItems();

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

            // Act

            Todo actual   = newTodoItems.FindById(2);;
            Todo expected = null;

            //Assert
            Assert.Equal(expected, actual);
        }
Exemplo n.º 15
0
        public void RunFindById()
        {
            //Arrange

            string description = "nothing";

            TodoItems tasks = new TodoItems();

            tasks.Clear();
            Todo todo = tasks.NewTodo(description);

            //Act

            Todo actual = tasks.FindById(todo.TodoId);  //Why using todo.TodoId here?

            //Assert

            Assert.Equal(todo, actual);
        }