예제 #1
0
        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 );
        }
예제 #2
0
        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 );
        }
예제 #3
0
        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 );
        }
예제 #4
0
        private void ExecuteEditEntryCommand(TodoViewModel arg)
        {
            var vm = new EditEntryViewModel(arg);

            MessengerInstance.Send(new FlyoutMessage(FlyoutMessage.EditEntryFlyoutName, vm));
        }
예제 #5
0
 private bool CanExecuteEditEntryCommand(TodoViewModel arg)
 {
     return(arg != null);
 }