Current filter:
                                You should refresh the page.

                                How to: Test an Action

                                0

                                This example illustrates how to test a custom Action. The complete description is available in the How to: Test an Action help topic.

                                You must  log in  or  register  to leave comments
                                Select file
                                • PostponeController.cs
                                • PostponeControllerTest.ets
                                • PostponeControllerUnitTest.cs
                                • Task.cs
                                Select language
                                • C#
                                • VB.NET
                                Select version
                                • v2012 vol 2.4 - v2012 vol 2.8
                                • v2012 vol 1.4 - v2012 vol 1.10
                                • v2011 vol 2.5 - v2011 vol 2.14
                                • v2011 vol 1.4 - v2011 vol 1.12
                                • v2010 vol 2.9 - v2010 vol 2.11
                                • v2010 vol 2.3 - v2010 vol 2.8
                                • v2010 vol 1.4 - v2010 vol 1.12
                                • v2009 vol 3.2 - v2009 vol 3.7
                                • v2009 vol 2.4 - v2009 vol 2.13
                                using System;
                                using System.ComponentModel;
                                using System.Collections.Generic;
                                using System.Diagnostics;
                                using System.Text;
                                using DevExpress.ExpressApp;
                                using DevExpress.ExpressApp.Actions;
                                using DevExpress.Persistent.Base;
                                
                                using System.Collections;
                                
                                namespace PostponeControllerTest.Module {
                                    public class PostponeController : ViewController {
                                        private SimpleAction postpone;
                                        public PostponeController() {
                                            TargetObjectType = typeof(Task);
                                            postpone = new SimpleAction(this, "Postpone", "Edit");
                                            postpone.Execute += new SimpleActionExecuteEventHandler(Postpone_Execute);
                                        }
                                        void Postpone_Execute(object sender, SimpleActionExecuteEventArgs e) {
                                            IList selectedObjects = View.SelectedObjects;
                                            foreach (object selectedObject in selectedObjects)
                                            {                              
                                                Task selectedTask = (Task)selectedObject;                    
                                                    if (selectedTask.DueDate == DateTime.MinValue) {
                                                        selectedTask.DueDate = DateTime.Today;
                                                    }
                                                    selectedTask.DueDate = selectedTask.DueDate.AddDays(1);               
                                            }
                                        }
                                        public SimpleAction Postpone {
                                            get { return postpone; }
                                        }
                                    }
                                }