Commit 133588ae authored by Shaun Burch's avatar Shaun Burch

#5 Test subscription feeds updates

parent 97966790
Pipeline #23092337 passed with stages
in 6 minutes and 50 seconds
package com.example.tictactoe;
import android.util.Log;
import io.reactivex.Observable;
import io.reactivex.subjects.PublishSubject;
......@@ -28,7 +27,7 @@ public class Game {
}
void selectSquare(int x, int y) {
Log.d(TAG, String.format("selectSquare: {x: %1d, y: %2d}", x, y));
System.out.println(String.format("%1s: selectSquare: {x: %2d, y: %3d}", TAG, x, y));
boolean success = mBoard.markCell(mCurrentPlayer.getMark(), x, y);
// Exit if unsuccessful
......
package com.example.tictactoe;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
public class GameTest {
private Game game;
@Before
public void setUp() throws Exception {
List<Player> players = new ArrayList<>();
players.add(new Player("TestUser", Mark.X));
players.add(new Player("AWildCompetitorAppeared", Mark.O));
game = new Game(players);
}
@Test
public void selectSquare() {
game.selectSquare(1, 0);
game.getGameUpdates().subscribe((update) -> {
// Mark
assertEquals(1, update.getMove().x);
assertEquals(0, update.getMove().y);
// De-false
assertFalse(update.isDraw());
assertFalse(update.isWinner());
});
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment