public EditEntryViewModel( TodoViewModel entry, ITodoRepository todoRepo = null ) { Entry = entry; TodoRepo = todoRepo ?? new TodoRepository( App.Session ); Summary = entry.Model.Summary; Details = entry.Model.Details; Validate( nameof( Summary ) ).Check( () => !string.IsNullOrWhiteSpace( Summary ) ).Message( Strings.EntryNeedsSummary ); }
public void ConstructorExtractsCorrectModelData() { // Arrange var todo = new Todo {Summary = "summary", Details = "details"}; var entry = new TodoViewModel( todo ); // Act var vm = new EditEntryViewModel( entry ); // Assert Assert.AreEqual( "summary", vm.Summary ); Assert.AreEqual( "details", vm.Details ); }
public void SaveCommandNeedsSummary() { // Arrange var todo = new Todo {Summary = "summary", Details = "details"}; var entry = new TodoViewModel( todo ); var vm = new EditEntryViewModel( entry ); // Act bool withSummary = vm.SaveCommand.CanExecute( null ); vm.Summary = string.Empty; bool withoutSummary = vm.SaveCommand.CanExecute( null ); // Assert Assert.IsTrue( withSummary ); Assert.IsFalse( withoutSummary ); }
private void ExecuteEditEntryCommand(TodoViewModel arg) { var vm = new EditEntryViewModel(arg); MessengerInstance.Send(new FlyoutMessage(FlyoutMessage.EditEntryFlyoutName, vm)); }
private bool CanExecuteEditEntryCommand(TodoViewModel arg) { return(arg != null); }