コード例 #1
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);
        }
コード例 #2
0
ファイル: TestTodoItems.cs プロジェクト: PNewbranch/TodoIt
        public void TestFindById()
        {
            //Arrange
            arrayOfItemsV1.CreateANewTodoItem("Stryka", false, null);
            Todo testTodo = arrayOfItemsV1.CreateANewTodoItem("Handla", false, null);
            int  testId   = testTodo.TodoId; //få tag på ett id

            arrayOfItemsV1.CreateANewTodoItem("Klippa gräs", false, null);
            arrayOfItemsV1.CreateANewTodoItem("Fäll träd", false, null);

            //Act

            //Asset
            Assert.Equal(testTodo, arrayOfItemsV1.FindById(testId));
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
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);
        }
コード例 #6
0
        public void CheckFindById_Ok()
        {
            //Arrange
            Todo todo1 = TodoItems.AddNewTodo("Drink a beer");
            Todo todo2 = TodoItems.AddNewTodo("Find the Bear");

            //Act
            Todo chosenOne = TodoItems.FindById(todo2.TodoId);

            //Assert
            Assert.Equal(todo2.TodoId, chosenOne.TodoId);
        }
コード例 #7
0
        public void FindUnssignedTodoItems()
        {
            TodoItems todoItems = new TodoItems();

            todoItems.Clear();
            TodoSeqencer.reset();

            todoItems.Newtodo("Run");
            todoItems.Newtodo("Eat");
            todoItems.Newtodo("Sleep");
            todoItems.Newtodo("work");

            Person person1 = new Person(1, "Ulf", "Bengtsson");
            Person person2 = new Person(1, "Peter", "Svensson");

            todoItems.FindById(2).Assignee = person1;
            todoItems.FindById(3).Assignee = person2;

            Todo[] unassignedTodo = todoItems.FindUnassignedTodoItems();

            Assert.Equal(2, unassignedTodo.Length);
        }
コード例 #8
0
        public void FindByAssignee()
        {
            TodoItems todoItems = new TodoItems();

            todoItems.Clear();
            TodoSeqencer.reset();

            todoItems.Newtodo("Run");
            todoItems.Newtodo("Eat");
            todoItems.Newtodo("Sleep");
            todoItems.Newtodo("work");

            Person person1 = new Person(1, "Haris", "Gusinac");
            Person person2 = new Person(2, "Pontus", "Eriksson");

            todoItems.FindById(1).Assignee = person1;
            todoItems.FindById(2).Assignee = person2;
            todoItems.FindById(4).Assignee = person2;

            Todo[] todoAssigneePerson2 = todoItems.FindByAssignee(person2);

            Assert.Equal(2, todoAssigneePerson2.Length);
        }
コード例 #9
0
ファイル: TodoItemTest.cs プロジェクト: timborg-del/Todoapp
        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);
        }
コード例 #10
0
        public void FindById()
        {
            Todo      todo;
            TodoItems todoItems = new TodoItems();

            todoItems.Clear();
            TodoSeqencer.reset();

            todoItems.Newtodo("Run");
            todoItems.Newtodo("Eat");
            todoItems.Newtodo("Sleep");

            todo = todoItems.FindById(1);
            Assert.Equal("Run", todo.Description);
            Assert.Equal(1, todo.TodoId);

            todo = todoItems.FindById(2);
            Assert.Equal("Eat", todo.Description);
            Assert.Equal(2, todo.TodoId);

            todo = todoItems.FindById(3);
            Assert.Equal("Sleep", todo.Description);
            Assert.Equal(3, todo.TodoId);
        }
コード例 #11
0
ファイル: TodoItemsTest.cs プロジェクト: majictech/TodoItApp
        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);
        }
コード例 #12
0
ファイル: TodoItemTest.cs プロジェクト: timborg-del/Todoapp
        [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);
        }
コード例 #13
0
ファイル: TodoItemsTest.cs プロジェクト: majictech/TodoItApp
        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);
        }
コード例 #14
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);
        }
コード例 #15
0
ファイル: TodoItemsTest.cs プロジェクト: codeatom/ToDoApp
        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);
        }
コード例 #16
0
        public void FindbyId()
        {
            Todo      todo;
            TodoItems todoItems = new TodoItems();


            //Arrange
            todoItems.Newtodo("run");
            Todo tofind = todoItems.Newtodo("work");

            todoItems.Newtodo("eat");


            //Act
            todo = todoItems.FindById(tofind.TodoId);

            //Assert
            Assert.Equal(tofind.Description, todo.Description);
            Assert.Equal(tofind.TodoId, todo.TodoId);
        }
コード例 #17
0
        public void TodoItems_TestCase_9d()
        {
            //testing the FindById() method of TodoItems class:
            //test to check whether this method retruns the same todo that was created here.

            //Arrange
            int    expectedTodoID;
            int    actualTodoID;
            String desc = "TestDesc";

            //Act
            TodoItems todoItems    = new TodoItems();
            Todo      expectedTodo = todoItems.addNewTodo(desc);

            expectedTodoID = expectedTodo.TodoId;

            Todo actualTodo = todoItems.FindById(expectedTodoID);

            actualTodoID = actualTodo.TodoId;

            //Assert
            Assert.Equal(expectedTodoID, actualTodoID); //should be not null
        }