diff --git a/Mage.Tests/src/test/java/org/mage/test/bdd/StepController.java b/Mage.Tests/src/test/java/org/mage/test/bdd/StepController.java new file mode 100644 index 0000000000..96dad30e15 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/bdd/StepController.java @@ -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; +} diff --git a/Mage.Tests/src/test/java/org/mage/test/bdd/StepState.java b/Mage.Tests/src/test/java/org/mage/test/bdd/StepState.java new file mode 100644 index 0000000000..d34e36c5e0 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/bdd/StepState.java @@ -0,0 +1,8 @@ +package org.mage.test.bdd; + +public enum StepState { + GIVEN, + WHEN, + THEN, + NONE +} \ No newline at end of file diff --git a/Mage.Tests/src/test/java/org/mage/test/bdd/given/A.java b/Mage.Tests/src/test/java/org/mage/test/bdd/given/A.java index 325891ab54..3de8bf0cbb 100644 --- a/Mage.Tests/src/test/java/org/mage/test/bdd/given/A.java +++ b/Mage.Tests/src/test/java/org/mage/test/bdd/given/A.java @@ -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; } } diff --git a/Mage.Tests/src/test/java/org/mage/test/bdd/given/Given.java b/Mage.Tests/src/test/java/org/mage/test/bdd/given/Given.java index dd8c89e04c..cb2fa48d0e 100644 --- a/Mage.Tests/src/test/java/org/mage/test/bdd/given/Given.java +++ b/Mage.Tests/src/test/java/org/mage/test/bdd/given/Given.java @@ -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; } diff --git a/Mage.Tests/src/test/java/org/mage/test/bdd/given/Have.java b/Mage.Tests/src/test/java/org/mage/test/bdd/given/Have.java index e49750c26a..85f46168b3 100644 --- a/Mage.Tests/src/test/java/org/mage/test/bdd/given/Have.java +++ b/Mage.Tests/src/test/java/org/mage/test/bdd/given/Have.java @@ -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; } \ No newline at end of file diff --git a/Mage.Tests/src/test/java/org/mage/test/bdd/given/I.java b/Mage.Tests/src/test/java/org/mage/test/bdd/given/I.java index 034626aefc..5a5160ee5e 100644 --- a/Mage.Tests/src/test/java/org/mage/test/bdd/given/I.java +++ b/Mage.Tests/src/test/java/org/mage/test/bdd/given/I.java @@ -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; } \ No newline at end of file