简体   繁体   中英

Design pattern for data flow

We have some kind of test-workflow consisting of steps. Now I want to build classes to represent that.

eg

Step 1: Get edit control for username
Step 2: Write username into the control
Step 3: Get edit control for password
Step 4: Write password into the control
Step 5: Click Login Button

The problem is: How can i have those steps to easily exchange information? How can i easily use the edit control of Step 1 in the code of Step 2?

At the moment I just have the following code:

public abstract class TestCase
{
    // the Steps to build the test
    public IList<TestStep> TestSteps { get; set; }

    public TestCase()
    {
        this.TestSteps = new List<TestStep>();
    }

    public abstract void Run();

    public override string ToString()
    {
        return this.GetType().Name;
    }
}

public class TestStep
{
    public int StepNumber { get; set; } 
    public Func<bool> StepFunc { get; set; }
}

Now I want to get the Control in Step1, use it in Step2 and so on.

Thought of having different StepFunc's that have a return value suiting the needs or a member in a specialized TestStep-derived class. But there is probably a better way.

Please note: At the moment I cannot do this in one step.

Any ideas highly appreciated!

引入一个步进控制器来控制要执行的步骤,并控制这些步骤的执行,当它执行步骤2时,它将步骤1的结果传递给步骤2。步骤2应该不能访问步骤1的编辑控件,而只能访问步骤1的结果,即输入到步骤1的编辑控件中的文本。当然,也可以累积步骤的结果,以便步骤4的结果同时包含用户名和密码。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM