⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smcturnstyletest.java

📁 著名的uncle Bob的Agile software development的代码
💻 JAVA
字号:
import junit.framework.*;import junit.swingui.TestRunner;public class SMCTurnstyleTest extends TestCase{  public static void main(String[] args)  {    TestRunner.main(new String[]{"SMCTurnstyleTest"});  }  public SMCTurnstyleTest(String name)  {    super(name);  }  private TurnstyleFSM t;  private boolean lockCalled = false;  private boolean unlockCalled = false;  private boolean thankyouCalled = false;  private boolean alarmCalled = false;  public void setUp()  {    TurnstyleController controllerSpoof = new TurnstyleController()    {      public void lock() {lockCalled = true;}      public void unlock() {unlockCalled = true;}      public void thankyou() {thankyouCalled = true;}      public void alarm() {alarmCalled = true;}    };    t = new TurnstyleFSM(controllerSpoof);  }  public void testInitialConditions()  {    assertEquals("Locked", t.getCurrentStateName());  }  public void testCoinInLockedState() throws Exception  {    t.coin();    assertEquals("Unlocked", t.getCurrentStateName());    assert(unlockCalled);  }  public void testCoinInUnlockedState() throws Exception  {    t.coin(); // put in Unlocked state    t.coin();    assertEquals("Unlocked", t.getCurrentStateName());    assert(thankyouCalled);  }  public void testPassInLockedState() throws Exception  {    t.pass();    assertEquals("Locked", t.getCurrentStateName());    assert(alarmCalled);  }  public void testPassInUnlockedState() throws Exception  {    t.coin(); // unlock    t.pass();    assertEquals("Locked", t.getCurrentStateName());    assert(lockCalled);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -