Package com.wakaleo.gameoflife.domain

Examples of com.wakaleo.gameoflife.domain.Grid


    public static final String EMPTY_GRID = "..." + NEW_LINE + "..." + NEW_LINE + "..." + NEW_LINE;

    @Test
    public void aNewGridShouldBeEmpty() {
        Grid grid = new Grid();
        assertThat(grid.toString(), is(EMPTY_GRID));
    }
View Full Code Here


        String gridContents = "..." + NEW_LINE + "..." + NEW_LINE + "...";

        String expectedPrintedGrid = "..." + NEW_LINE + "..." + NEW_LINE + "..." + NEW_LINE;

        Grid grid = new Grid(gridContents);
        assertThat(grid.toString(), is(expectedPrintedGrid));
    }
View Full Code Here

        String gridContents = "*.." + NEW_LINE + ".*." + NEW_LINE + ".*.";

        String expectedPrintedGrid = "*.." + NEW_LINE + ".*." + NEW_LINE + ".*." + NEW_LINE;

        Grid grid = new Grid(gridContents);
        assertThat(grid.toString(), is(expectedPrintedGrid));
    }
View Full Code Here

    @Test
    public void shouldBeAbleToCountLiveNeighboursOfACell() {

        String gridContents = ".*." + NEW_LINE + "..." + NEW_LINE + "...";

        Grid grid = new Grid(gridContents);
        assertThat(grid.getLiveNeighboursAt(1, 1), is(1));
    }
View Full Code Here

    @Test
    public void shouldBeAbleToCountLiveNeighboursOfACellOnBoundaries() {

        String gridContents = ".*." + NEW_LINE + "*.." + NEW_LINE + "...";

        Grid grid = new Grid(gridContents);
        assertThat(grid.getLiveNeighboursAt(0, 0), is(2));
    }
View Full Code Here

    @Test
    public void shouldBeAbleToCountLiveNeighboursOfACellInTheMiddleOfTheGrid() {

        String gridContents = "..." + NEW_LINE + "***" + NEW_LINE + "...";

        Grid grid = new Grid(gridContents);
        assertThat(grid.getLiveNeighboursAt(1, 1), is(2));
    }
View Full Code Here

    @Test
    public void shouldBeAbleToCountLiveNeighboursOfACellOnAnotherLine() {

        String gridContents = "..." + NEW_LINE + "***" + NEW_LINE + "...";

        Grid grid = new Grid(gridContents);
        assertThat(grid.getLiveNeighboursAt(1, 0), is(3));
    }
View Full Code Here

    @Test
    public void shouldBeAbleToCountLiveNeighboursOfACellOnDiagonalsAndStraightLines() {

        String gridContents = "***" + NEW_LINE + "*.*" + NEW_LINE + "***";

        Grid grid = new Grid(gridContents);
        assertThat(grid.getLiveNeighboursAt(1, 1), is(8));
    }
View Full Code Here

        String gridContents = "***" + NEW_LINE +
                "***" + NEW_LINE +
                "***";

        Grid grid = new Grid(gridContents);

        assertThat(grid.getLiveNeighboursAt(1, 1), is(8));
    }
View Full Code Here

    @Test
    public void shouldBeAbleToReadTheStateOfALivingCell() {

        String currentContents = "..." + NEW_LINE + "***" + NEW_LINE + "...\n";
        Grid grid = new Grid(currentContents);
        int x = 0;
        int y = 1;
        assertThat(grid.getCellAt(x, y), is(LIVE_CELL));
    }
View Full Code Here

TOP

Related Classes of com.wakaleo.gameoflife.domain.Grid

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.