Package com.wakaleo.gameoflife.domain

Examples of com.wakaleo.gameoflife.domain.Grid


    @Test
    public void shouldBeAbleToReadTheStateOfADeadCell() {

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


    }

    @Test
    public void shouldBeAbleToReadTheWidthOfTheGrid() {
        String currentContents = "..." + NEW_LINE + "***\n";
        Grid grid = new Grid(currentContents);
        assertThat(grid.getWidth(), is(3));
    }
View Full Code Here

    }

    @Test
    public void shouldBeAbleToReadTheHeightOfTheGrid() {
        String currentContents = "..." + NEW_LINE + "***" + NEW_LINE;
        Grid grid = new Grid(currentContents);
        assertThat(grid.getHeight(), is(2));
    }
View Full Code Here

    }

    @Test
    public void shouldBeAbleToObtainTheGridContentsAsAnArray() {
        String currentContents = "*.." + NEW_LINE + "*.." + NEW_LINE + ".*." + NEW_LINE;
        Grid grid = new Grid(currentContents);

        Cell[][] contents = grid.getContents();
        assertThat(contents[0][0], is(LIVE_CELL));
        assertThat(contents[1][0], is(LIVE_CELL));
        assertThat(contents[2][1], is(LIVE_CELL));
    }
View Full Code Here

    }

    @Test
    public void theGridContentsAsAnArrayShouldBeTheCorrectSize() {
        String currentContents = "*.." + NEW_LINE + "*.." + NEW_LINE + ".*." + NEW_LINE;
        Grid grid = new Grid(currentContents);

        Cell[][] contents = grid.getContents();
        assertThat(contents.length, is(3));
        assertThat(contents[0].length, is(3));
    }
View Full Code Here

    }

    @Test
    public void ModifyingTheGridContentsAsAnArrayShouldNotModifyTheOriginalContents() {
        String currentContents = "*.." + NEW_LINE + ".*." + NEW_LINE + "..*" + NEW_LINE;
        Grid grid = new Grid(currentContents);

        Cell[][] contents = grid.getContents();
        contents[1][1] = DEAD_CELL;

        assertThat(grid.getCellAt(1, 1), 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.