public void BeginEdit_IsEditMode() { var viewModel = new TestEditableItemViewModel(_itemsService, _selectedItemService); viewModel.BeginEdit(); Assert.True(viewModel.IsEditMode); }
public void BeginEdit_CreateCopy() { var viewModel = new TestEditableItemViewModel(_itemsService, _selectedItemService); viewModel.BeginEdit(); viewModel.EditItem.Text = "new text"; Assert.NotEqual(viewModel.Item.Text, viewModel.EditItem.Text); }
public void CancelEdit_EditMode() { var viewModel = new TestEditableItemViewModel(_itemsService, _selectedItemService); viewModel.BeginEdit(); viewModel.CancelEdit(); Assert.False(viewModel.IsEditMode); }
public void EndEdit_ItemSaved() { var viewModel = new TestEditableItemViewModel(_itemsService, _selectedItemService); viewModel.BeginEdit(); viewModel.EditItem.Text = "new text"; viewModel.EndEdit(); Assert.Equal("new text", viewModel.EditItem.Text); Assert.Equal(viewModel.EditItem.Text, viewModel.Item.Text); }
public void CancelEdit_EditItemReset() { var viewModel = new TestEditableItemViewModel(_itemsService, _selectedItemService); viewModel.BeginEdit(); viewModel.EditItem.Text = "new text"; viewModel.CancelEdit(); Assert.Equal("second", viewModel.Item.Text); Assert.Equal(viewModel.Item.Text, viewModel.EditItem.Text); }
public void IsEditModeRaiseEvents() { // arrange var viewModel = new TestEditableItemViewModel(_itemsService, _selectedItemService); bool cancelCommandFired = false; bool saveCommandFired = false; bool editCommandFired = false; viewModel.CancelCommand.CanExecuteChanged += (sender, e) => cancelCommandFired = true; viewModel.SaveCommand.CanExecuteChanged += (sender, e) => saveCommandFired = true; viewModel.EditCommand.CanExecuteChanged += (sender, e) => editCommandFired = true; // act viewModel.BeginEdit(); // assert Assert.True(viewModel.IsEditMode); Assert.True(cancelCommandFired); Assert.True(saveCommandFired); Assert.True(editCommandFired); }