Beispiel #1
0
 public void Receive(string message)
 {
     switch (message)
     {
         case "new-game":
             GUIPlayer player = new GUIPlayer("GUI");
             GUIDealer dealer = new GUIDealer("Dealer");
             NewGame(player, dealer);
             break;
         case "bet-25":
             _player.Place25Bet();
             break;
         case "bet-50":
             _player.Place50Bet();
             break;
         case "bet-100":
             _player.Place100Bet();
             break;
         case "hit":
             _player.TakeCard();
             break;
         case "stand":
             _player.Stand();
             break;
         case "double-down":
             _player.DoubleDown();
             break;
         case "play-again":
             _dealer.NewGame();
             break;
         default:
             throw new ArgumentOutOfRangeException("message");
     }
 }
 public void TestGameDoesntIncludeNullPropertiesWhenConvertingToJson()
 {
     GUIDealer dealer = new GUIDealer("DEALER");
     GameViewModel model = new GameViewModel
     {
         Player = null,
         Dealer = new PlayerViewModel(dealer)
     };
     Assert.AreEqual("{\"dealer\":{\"name\":\"DEALER\",\"currentState\":\"DealerCollectingBets\",\"hand\":{\"cards\":[]}}}", model.ToJson());
 }
 public void TestGameConvertsToJson()
 {
     GUIPlayer player = new GUIPlayer("PLAYER1");
     GUIDealer dealer = new GUIDealer("DEALER");
     GameViewModel model = new GameViewModel
     {
         Player = new PlayerViewModel(player),
         Dealer = new PlayerViewModel(dealer)
     };
     Assert.AreEqual("{\"player\":{\"name\":\"PLAYER1: £1000.00\",\"currentState\":\"GUIBetting\",\"hand\":{\"cards\":[]}},\"dealer\":{\"name\":\"DEALER\",\"currentState\":\"DealerCollectingBets\",\"hand\":{\"cards\":[]}}}", model.ToJson());
 }