• XAF 帮助文档翻译功能测试如何:测试XAF应用程序


    How to: Test an XAF Application
    如何:测试XAF应用程序

     

    eXpressApp Framework > Task-Based Help > How to: Test an XAF Application

    The eXpressApp Framework is shipped with EasyTest - a test framework designed to perform functional testing of XAF applications. This topic demonstrates how to test an XAF application. A custom Controller will be implemented. Then, its functionality will be tested via EasyTest. To learn more about EasyTest, refer to the EasyTest Basics topic.
    XAF
    附带一个测试框架设计执行XAF应用程序功能测试-EasyTest。本篇演示如何测试XAF应用程序。实现一个自定义控件。然后,用EaseyTest进行他的功能测试。了解更多关于EasyTest,请参考EasyTest基础主题。

    Show Me

    The complete sample project is available in the DevExpress Code Central database at http://www.devexpress.com/example=E1619. Depending on the target platform type (ASP.NET, WinForms, etc), you can either run this example online or download an auto-executable sample.
    完整的例子工程在http://www.devexpress.com/example=E1619里。依赖平台类型(Asp.NET,WinForms,等等),你也可以在线运行或者下载一个自动可执行例子。

    This topic is comprised of two parts.(这个主题包含两个部分)

    1. A custom Controller implementation. This Controller will contain a custom Action.
      一个自定义控件实现。这个控件包括一个自定义按钮。
    2. Step-by-step instructions on how to test an implemented Controller.
      一步一步介绍如何测试一个实现的控件。

    Implement a Custom Controller(实现一个自定义控件)

    Create a new XAF application solution named PostponeControllerTest. The custom Controller will perform an Action over Task business objects. The sample Task business class exposes two properties - Description and DueDate.
    创建一个新的XAF应用程序项目,命名为PostponeControllerTest.这个相当于控件将执行一个动作在Task业务逻辑对象。这个例子Task业务类公开了两个属性-DescriptionDueDate.

    C#

     

    VB

     

    [DefaultClassOptions]

    public class Task : BaseObject {

        public Task(Session session) : base(session) { }

     

        public string Description {

            get { return GetPropertyValue<string>("Description"); }

            set { SetPropertyValue<string>("Description", value); }

        }

     

        public DateTime DueDate {

            get { return GetPropertyValue<DateTime>("DueDate"); }

            set { SetPropertyValue<DateTime>("DueDate", value); }

        }

    }  

    <DefaultClassOptions> _

    Public Class Task

      Inherits BaseObject

        Public Sub New(ByVal session As Session)

            MyBase.New(session)

        End Sub 

     

        Public Property Description() As String 

            Get 

                Return GetPropertyValue(Of String)("Description")

            End Get 

            Set(ByVal value As String)

                SetPropertyValue(Of String)("Description", value)

            End Set 

        End Property 

     

        Public Property DueDate() As DateTime

            Get 

                Return GetPropertyValue(Of DateTime)("DueDate")

            End Get 

            Set(ByVal value As DateTime)

                SetPropertyValue(Of DateTime)("DueDate", value)

            End Set 

        End Property 

    End Class 

     

    The custom Controller is targeted for List Views and contains the Postpone Action. This Action processes the selected objects in a Task List View. The Action adds one day to the objects' DueDate property values.
    这个自定义控件是面向列表视图和包括Postpone动作。这动作处理选择对象在Task列表视图中。这个动作添加一天给这个对象的DueDate属性值。

    C#

     

    VB

     

    using System.Collections;

     

    //... 

     

    public partial class PostponeController : ViewController {

        public PostponeController() {

            InitializeComponent();

            RegisterActions(components);

            this.TargetViewType = ViewType.ListView;

            this.TargetObjectType = typeof(Task);

            this.Postpone.Execute += new SimpleActionExecuteEventHandler(Postpone_Execute);

        }

     

        void Postpone_Execute(object sender, SimpleActionExecuteEventArgs e) {

            IList selectedObjects = ((ListView)View).SelectedObjects;

            foreach (object selectedObject in selectedObjects)

            {                             

                Task selectedTask = (Task)selectedObject;                   

                    if (selectedTask.DueDate == DateTime.MinValue) {

                        selectedTask.DueDate = DateTime.Now;

                    }

                    selectedTask.DueDate = selectedTask.DueDate.AddDays(1);              

            }

        }

    }

    Imports System.Collections

     

    '... 

     

    Partial Public Class PostponeController

        Inherits ViewController

        Public Sub New()

            InitializeComponent()

            RegisterActions(components)

            Me.TargetViewType = ViewType.ListView

            Me.TargetObjectType = GetType(Task)

            AddHandler Postpone.Execute, AddressOf Postpone_Execute

        End Sub 

     

        Private Sub Postpone_Execute(ByVal sender As Object, ByVal e As SimpleActionExecuteEventArgs)

            Dim selectedObjects As IList = (CType(View, ListView)).SelectedObjects

            For Each selectedObject As Object In selectedObjects

                Dim selectedTask As Task = CType(selectedObject, Task)

                    If selectedTask.DueDate = DateTime.MinValue Then 

                        selectedTask.DueDate = DateTime.Now

                    End If 

                    selectedTask.DueDate = selectedTask.DueDate.AddDays(1)

            Next selectedObject

        End Sub 

    End Class 

     

    Test the Custom Action (测试自定义动作)

    This section describes a way of creating an EasyTest script that ensures that the implemented Postpone Action works as expected. The test will work for both Windows Forms and ASP.NET Web applications.
    这个片段描述一个创建一个EasyTest脚本的方法,确保实现Postpone动作预期执行。这个测试可以在两种平台上工作(WinForms and ASP.NET Web applications

    1. In Solution Explorer, navigate to the module project:
      在项目浏览器,导向模块工程

    Right-click the FunctionalTests folder and select Add New Item. In the Add New Item dialog, select Text File and enter the "PostponeControllerTest.ets" as the new file's name. When the Visual Studio text editor is invoked, enter the following code.
    右击FunctionalTests文件夹,选择添加新项目,在项目对话框选择TextFile,输入“PostponeCOntrollerTest.ets”作为新文件的名称。用Visual Studio文本编辑器编辑,输入以下代码

    #DropDB PostponeControllerTestEasyTest

     

    #Application PostponeControllerTestWin

    #Application PostponeControllerTestWeb

     

    *Action Navigation(Task)

     

    *Action New

     

    *FillForm

     Description = Test Task

     Due Date = 05/05/2009

     

    *Action Save and Close

     

    *Action New

     

    *FillForm

     Description = Test Task Two

     Due Date = 03/03/2009

     

    *Action Save and Close

     

    #IfDef PostponeControllerTestWeb

    *Action Navigation(Task)

    #EndIf

     

    *SelectRecords

     Columns = Description

     Row = Test Task

     Row = Test Task Two

     

    *Action Postpone

     

    *CheckTable

     Columns = 'Due Date'

     Row = 5/6/2009

     Row = 3/4/2009

    This script creates two Task objects, selects them in the List View and executes the Postpone Action. After that, the script ensures that the test objects' DueDate properties' values change as expected. For detailed information on the EasyTest command syntax, refer to the EasyTest Script Reference topic.
    这个脚本创建两个任务对象,选择他们在列表视图中,执行Postpone动作。之后,这个脚本确保测试对象的DueDate属性的值预期改变。更详细信息关于EasyTest命令语法,请参考EaseyTestScript主题

    1. Save the test script. Right-click this file in Solution Explorer and select Run:
      保存测试脚本。在项目浏览器中右击这个文件,选择Run:

    The test will first be executed in the Windows Forms application, and then in the ASP.NET Web Site (This is specified by the second and third commands of the test script). You will then see the following output, indicating that all tests passed successfully.
    首先在WindowsForms应用程序上执行,然后在ASP.NET Web Site执行。你将看到下面输出,显示所有的测试通过成功。

    See Also(也可)

    功能测试

     

     

    欢迎转载,转载请注明出处:http://www.cnblogs.com/Tonyyang/

     

     

  • 相关阅读:
    解决Laravel 开启HTTPS反向代理时Url一直是Http问题
    Laravel Passport 401 Unauthenticated.
    Windows 10 1909 (2020年1月) DVD (Chinese-Simplified)
    Office Professional Plus 2019 下载安装激活
    电脑设置U盘启动快捷键
    适用于 Laravel 的阿里云MNS队列驱动
    idea 2021版下创建springMvc项目过程
    UML类图关系(泛化 、继承、实现、依赖、关联、聚合、组合)
    Mac 下打包python 程序
    Tomcat 对 servlet 的支持表
  • 原文地址:https://www.cnblogs.com/Tonyyang/p/2010102.html
Copyright © 2020-2023  润新知