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); }
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); }
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); }
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); }
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); }
public void Deactivate(object parameter) { if (TodoItems != null) { TodoItems.Clear(); } }
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; } }
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); }
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); }
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); }
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); }
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); }
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 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); }
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); }
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); }
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); }
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); } }
private async void OnRefreshCommandExecuted() { TodoItems.Clear(); foreach (var item in await _apiClient.GetTodoItemsAsync()) { TodoItems.Add(item); } }
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]);
public void FindAllItems_ClearedItems_EmptyArray() { //arrange TodoItems todoItems = new TodoItems(); todoItems.Clear(); //act Todo[] itemArray = todoItems.FindAll(); //assert Assert.Empty(itemArray); }
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); }
public void RunSize() { //Arrange TodoItems tasks = new TodoItems(); tasks.Clear(); var result = tasks.Size(); //Act & Assert Assert.Equal(0, result); }
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); }
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); }
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); }
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); }
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); }
[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); }
[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); }