Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package juego;
- import org.junit.Assert;
- import org.junit.Test;
- public class ReversiTest {
- @Test
- public void convertir1FichaBlancaDelSurANegraConUnTablero4x4() {
- Reversi reversi = new Reversi(4, "negras", "blancas");
- reversi.colocarFicha(4, 3);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(2, 3));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(3, 3));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(4, 3));
- }
- @Test
- public void convertir2FichasBlancaDelSurANegraConUnTablero6x6() {
- Reversi reversi = new Reversi(6, "negras", "blancas");
- reversi.setCasillero(5, 4, Casillero.BLANCAS);
- reversi.colocarFicha(6, 4);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(3, 4));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(4, 4));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 4));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(6, 4));
- }
- @Test
- public void convertir3FichasBlancaDelSurANegraConUnTablero8x8() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.setCasillero(6, 5, Casillero.BLANCAS);
- reversi.setCasillero(7, 5, Casillero.BLANCAS);
- reversi.colocarFicha(8, 5);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(4, 5));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 5));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(6, 5));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(7, 5));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(8, 5));
- }
- @Test
- public void probarSiSePuedeColocarConUnaFilaDe2FichasBlancaDelSurConTurnoDeFichasNegrasConUnTablero6x6() {
- Reversi reversi = new Reversi(6, "negras", "blancas");
- reversi.setCasillero(5, 4, Casillero.BLANCAS);
- Assert.assertTrue(reversi.puedeColocarFicha(6, 4));
- }
- @Test
- public void probarSiSePuedeColocarConUnaFilaDe3FichasBlancaDelSurConTurnoDeFichasNegrasConUnTablero8x8() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.setCasillero(3, 4, Casillero.NEGRAS);
- reversi.setCasillero(4, 4, Casillero.BLANCAS);
- reversi.setCasillero(5, 4, Casillero.BLANCAS);
- reversi.setCasillero(6, 4, Casillero.BLANCAS);
- Assert.assertTrue(reversi.puedeColocarFicha(7, 4));
- }
- @Test
- public void probarSiSePuedeColocarConUnaFilaDe4FichasBlancaDelSurConTurnoDeFichasNegrasConUnTablero10x10() {
- Reversi reversi = new Reversi(10, "negras", "blancas");
- reversi.setCasillero(3, 4, Casillero.NEGRAS);
- reversi.setCasillero(4, 4, Casillero.BLANCAS);
- reversi.setCasillero(5, 4, Casillero.BLANCAS);
- reversi.setCasillero(6, 4, Casillero.BLANCAS);
- reversi.setCasillero(7, 4, Casillero.BLANCAS);
- Assert.assertTrue(reversi.puedeColocarFicha(8, 4));
- }
- @Test
- public void probarSiSePuedeColocarConUnaFilaDe3FichasBlancaYLaUltimaFichaNegraDelSurConTurnoDeFichasNegrasConUnTablero10x10() {
- Reversi reversi = new Reversi(10, "negras", "blancas");
- reversi.setCasillero(3, 4, Casillero.NEGRAS);
- reversi.setCasillero(4, 4, Casillero.BLANCAS);
- reversi.setCasillero(5, 4, Casillero.BLANCAS);
- reversi.setCasillero(6, 4, Casillero.BLANCAS);
- reversi.setCasillero(7, 4, Casillero.NEGRAS);
- Assert.assertFalse(reversi.puedeColocarFicha(8, 4));
- }
- @Test
- public void convertir4FichasBlancaDelSurANegraConUnTablero10x10() {
- Reversi reversi = new Reversi(10, "negras", "blancas");
- reversi.setCasillero(7, 6, Casillero.BLANCAS);
- reversi.setCasillero(8, 6, Casillero.BLANCAS);
- reversi.setCasillero(9, 6, Casillero.BLANCAS);
- reversi.colocarFicha(10, 6);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 6));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(6, 6));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(7, 6));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(8, 6));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(9, 6));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(10, 6));
- }
- @Test
- public void probarSiSePuedeColocarConUnaFilaDe3FichasBlancaEnElSudoesteConTurnoDeFichasNegrasConUnTablero10x10() {
- Reversi reversi = new Reversi(10, "negras", "blancas");
- reversi.setCasillero(3, 4, Casillero.NEGRAS);
- reversi.setCasillero(4, 4, Casillero.BLANCAS);
- reversi.setCasillero(5, 4, Casillero.BLANCAS);
- reversi.setCasillero(6, 4, Casillero.BLANCAS);
- Assert.assertFalse(reversi.puedeColocarFicha(7, 3));
- }
- @Test
- public void probarSiSePuedeColocarConUnaFilaDe2FichasBlancaDelSudesteConTurnoDeFichasNegrasConUnTablero8x8() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.setCasillero(5, 5, Casillero.NEGRAS);
- reversi.setCasillero(6, 6, Casillero.BLANCAS);
- reversi.setCasillero(7, 7, Casillero.BLANCAS);
- Assert.assertTrue(reversi.puedeColocarFicha(8, 8));
- }
- @Test
- public void probarSiSePuedeColocarSinQueHayaUnaFichaDelQueLeTocaElTurnoAlFinalDeLaFilaEnUnTableroDe8x8() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.setCasillero(3, 3, Casillero.BLANCAS);
- reversi.setCasillero(4, 3, Casillero.BLANCAS);
- reversi.setCasillero(5, 3, Casillero.BLANCAS);
- reversi.setCasillero(6, 3, Casillero.BLANCAS);
- Assert.assertFalse(reversi.puedeColocarFicha(7, 3));
- }
- @Test
- public void probarSiSePuedeColocarConUnaColumnaDe2FichasBlancasAlEsteConTurnoDeFichasNegrasConUnTablero8x8() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.setCasillero(4, 3, Casillero.NEGRAS);
- reversi.setCasillero(4, 4, Casillero.BLANCAS);
- reversi.setCasillero(4, 5, Casillero.BLANCAS);
- reversi.setCasillero(4, 6, Casillero.BLANCAS);
- Assert.assertTrue(reversi.puedeColocarFicha(4, 7));
- }
- @Test
- public void probarSiSePuedeColocarConUnaColumnaDe1FichaBlancaAlEsteConTurnoDeFichasNegrasConUnTablero4x4() {
- Reversi reversi = new Reversi(4, "negras", "blancas");
- Assert.assertTrue(reversi.puedeColocarFicha(3, 4));
- }
- @Test
- public void probarSiSePuedeColocarConUnaColumnaDe3FichasBlancasAlEsteConTurnoDeFichasNegrasConUnTablero8x8() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.setCasillero(5, 6, Casillero.BLANCAS);
- reversi.setCasillero(5, 7, Casillero.BLANCAS);
- Assert.assertTrue(reversi.puedeColocarFicha(5, 8));
- }
- @Test
- public void convertir2FichasBlancaDelEsteANegraConUnTablero4x4() {
- Reversi reversi = new Reversi(4, "negras", "blancas");
- reversi.colocarFicha(3, 4);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(3, 2));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(3, 3));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(3, 4));
- }
- @Test
- public void convertir2FichasBlancaDelEsteANegraConUnTablero6x6() {
- Reversi reversi = new Reversi(6, "negras", "blancas");
- reversi.setCasillero(4, 5, Casillero.BLANCAS);
- reversi.colocarFicha(4, 6);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(4, 3));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(4, 4));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(4, 5));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(4, 6));
- }
- @Test
- public void probarSiSePuedeColocarConUnaColumnaDe3FichasBlancaYLaUltimaFichaNegraDelEsteConTurnoDeFichasNegrasConUnTablero10x10() {
- Reversi reversi = new Reversi(10, "negras", "blancas");
- reversi.setCasillero(4, 3, Casillero.NEGRAS);
- reversi.setCasillero(4, 4, Casillero.BLANCAS);
- reversi.setCasillero(4, 5, Casillero.BLANCAS);
- reversi.setCasillero(4, 6, Casillero.BLANCAS);
- reversi.setCasillero(4, 7, Casillero.NEGRAS);
- Assert.assertFalse(reversi.puedeColocarFicha(4, 8));
- }
- @Test
- public void convertir4FichasBlancaDelEsteANegraConUnTablero10x10() {
- Reversi reversi = new Reversi(10, "negras", "blancas");
- reversi.setCasillero(6, 7, Casillero.BLANCAS);
- reversi.setCasillero(6, 8, Casillero.BLANCAS);
- reversi.setCasillero(6, 9, Casillero.BLANCAS);
- reversi.colocarFicha(6, 10);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(6, 5));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(6, 6));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(6, 7));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(6, 8));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(6, 9));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(6, 10));
- }
- @Test
- public void convertir3FichasBlancaDelEsteANegraConUnTablero8x8() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.setCasillero(5, 6, Casillero.BLANCAS);
- reversi.setCasillero(5, 7, Casillero.BLANCAS);
- reversi.colocarFicha(5, 8);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 4));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 5));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 6));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 7));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 8));
- }
- @Test
- public void probarSiSePuedeColocarConUnaFilaDe3FichasBlancarConTurnoDeFichasNegrasConUnTablero10x10ConLibreDePorMedio() {
- Reversi reversi = new Reversi(10, "negras", "blancas");
- reversi.setCasillero(3, 4, Casillero.NEGRAS);
- reversi.setCasillero(4, 4, Casillero.BLANCAS);
- reversi.setCasillero(5, 4, Casillero.LIBRE);
- reversi.setCasillero(6, 4, Casillero.BLANCAS);
- reversi.setCasillero(7, 4, Casillero.BLANCAS);
- Assert.assertFalse(reversi.puedeColocarFicha(8, 4));
- Assert.assertTrue(reversi.puedeColocarFicha(5, 4));
- }
- @Test
- public void probarSiSePuedeColocarConUnaFilaDe3FichasBlancaEnElSudesteConTurnoDeFichasNegrasConUnTablero10x10() {
- Reversi reversi = new Reversi(10, "negras", "blancas");
- reversi.setCasillero(4, 4, Casillero.NEGRAS);
- reversi.setCasillero(5, 5, Casillero.BLANCAS);
- reversi.setCasillero(6, 6, Casillero.BLANCAS);
- reversi.setCasillero(7, 7, Casillero.BLANCAS);
- Assert.assertTrue(reversi.puedeColocarFicha(8, 8));
- }
- @Test(expected = Error.class)
- public void probarSiSePuedeCrearUnTableroCon0FilasY0Columnas() {
- Reversi juegoNuevo = new Reversi(0, "Jugador1", "Jugador2");
- int cantidadFilas = juegoNuevo.contarFilas();
- int cantidadColumnas = juegoNuevo.contarColumnas();
- }
- @Test(expected = Error.class)
- public void probarSiSePuedeCrearUnTableroConNumero5DeFilasYColumnas() {
- Reversi juegoNuevo = new Reversi(5, "Jugador1", "Jugador2");
- int cantidadFilas = juegoNuevo.contarFilas();
- int cantidadColumnas = juegoNuevo.contarColumnas();
- }
- @Test
- public void probarSiSePuedeCrearUnTableroConNumero6DeFilasYColumnas() {
- Reversi juegoNuevo = new Reversi(6, "Jugador1", "Jugador2");
- int filas = juegoNuevo.contarFilas();
- int columnas = juegoNuevo.contarColumnas();
- Assert.assertEquals(6, filas);
- Assert.assertEquals(6, columnas);
- }
- @Test(expected = Error.class)
- public void crearUnTableroConDimension4Negativo() {
- Reversi juegoNuevo = new Reversi(-4, "jugador1", "jugador2");
- int cantidadFilas = juegoNuevo.contarFilas();
- int cantidadColumnas = juegoNuevo.contarColumnas();
- }
- @Test
- public void colocarFichaEnFila4Columa3LaFichaBlancaDeLaFila4Columna4DebeSerNegraLuegoDeEjecutar() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.colocarFicha(4, 3);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(4, 4));
- }
- @Test
- public void colocarFichaEnFila4columna3YOtraEnFila5Columna3LaFichaDeLaFila5Columna4DebeSerBlanca() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.colocarFicha(4, 3);
- reversi.colocarFicha(5, 3);
- Assert.assertEquals(Casillero.BLANCAS, reversi.obtenerCasillero(5, 4));
- }
- /*
- * coloco ficha en fila 1 columna 2
- *
- * se espera que fila 1 columna 2 , fila 2 columna 2 y fila 3 columna 2 sean
- * fichas negras
- */
- @Test
- public void colocoFichaEnFilaUnoColumnaDosDebeHaberUnaColumnaDe3NegrasConsecutivas() {
- Reversi reversi = new Reversi(4, "negras", "blancas");
- reversi.colocarFicha(1, 2);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(1, 2));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(2, 2));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(3, 2));
- }
- /*
- * PRUEBA PARA CAMBIO DE TURNO
- *
- *
- * coloco ficha en fila 1 columna 2
- *
- * coloco ficha en fila 1 columna 3
- *
- * se espera que fila 1 columna 2 , fila 2 columna 2 y fila 3 columna 2 sean
- * fichas negras
- *
- * se espera que fila 1 columna 3 , fila 2 columna 3 y fila 3 columna 3 sean
- * fichas blancas
- */
- @Test
- public void colocoFichaEnFilaUnoColumnaDosDebeHaberUnaColumnaDe3NegrasY3BlancasConsecutivas() {
- Reversi reversi = new Reversi(4, "negras", "blancas");
- reversi.colocarFicha(1, 2);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(1, 2));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(2, 2));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(3, 2));
- }
- @Test
- public void cuentoFichasBlancasAlInicioDeLaPartida() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- Assert.assertEquals(2, reversi.contarFichasBlancas());
- }
- @Test
- public void cuentoFichasNegrasAlInicioDeLaPartida() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- Assert.assertEquals(2, reversi.contarFichasNegras());
- }
- @Test
- public void obtenerSiPuedeColocarFichaEnFila4Columna3() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- Assert.assertTrue(reversi.puedeColocarFicha(4, 3));
- }
- @Test
- public void obtenerSiHayGanadoCuandoComienzaLaPartida() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- Assert.assertFalse(reversi.hayGanador());
- }
- /*
- * coloco ficha en fila 4 columna 3 fila 5 columna 3 fila 6 columna 3
- *
- * fila 5 columna 4 deberia ser una ficha negra y fila 5 columna 3 deberia
- * ser una ficha negra
- */
- @Test
- public void alColocarLaSegundaFichaDebeConvertirEnSentidoNorteYNorEste() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.colocarFicha(4, 3);
- reversi.colocarFicha(5, 3);
- reversi.colocarFicha(6, 3);
- int cantidadDeFichasNegrasHastaElMomento = reversi.contarFichasNegras();
- Assert.assertEquals(6, cantidadDeFichasNegrasHastaElMomento);
- }
- /*
- * coloco ficha en fila 4 columna 3 fila 5 columna 3 fila 6 columna 3
- *
- * fila 5 columna 4 deberia ser una ficha negra y fila 5 columna 3 deberia
- * ser una ficha negra
- *
- * En este movimiento se espera obtener nuevas fichas negras
- */
- @Test
- public void contarCantidadDeFichasNegrasDespuesDeRealizarMovimietos() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.setCasillero(4, 3, Casillero.NEGRAS);
- reversi.setCasillero(5, 3, Casillero.BLANCAS);
- reversi.colocarFicha(6, 3);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 4));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 3));
- }
- @Test
- public void verificarSiAlIniciarLaPartidaLasFichasNegrasTiene4OpcionesParaColocarFicha() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- Assert.assertTrue(reversi.puedeColocarFicha(3, 4));
- Assert.assertTrue(reversi.puedeColocarFicha(4, 3));
- Assert.assertTrue(reversi.puedeColocarFicha(5, 6));
- Assert.assertTrue(reversi.puedeColocarFicha(6, 5));
- }
- @Test
- public void alColocarLaSegundaFichaBlancaDebeConvertirEnDiagonal() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.colocarFicha(4, 3);
- reversi.colocarFicha(3, 3);
- // comprobarFilaDe3Blancas
- Assert.assertEquals(Casillero.BLANCAS, reversi.obtenerCasillero(3, 3));
- Assert.assertEquals(Casillero.BLANCAS, reversi.obtenerCasillero(4, 4));
- Assert.assertEquals(Casillero.BLANCAS, reversi.obtenerCasillero(5, 5));
- }
- @Test
- public void alColocarVariasFichasNegraSeDebeConvertirEnUnaFilaDiagonalDeFichasNegras() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.colocarFicha(4, 3);
- reversi.colocarFicha(3, 3);
- reversi.colocarFicha(3, 4);
- reversi.colocarFicha(5, 3);
- reversi.colocarFicha(2, 2);
- // comprobarFilaDe3Negras
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(2, 2));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(3, 3));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(4, 4));
- }
- @Test
- public void primerMovimientoDeFichasNegrasConvierteUnaFilaVerticalDeNegras() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.colocarFicha(3, 4);
- // comprobarFilaDe3Negras
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(3, 4));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(4, 4));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 4));
- }
- @Test
- public void obtenerSiTerminoElJuegoCuandoComienzaLaPartida() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- Assert.assertFalse(reversi.termino());
- }
- @Test
- public void comer3FichasAlSurDeBlancasANegrasY3FichasAlEsteDeBlancasANegras() {
- Reversi reversi = new Reversi(10, "negras", "blancas");
- reversi.setCasillero(9, 4, Casillero.NEGRAS);
- reversi.setCasillero(9, 5, Casillero.BLANCAS);
- reversi.setCasillero(9, 6, Casillero.BLANCAS);
- reversi.setCasillero(9, 7, Casillero.BLANCAS);
- reversi.setCasillero(5, 8, Casillero.NEGRAS);
- reversi.setCasillero(6, 8, Casillero.BLANCAS);
- reversi.setCasillero(7, 8, Casillero.BLANCAS);
- reversi.setCasillero(8, 8, Casillero.BLANCAS);
- reversi.colocarFicha(9, 8);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(9, 4));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(9, 5));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(9, 6));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(9, 7));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 8));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(6, 8));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(7, 8));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(8, 8));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(9, 8));
- }
- @Test
- public void convertirFichaBlancaDelSurANegraConUnTablero10x10() {
- Reversi reversi = new Reversi(10, "negras", "blancas");
- reversi.setCasillero(9, 4, Casillero.NEGRAS);
- reversi.setCasillero(9, 5, Casillero.BLANCAS);
- reversi.colocarFicha(9, 6);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(9, 4));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(9, 5));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(9, 6));
- }
- @Test
- public void sePuedeColocarFichaNegraAlSudoesteCon1FichaBlancaEnUnTablero6x6() {
- Reversi reversi = new Reversi(6, "negras", "blancas");
- reversi.setCasillero(5, 2, Casillero.BLANCAS);
- Assert.assertTrue(reversi.puedeColocarFicha(6, 1));
- }
- @Test
- public void sePuedeColocarFichaNegraAlSudoesteCon2FichaBlancaEnUnTablero8x8() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.setCasillero(6, 3, Casillero.BLANCAS);
- reversi.setCasillero(7, 2, Casillero.BLANCAS);
- Assert.assertTrue(reversi.puedeColocarFicha(8, 1));
- }
- @Test
- public void comer1FichaAlSudoesteDeBlancaANegraEnUnTablero8x8() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.setCasillero(6, 3, Casillero.BLANCAS);
- reversi.colocarFicha(7, 2);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(6, 3));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(7, 2));
- }
- @Test
- public void comer2FichaAlSudoesteDeBlancaANegraEnUnTablero8x8() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.setCasillero(6, 3, Casillero.BLANCAS);
- reversi.setCasillero(7, 2, Casillero.BLANCAS);
- reversi.colocarFicha(8, 1);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(6, 3));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(7, 2));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(8, 1));
- }
- @Test
- public void comer3fichasAlSudoesteDeBlancaANegraEnUnTablero10x10() {
- Reversi reversi = new Reversi(10, "negras", "blancas");
- reversi.setCasillero(7, 4, Casillero.BLANCAS);
- reversi.setCasillero(8, 3, Casillero.BLANCAS);
- reversi.setCasillero(9, 2, Casillero.BLANCAS);
- reversi.colocarFicha(10, 1);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(7, 4));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(8, 3));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(9, 2));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(10, 1));
- }
- @Test
- public void sePuedeColocarFichaNegraAlSudoesteCon3FichaBlancaEnUnTablero10x10() {
- Reversi reversi = new Reversi(10, "negras", "blancas");
- reversi.setCasillero(4, 7, Casillero.BLANCAS);
- reversi.setCasillero(3, 8, Casillero.BLANCAS);
- reversi.setCasillero(2, 9, Casillero.BLANCAS);
- Assert.assertTrue(reversi.puedeColocarFicha(1, 10));
- }
- @Test
- public void sePuedeColocarFichaNegraAlNoresteCon1FichaBlancaEnUnTablero6x6() {
- Reversi reversi = new Reversi(6, "negras", "blancas");
- reversi.setCasillero(2, 5, Casillero.BLANCAS);
- Assert.assertTrue(reversi.puedeColocarFicha(1, 6));
- }
- @Test
- public void sePuedeColocarFichaNegraAlNoresteCon2FichaBlancaEnUnTablero8x8() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.setCasillero(3, 6, Casillero.BLANCAS);
- reversi.setCasillero(2, 7, Casillero.BLANCAS);
- Assert.assertTrue(reversi.puedeColocarFicha(1, 8));
- }
- @Test
- public void comerFichaNegraAlNoresteCon2FichaBlancaEnUnTablero6x6() {
- Reversi reversi = new Reversi(6, "negras", "blancas");
- reversi.setCasillero(2, 5, Casillero.BLANCAS);
- reversi.colocarFicha(1, 6);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(2, 5));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(1, 6));
- }
- @Test
- public void comer2FichaAlNoresteDeBlancaANegraEnUnTablero8x8() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.setCasillero(3, 6, Casillero.BLANCAS);
- reversi.setCasillero(2, 7, Casillero.BLANCAS);
- reversi.colocarFicha(1, 8);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(3, 6));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(2, 7));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(1, 8));
- }
- @Test
- public void comer3fichasAlNoresteDeBlancaANegraEnUnTablero10x10() {
- Reversi reversi = new Reversi(10, "negras", "blancas");
- reversi.setCasillero(4, 7, Casillero.BLANCAS);
- reversi.setCasillero(3, 8, Casillero.BLANCAS);
- reversi.setCasillero(2, 9, Casillero.BLANCAS);
- reversi.colocarFicha(1, 10);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(4, 7));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(3, 8));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(2, 9));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(1, 10));
- }
- @Test
- public void sePuedeColocarFichaNegraAlNorteCon1FichaBlancaEnUnTablero6x6() {
- Reversi reversi = new Reversi(6, "negras", "blancas");
- Assert.assertTrue(reversi.puedeColocarFicha(5, 4));
- }
- @Test
- public void sePuedeColocarFichaNegraAlNorteCon2FichaBlancaEnUnTablero8x8() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.setCasillero(6, 5, Casillero.BLANCAS);
- Assert.assertTrue(reversi.puedeColocarFicha(7, 5));
- }
- @Test
- public void comerFichaNegraAlNorteCon1FichaBlancaEnUnTablero6x6() {
- Reversi reversi = new Reversi(6, "negras", "blancas");
- reversi.colocarFicha(5, 4);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(3, 4));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(4, 4));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 4));
- }
- @Test
- public void comer2FichaAlNorteDeBlancaANegraEnUnTablero8x8() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.setCasillero(6, 5, Casillero.BLANCAS);
- reversi.colocarFicha(7, 5);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(4, 5));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 5));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(6, 5));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(7, 5));
- }
- @Test
- public void comer3fichasAlNorteDeBlancaANegraEnUnTablero10x10() {
- Reversi reversi = new Reversi(10, "negras", "blancas");
- reversi.setCasillero(7, 6, Casillero.BLANCAS);
- reversi.setCasillero(8, 6, Casillero.BLANCAS);
- reversi.colocarFicha(9, 6);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 6));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(6, 6));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(7, 6));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(8, 6));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(9, 6));
- }
- @Test
- public void sePuedeColocarFichaNegraAlOesteCon1FichaBlancaEnUnTablero6x6() {
- Reversi reversi = new Reversi(6, "negras", "blancas");
- Assert.assertTrue(reversi.puedeColocarFicha(3, 2));
- }
- @Test
- public void sePuedeColocarFichaNegraAlOesteCon2FichaBlancaEnUnTablero8x8() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.setCasillero(4, 3, Casillero.BLANCAS);
- Assert.assertTrue(reversi.puedeColocarFicha(4, 2));
- }
- @Test
- public void sePuedeColocarFichaNegraAlOesteCon3FichasBlancasEnUnTablero10x10() {
- Reversi reversi = new Reversi(10, "negras", "blancas");
- reversi.setCasillero(5, 4, Casillero.BLANCAS);
- reversi.setCasillero(5, 3, Casillero.BLANCAS);
- Assert.assertTrue(reversi.puedeColocarFicha(5, 2));
- }
- @Test
- public void comerFichaNegraAlOesteCon1FichaBlancaEnUnTablero6x6() {
- Reversi reversi = new Reversi(6, "negras", "blancas");
- reversi.colocarFicha(3, 2);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(3, 4));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(3, 3));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(3, 2));
- }
- @Test
- public void comer2FichaAlOesteDeBlancaANegraEnUnTablero8x8() {
- Reversi reversi = new Reversi(8, "negras", "blancas");
- reversi.setCasillero(4, 3, Casillero.BLANCAS);
- reversi.colocarFicha(4, 2);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(4, 5));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(4, 4));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(4, 3));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(4, 2));
- }
- @Test
- public void comer3fichasAlNorteDeBlancaAOesteEnUnTablero10x10() {
- Reversi reversi = new Reversi(10, "negras", "blancas");
- reversi.setCasillero(5, 4, Casillero.BLANCAS);
- reversi.setCasillero(5, 3, Casillero.BLANCAS);
- reversi.colocarFicha(5, 2);
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 6));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 5));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 4));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 3));
- Assert.assertEquals(Casillero.NEGRAS, reversi.obtenerCasillero(5, 2));
- }
- @Test(expected = Error.class)
- public void probarSiSePuedenLlamarLosJugadoresDeLaMismaManera(){
- Reversi reversi = new Reversi(6, "pepe", "pepe");
- }
- @Test(expected = Error.class)
- public void probarQueTenganNombre(){
- Reversi reversi = new Reversi(6, "", "pepe");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement