public void SetIsCompleted_ShouldRaisePropertyChanged() { bool isCalled = false; Todo item= new Todo(); item.PropertyChanged += (s, e) => { if (e.PropertyName == "IsCompleted") isCalled = true; }; item.IsCompleted = true; Assert.True(isCalled); }
private void ExecuteDeleteCommand(Todo item) { _service.Delete(item); Items.Remove(item); }
private void ExecuteCompletedCommand(Todo obj) { obj.IsCompleted = true; }
private void ExecuteAddNewItemCommand() { Todo item = new Todo(); item.Description = CurrentItemDescription; item.DueDate = CurrentItemDueDate; Items.Add(item); item.Id = _service.Save(item); CurrentItemDescription = String.Empty; CurrentItemDueDate = DateTime.Today; }
public void Completed_ShouldChangeStateOfTheItem() { Todo item = new Todo(); IList<Todo> items = new List<Todo> { new Todo(), item, new Todo() }; _service.Setup(s => s.GetItems()).Returns(items); _viewModel.Initialize(); _viewModel.CompletedCommand.Execute(item); Assert.True(item.IsCompleted); }
public void DeleteItem_ShouldRemoveItemFromCollection() { Todo toDelete = new Todo(); IList<Todo> items = new List<Todo>{new Todo(), toDelete, new Todo()}; _service.Setup(s => s.GetItems()).Returns(items); _viewModel.Initialize(); _viewModel.DeleteItemCommand.Execute(toDelete); Assert.Equal(2, _viewModel.Items.Count); }
public void DeleteItem_ShouldCallServiceToRemoveTheItem() { Todo item = new Todo(); _viewModel.Initialize(); _viewModel.DeleteItemCommand.Execute(item); _service.Verify(s => s.Delete(item)); }
public int Save(Todo todo) { return 42; }
public void Delete(Todo item) { }