public void TestCanExecute_ShouldReturnTrue_IfCanExecuteFuncReturnTrue() { var command = new RelayCommand(delegate { }, p => true); bool canExecute = command.CanExecute(null); Assert.IsTrue(canExecute); }
public void TestExecute_ShouldExecuteAction() { bool execute = false; var command = new RelayCommand(delegate { execute = true; }); command.Execute(null); Assert.IsTrue(execute); }
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; }); }
public void TestConstructor_TakeActionParameter() { var command = new RelayCommand(delegate { }); Assert.IsNotNull(command); }
public void TestConstructor_CanAssignFunctionForCanExecute() { var command = new RelayCommand(delegate { }, p => true); Assert.IsNotNull(command); }