GPAL - Generally Positive Automation Library v1.0
GPAL The Fluent Automation LIbrary
Loading...
Searching...
No Matches
Gherkin.cs
1// =============================================================================
2// GPAL - Generally Positive Automation Library
3// Copyright © 2026 Software Decisions, Inc. All rights reserved.
4//
5// This file is part of GPAL.
6// Licensed under the Business Source License 1.1
7//
8// Primary development, architecture, and vision by Michael B. Vederman,
9// CEO of Software Decisions, Inc., Texas.
10//
11// Internal development maintained privately.
12// Public releases appear on GitHub: https://github.com/SoftwareDecisionsInc/GPAL.
13//
14// See LICENSE for full terms, including Additional Use Grant.
15// =============================================================================
16
17using System;
18using System.Linq;
19using System.Text;
20using System.Threading.Tasks;
23using static GenerallyPositive.Enums;
24
25namespace GenerallyPositive
26{
30 internal class Gherkin : IAllowGiven, IAllowWhen, IAllowAnd, IAllowThen
31 {
32 private IBrowser _browser;
33 private IApplication _application;
34
38 public Gherkin()
39 {
40 }
41
48 public Gherkin ForBrowser(BrowserType browserType, string driverLocation)
49 {
50 _browser = GPAL.Browser.WithBrowserType(browserType).WithDriverLocation(driverLocation).ToGPALObject(); ;
51 return this;
52 }
53
59 public Gherkin ForApplication(string appPath)
60 {
61 _application = GPAL.Application.Open(appPath).ToGPALObject();
62 GPAL.PublishSimpleEvent(GPALEventType.INFO, $"Starting application: [{appPath}]", null, GPALObjectType.Application);
63 return this;
64 }
65
71 public IAllowWhen Given(Action step)
72 {
73 step();
74 return this;
75 }
76
78 public IAllowWhen Given<T1>(Action<T1> step, T1 arg1)
79 {
80 step(arg1);
81 return this;
82 }
83
85 public IAllowWhen Given<T1, T2>(Action<T1, T2> step, T1 arg1, T2 arg2)
86 {
87 step(arg1, arg2);
88 return this;
89 }
90
92 public IAllowWhen Given<T1, T2, T3>(Action<T1, T2, T3> step, T1 arg1, T2 arg2, T3 arg3)
93 {
94 step(arg1, arg2, arg3);
95 return this;
96 }
97
103 public IAllowAnd When(Action step)
104 {
105 step();
106 return this;
107 }
108
110 public IAllowAnd When<T1>(Action<T1> step, T1 arg1)
111 {
112 step(arg1);
113 return this;
114 }
115
117 public IAllowAnd When<T1, T2>(Action<T1, T2> step, T1 arg1, T2 arg2)
118 {
119 step(arg1, arg2);
120 return this;
121 }
122
124 public IAllowAnd When<T1, T2, T3>(Action<T1, T2, T3> step, T1 arg1, T2 arg2, T3 arg3)
125 {
126 step(arg1, arg2, arg3);
127 return this;
128 }
129
135 public IAllowThen And(Action step)
136 {
137 step();
138 return this;
139 }
140
142 public IAllowThen And<T1>(Action<T1> step, T1 arg1)
143 {
144 step(arg1);
145 return this;
146 }
147
149 public IAllowThen And<T1, T2>(Action<T1, T2> step, T1 arg1, T2 arg2)
150 {
151 step(arg1, arg2);
152 return this;
153 }
154
156 public IAllowThen And<T1, T2, T3>(Action<T1, T2, T3> step, T1 arg1, T2 arg2, T3 arg3)
157 {
158 step(arg1, arg2, arg3);
159 return this;
160 }
161
167 public IAllowThen Then(Action step)
168 {
169 step();
170 return this;
171 }
172
174 public IAllowThen Then<T1>(Action<T1> step, T1 arg1)
175 {
176 step(arg1);
177 return this;
178 }
179
181 public IAllowThen Then<T1, T2>(Action<T1, T2> step, T1 arg1, T2 arg2)
182 {
183 step(arg1, arg2);
184 return this;
185 }
186
188 public IAllowThen Then<T1, T2, T3>(Action<T1, T2, T3> step, T1 arg1, T2 arg2, T3 arg3)
189 {
190 step(arg1, arg2, arg3);
191 return this;
192 }
193
197 // Optional: Public Browser access for steps
198 public IBrowser Browser => _browser;
199 }
200}
201