public void FindByAssigneeInt_NotFound_Arraysize0() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; 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 FindByAssigneePerson_NullPerson_ReturnsUnassignedItems() { //findbyAssignee(null) will return the unassigned items //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee1 = new Person(personId, firstName, familyName); personId = PersonSequencer.getNext(); Person assignee2 = new Person(personId, "Clara", familyName); Person assignee3 = null; string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; //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 FindByDoneStatus_FindOnlyNotDone_Arraysize3() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; 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 FindByDoneStatus_FindOnlyOne_Arraysize1() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; 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 FindItemById_UnknownId_NoneReturned() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; 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 FindUnassigned_FindOnlyOne_Arraysize1() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); personId = PersonSequencer.getNext(); Person assignee2 = new Person(personId, "Clara", familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; ToDoSequencer.Reset(); ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //add 3 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee2, description2); todoItems.AddToDoItem(null, description3); //act ToDo[] foundItemsArray = todoItems.FindUnassignedTodoItems(); //assert Assert.Single(foundItemsArray); Assert.Equal(description3, foundItemsArray[0].Description); }
public void Remove_RemoveFirst_RemoveOnlyOne() { //arrange ToDo myToDo = null; string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; 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 FindItemById_FindOne_CorrectDescription() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; 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); }
public void FindAllItems_FindsAll_ArraySizeOK() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Peter"; string familyName = "Jansson"; Person assignee = new Person(personId, firstName, familyName); int expectedSizeOfToDoItems = 3; string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; 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); }
async Task ExecuteRefreshCommand() { if (IsBusy) { return; } IsBusy = true; try { var todos = await azureService.GetToDos(); ToDoItems.Clear(); foreach (var todo in todos) { ToDoItems.Add(todo); } } catch (Exception ex) { Acr.UserDialogs.UserDialogs.Instance.ShowError(ex.Message); } finally { IsBusy = false; } }
public async void LoadItems() { var items = await _toDoItemDomainManager.GetByStatusAsync(ToDoItemStatus.InProgress); ToDoItems.Clear(); ToDoItems.AddRange(items); }
public void Remove_RemoveNull_NothingRemovedNoCrash() { //arrange ToDo myNullToDo = null; string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; string description4 = "Do the home work."; 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(myNullToDo); int myAdjustedNumber = todoItems.Size(); //assert Assert.Equal(myAdjustedNumber, expectedNumberOfItems); }
public async Task InitializeToDoItems() { IsRefreshing = true; List <ToDoItemViewModel> items = (await App.Repository.GetAllAsync()).ToViewModels().ToList(); ToDoItems.Clear(); ToDoItems = ToDoItems.AddRange(items); IsRefreshing = false; }
public void FindAllItems_ClearedItems_EmptyArray() { //arrange ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //act ToDo[] itemArray = todoItems.FindAll(); //assert Assert.Empty(itemArray); }
private async Task LoadDataAsync() { if (_isDataLoaded && !_isRefreshing) { return; } _isDataLoaded = true; List <ToDoItem> toDoItems = await _toDoService.GetAllToDoItemsAsync(); ToDoItems.Clear(); foreach (var item in toDoItems) { ToDoItems.Add(new ToDoItemViewModel(item)); } }
public void Clear_clearList_zero() { //arrange int expectedSizeOfToDoItems = 0; string description = "Wash the car."; ToDoItems todoItems = new ToDoItems(); ToDo returnedTodo = todoItems.AddToDoItem(null, description); Assert.Equal(1, todoItems.Size()); //act todoItems.Clear(); //assert Assert.Equal(expectedSizeOfToDoItems, todoItems.Size()); }
public void AddTodoItem_WithoutAssignee_SizeDescription() { //arrange Person assignee = null; int expectedSizeOfToDoItems = 1; string description = "Shop for groceries."; ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //act ToDo returnedTodo = todoItems.AddToDoItem(assignee, description); //assert Assert.Equal(expectedSizeOfToDoItems, todoItems.Size()); Assert.Equal(description, returnedTodo.Description); }
public void AddTodoItem_WithoutDescription_DescriptionEmpty() { //arrange Person assignee = null; int expectedSizeOfToDoItems = 1; string expectedDescription = ""; string description = null; ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //act ToDo addedTodo = todoItems.AddToDoItem(assignee, description); //assert Assert.Equal(expectedSizeOfToDoItems, todoItems.Size()); Assert.Equal(expectedDescription, addedTodo.Description); }