コード例 #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);
        }
コード例 #2
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);
        }
コード例 #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 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
        private async Task LoadTodoList()
        {
            var todos = await _todoService.GetAll();

            var pendingGroup = TodoItems.FirstOrDefault(t => t.State == TodoItemCompletedState.Pending);

            if (pendingGroup is null)
            {
                pendingGroup = new TodoItemsGroup(TodoItemCompletedState.Pending);
            }
            var completedGroup = TodoItems.FirstOrDefault(t => t.State == TodoItemCompletedState.Completed);

            if (completedGroup is null)
            {
                completedGroup = new TodoItemsGroup(TodoItemCompletedState.Completed);
            }

            var pending = todos.Where(t => !t.Completed).ToList();

            pendingGroup.TodoItems.ReplaceRange(pending);
            var completed = todos.Where(t => t.Completed).ToList();

            completedGroup.TodoItems.ReplaceRange(completed);
            TodoItems.Clear();
            TodoItems.Add(pendingGroup);
            TodoItems.Add(completedGroup);
        }
コード例 #6
0
 public void Deactivate(object parameter)
 {
     if (TodoItems != null)
     {
         TodoItems.Clear();
     }
 }
コード例 #7
0
        async Task ExecuteFetchTodoItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy       = true;
            IsRefreshing = false;

            try
            {
                TodoItems.Clear();
                var todoItems = await todoItemService.GetAll();

                foreach (var item in todoItems)
                {
                    TodoItems.Add(item);
                }
            }
            catch (Exception ex)
            {
                // TODO: show alert
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy       = false;
                IsRefreshing = false;
            }
        }
コード例 #8
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);
        }
コード例 #9
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);
        }
コード例 #10
0
ファイル: TodoItemTest.cs プロジェクト: timborg-del/Todoapp
        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);
        }
コード例 #11
0
        public void FindByAssigneePerson_NullPerson_ReturnsUnassignedItems()
        {
            //findbyAssignee(null) will return the unassigned items

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

            personId = PersonSequencer.nextPersonId();
            Person assignee2 = new Person(personId, "Klara", familyName);

            Person assignee3 = null;

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

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

            //assert
            Assert.Single(foundItemsArray);
        }
コード例 #12
0
ファイル: TodoItemTest.cs プロジェクト: timborg-del/Todoapp
        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);
        }
コード例 #13
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);
        }
コード例 #14
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);
        }
コード例 #15
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);
        }
コード例 #16
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);
        }
コード例 #17
0
ファイル: TodoItemsTest.cs プロジェクト: majictech/TodoItApp
        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);
        }
コード例 #18
0
ファイル: MainContent.cs プロジェクト: averrunci/UwpMvc
 private void ApplyFilter()
 {
     TodoItems.Clear();
     foreach (var item in TodoItemDisplayState.Value == TodoItemState.All ? todoItems : todoItems.Where(i => i.State.Value == TodoItemDisplayState.Value))
     {
         TodoItems.Add(item);
     }
 }
コード例 #19
0
 private async void OnRefreshCommandExecuted()
 {
     TodoItems.Clear();
     foreach (var item in await _apiClient.GetTodoItemsAsync())
     {
         TodoItems.Add(item);
     }
 }
コード例 #20
0
ファイル: TodoItemsTest.cs プロジェクト: majictech/TodoItApp
        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]);
コード例 #21
0
        public void FindAllItems_ClearedItems_EmptyArray()
        {
            //arrange
            TodoItems todoItems = new TodoItems();

            todoItems.Clear();

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

            //assert
            Assert.Empty(itemArray);
        }
コード例 #22
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);
        }
コード例 #23
0
        public void RunSize()
        {
            //Arrange


            TodoItems tasks = new TodoItems();

            tasks.Clear();
            var result = tasks.Size();

            //Act & Assert

            Assert.Equal(0, result);
        }
コード例 #24
0
ファイル: TodoItemsTest.cs プロジェクト: majictech/TodoItApp
        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);
        }
コード例 #25
0
ファイル: TodoItemTest.cs プロジェクト: timborg-del/Todoapp
        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);
        }
コード例 #26
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);
        }
コード例 #27
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);
        }
コード例 #28
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);
        }
コード例 #29
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);
        }
コード例 #30
0
ファイル: TodoItemTest.cs プロジェクト: timborg-del/Todoapp
        [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);
        }