예제 #1
0
        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);
        }
예제 #2
0
 private void ExecuteDeleteCommand(Todo item)
 {
     _service.Delete(item);
     Items.Remove(item);
 }
예제 #3
0
 private void ExecuteCompletedCommand(Todo obj)
 {
     obj.IsCompleted = true;
 }
예제 #4
0
 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;
 }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        public void DeleteItem_ShouldCallServiceToRemoveTheItem()
        {
            Todo item = new Todo();
            _viewModel.Initialize();

            _viewModel.DeleteItemCommand.Execute(item);

            _service.Verify(s => s.Delete(item));
        }
예제 #8
0
 public int Save(Todo todo)
 {
     return 42;
 }
예제 #9
0
 public void Delete(Todo item)
 {
 }