예제 #1
0
        public void TestCanExecute_ShouldReturnTrue_IfCanExecuteFuncReturnTrue()
        {
            var command = new RelayCommand(delegate { }, p => true);

            bool canExecute = command.CanExecute(null);

            Assert.IsTrue(canExecute);
        }
예제 #2
0
        public void TestExecute_ShouldExecuteAction()
        {
            bool execute = false;
            var command = new RelayCommand(delegate { execute = true; });

            command.Execute(null);

            Assert.IsTrue(execute);
        }
예제 #3
0
        public EmployeeViewModel(IEmployeeService service)
        {
            _service = service;
               // LoadEmployeesCommand = new DelegateCommand(p => LoadEmployees());
            var commandResult = new CommandResult<EmployeeInfo[]>();
            LoadEmployeesCommand = new RelayCommand(p => commandResult.Result = _service.GetEmployees())
                                      .ExecuteAsync()
                                      .BeforeExecute(() => IsLoadingList = true)
                                      .AfterExecute(() => { Employees = commandResult.Result; IsLoadingList = false; });

            var employeeDetailsResult = new CommandResult<EmployeeDetails>();
            LoadEmployeeDetailsCommand = new RelayCommand(p => employeeDetailsResult.Result = _service.GetEmployee((Guid)p))
                                         .ExecuteAsync()
                                         .BeforeExecute(() => IsLoadingDetails = true)
                                         .AfterExecute(() => { CurrentEmployee = employeeDetailsResult.Result; IsLoadingDetails = false; });
        }
예제 #4
0
 public void TestConstructor_TakeActionParameter()
 {
     var command = new RelayCommand(delegate { });
     Assert.IsNotNull(command);
 }
예제 #5
0
 public void TestConstructor_CanAssignFunctionForCanExecute()
 {
     var command = new RelayCommand(delegate { }, p => true);
     Assert.IsNotNull(command);
 }