vendredi 26 janvier 2018

Fluent API how to handle splits to different types

I'm using Fluent API as part of Selenium UI testing I'm doing in a project. I read this article as a reference to fluent api Scott Lilly Fluent API. The purpose is to control the flow of the tests and to make it as readable as possible.
I have a simple wizard as you can see in the picture. login page directs to the first page which directs to the second page (so far everything is simple) but the issue starts with the second page that can take you back to the first page or to the last page. so I wonder what should I return to let the user both options but only those options?

I would for it to look something like this:

DoLogin().WithText().FillForm().GoToSecondPage().FillForm().xxx 

xxx = here I want to have both options to go back to the first page or to the last page

In code its looks something like this so far:

public interface IFirstPage
{
    void WithText();
    IGoToSecondPage FillForm();
}

public interface ISecondPage
{
    //Here starts the problem
    //From this page you can go back to the first page or continue to the last page

    Object FillForm();
}

public interface ILastPage
{
    void SetSomething();
    IGoToSecondPage FillForm();
}

public interface IGoToSecondPage
{
    void GoToSecondPage();
}

public interface IGoToFirstPage
{
    void GoToFirstPage();
}

public interface IGoToLastPage
{
    void GoToSecondPage();
}

public class FirstPage : IFirstPage
{
    public void WithText()
    {
    }

    public IGoToSecondPage FillForm()
    {
        throw new System.NotImplementedException();
    }
}

public class SecondPage : ISecondPage
{
    public object FillForm()
    {
        throw new NotImplementedException();
    }
}

Wizard pages flow

Aucun commentaire:

Enregistrer un commentaire