mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
Added StepState and StepController to execute different actions on the same "And." calls.
This commit is contained in:
parent
d898c083d4
commit
f299e31237
6 changed files with 51 additions and 4 deletions
|
@ -0,0 +1,19 @@
|
|||
package org.mage.test.bdd;
|
||||
|
||||
/**
|
||||
* Controls steps of bdd calls.
|
||||
* Uses step for the same "And" calls depending on previous calls.
|
||||
* So "And." can be either "Given." or "Then." depending on "Given" or "Then" was called previously.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* Given.I.have.a.card("Island"); // remember step here
|
||||
* And.battlefield.has("Plains"); // "And" replaced and Given.battlefield.has("Plains"); is called
|
||||
*
|
||||
* Then.graveyards.empty(); // remember step here
|
||||
* And.battlefield.has("Plains"); // "And" replaced and Then.battlefield.has("Plains"); is called
|
||||
*
|
||||
*/
|
||||
public class StepController {
|
||||
public static StepState currentState = StepState.NONE;
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package org.mage.test.bdd;
|
||||
|
||||
public enum StepState {
|
||||
GIVEN,
|
||||
WHEN,
|
||||
THEN,
|
||||
NONE
|
||||
}
|
|
@ -1,13 +1,20 @@
|
|||
package org.mage.test.bdd.given;
|
||||
|
||||
import org.mage.test.base.MageBase;
|
||||
import org.mage.test.bdd.StepController;
|
||||
import org.mage.test.bdd.StepState;
|
||||
|
||||
public class A {
|
||||
public static void card(String cardName) throws Exception {
|
||||
private StepState step;
|
||||
public A(StepState step) {
|
||||
this.step = step;
|
||||
}
|
||||
public void card(String cardName) throws Exception {
|
||||
MageBase.getInstance().giveme(cardName);
|
||||
Thread.sleep(4000);
|
||||
if (!MageBase.getInstance().checkIhave(cardName)) {
|
||||
throw new IllegalStateException("Couldn't find a card in hand: " + cardName);
|
||||
}
|
||||
StepController.currentState = this.step;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package org.mage.test.bdd.given;
|
||||
|
||||
import org.mage.test.bdd.StepState;
|
||||
import org.mage.test.bdd.and.Phase;
|
||||
|
||||
public class Given {
|
||||
public static I I;
|
||||
public static I I = new I(StepState.GIVEN);
|
||||
public static Phase phase;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package org.mage.test.bdd.given;
|
||||
|
||||
import org.mage.test.bdd.StepController;
|
||||
import org.mage.test.bdd.StepState;
|
||||
|
||||
public class Have {
|
||||
public static A a;
|
||||
public Have(StepState step) {
|
||||
a = new A(step);
|
||||
}
|
||||
public A a;
|
||||
}
|
|
@ -1,5 +1,11 @@
|
|||
package org.mage.test.bdd.given;
|
||||
|
||||
import org.mage.test.bdd.StepController;
|
||||
import org.mage.test.bdd.StepState;
|
||||
|
||||
public class I {
|
||||
public static Have have;
|
||||
public I(StepState step) {
|
||||
have = new Have(step);
|
||||
}
|
||||
public Have have;
|
||||
}
|
Loading…
Reference in a new issue