diff --git a/.besouro/20151009120031690/actions.txt b/.besouro/20151009120031690/actions.txt new file mode 100644 index 0000000..c97ebc5 --- /dev/null +++ b/.besouro/20151009120031690/actions.txt @@ -0,0 +1,181 @@ +FileOpenedAction 1444381232002 Cell.java 68 0 0 0 +FileOpenedAction 1444382120229 TestCell.java 200 1 1 0 +RefactoringAction 1444382177874 TestCell.java RENAME test()=>void testLiveCell() METHOD +RefactoringAction 1444382182508 TestCell.java RENAME testLiveCell()=>void testLiveCellWithN() METHOD +RefactoringAction 1444382185612 TestCell.java RENAME testLiveCellWithN()=>void testLiveCellWithNoNeighbors() METHOD +RefactoringAction 1444382188186 TestCell.java RENAME testLiveCellWithNoNeighbors()=>void testLiveCellWithNoNeighborsShouldDie() METHOD +RefactoringAction 1444382387293 TestCell.java ADD import org.unioulu.tol.sqatlab.gameoflife.Cell IMPORT +RefactoringAction 1444382395358 Cell.java ADD Cell(String) METHOD +RefactoringAction 1444382406886 Cell.java ADD void nextIteration() METHOD +RefactoringAction 1444382414703 Cell.java ADD Object getState() METHOD +EditAction 1444382429509 TestCell.java 380 1 3 1 +CompilationAction 1444382433066 TestCell.java +CompilationAction 1444382433066 TestCell.java +CompilationAction 1444382433066 TestCell.java +EditAction 1444382433160 Cell.java 303 3 1 0 +UnitTestCaseAction 1444382436997 TestCell.java FAIL +UnitTestSessionAction 1444382436997 TestCell FAIL +EditAction 1444382461583 Cell.java 305 3 1 0 +RefactoringAction 1444382489151 TestCell.java ADD void testLiveCellWithNoNeighborsShouldDie()/2 METHOD +RefactoringAction 1444382496904 TestCell.java RENAME testLiveCellWithNoNeighborsShouldDie()/2=> null +RefactoringAction 1444382509774 TestCell.java RENAME =>void testLiveCellWith() METHOD +RefactoringAction 1444382511849 TestCell.java RENAME testLiveCellWith()=>void testLiveCellWithNeighbors() METHOD +RefactoringAction 1444382513923 TestCell.java RENAME testLiveCellWithNeighbors()=>void testLiveCellWithNeighborsShouldDie() METHOD +RefactoringAction 1444382539868 TestCell.java RENAME testLiveCellWithNeighborsShouldDie()=>void testLiveCellWithTwoNeighborsShouldDie() METHOD +RefactoringAction 1444382545032 TestCell.java RENAME testLiveCellWithTwoNeighborsShouldDie()=>void testLiveCellWithTwoNeighborsShould() METHOD +RefactoringAction 1444382546592 TestCell.java RENAME testLiveCellWithTwoNeighborsShould()=>void testLiveCellWithTwoNeighborsShouldLive() METHOD +EditAction 1444382551726 TestCell.java 580 2 6 2 +UnitTestCaseAction 1444382555314 TestCell.java FAIL +UnitTestSessionAction 1444382555314 TestCell.testLiveCellWithTwoNeighborsShouldLive FAIL +RefactoringAction 1444382631160 Cell.java ADD String state FIELD +UnitTestCaseAction 1444382674262 TestCell.java OK +UnitTestSessionAction 1444382674263 TestCell.testLiveCellWithTwoNeighborsShouldLive OK +EditAction 1444382708197 Cell.java 285 3 2 0 +EditAction 1444382714954 TestCell.java 570 2 6 2 +UnitTestCaseAction 1444382718230 TestCell.java FAIL +UnitTestSessionAction 1444382718230 TestCell FAIL +RefactoringAction 1444382842710 Cell.java RENAME nextIteration()=>void nextIteration(int) METHOD +RefactoringAction 1444382846875 Cell.java RENAME nextIteration(int)=>void nextIteration FIELD +RefactoringAction 1444382865408 Cell.java RENAME nextIteration()=>void nextIteration(int) METHOD +CompilationAction 1444382954287 TestCell.java +EditAction 1444382967594 TestCell.java 572 2 6 2 +UnitTestCaseAction 1444382980138 TestCell.java OK +UnitTestSessionAction 1444382980138 TestCell OK +FileOpenedAction 1444383091965 TestGrid.java 199 1 1 0 +RefactoringAction 1444383105851 TestGrid.java RENAME test()=> null +RefactoringAction 1444383110484 TestGrid.java RENAME =>void singleCell() METHOD +RefactoringAction 1444383117177 TestGrid.java RENAME singleCell()=>void singleCellGrid() METHOD +RefactoringAction 1444383120266 TestGrid.java RENAME singleCellGrid()=>void singleCell() METHOD +RefactoringAction 1444383126958 TestGrid.java RENAME singleCell()=>void test() METHOD +RefactoringAction 1444383380910 TestGrid.java ADD import org.unioulu.tol.sqatlab.gameoflife.Grid IMPORT +RefactoringAction 1444383415076 TestGrid.java ADD import org.unioulu.tol.sqatlab.gameoflife.Cell IMPORT +RefactoringAction 1444383422050 Cell.java ADD Cell(int, int) METHOD +RefactoringAction 1444383447401 Cell.java ADD int x FIELD +RefactoringAction 1444383447401 Cell.java ADD int y FIELD +FileOpenedAction 1444383480865 Grid.java 68 0 0 0 +RefactoringAction 1444383480943 Grid.java ADD int getNeighbors(Cell) METHOD +EditAction 1444383495747 Grid.java 159 1 1 0 +EditAction 1444383498711 TestGrid.java 403 1 4 1 +UnitTestCaseAction 1444383502114 TestGrid.java OK +UnitTestSessionAction 1444383502114 TestGrid OK +RefactoringAction 1444383534985 TestGrid.java RENAME test()=>void testSingleCellOnGrid() METHOD +RefactoringAction 1444383538074 TestGrid.java RENAME testSingleCellOnGrid()=>void testSingleCellOnGridHasNoNeighbors() METHOD +RefactoringAction 1444383613550 Grid.java ADD void addCell(Cell) METHOD +RefactoringAction 1444383637389 TestGrid.java ADD void testSingleCellOnGridHasNoNeighbors()/2 METHOD +EditAction 1444383702773 TestGrid.java 786 2 12 2 +CompilationAction 1444383707765 TestGrid.java +CompilationAction 1444383707765 TestGrid.java +RefactoringAction 1444383712803 TestGrid.java RENAME testSingleCellOnGridHasNoNeighbors()/2=>void testSingleCellOnGridHasOneNeighbors() METHOD +RefactoringAction 1444383714363 TestGrid.java RENAME testSingleCellOnGridHasOneNeighbors()=>void testSingleCellOnGridHasOneNeighbor() METHOD +EditAction 1444383738187 TestGrid.java 786 2 12 2 +CompilationAction 1444383741307 TestGrid.java +RefactoringAction 1444383749294 Grid.java ADD void addCell(Cell)/2 METHOD +RefactoringAction 1444383757562 Grid.java REMOVE addCell(Cell)/2 METHOD +EditAction 1444383982589 TestCell.java 576 2 6 2 +RefactoringAction 1444384044650 Grid.java ADD void addCell(Cell)/2 METHOD +RefactoringAction 1444384050078 Grid.java REMOVE addCell(Cell)/2 METHOD +EditAction 1444384052216 Grid.java 239 2 1 0 +UnitTestCaseAction 1444384063588 TestGrid.java FAIL +UnitTestSessionAction 1444384063588 TestGrid FAIL +RefactoringAction 1444384256432 Grid.java ADD Array arrayOfCells FIELD +RefactoringAction 1444384318290 Grid.java REMOVE arrayOfCells FIELD +RefactoringAction 1444384601211 Grid.java ADD Set cells FIELD +RefactoringAction 1444384621148 Grid.java ADD import java.util.Set IMPORT +RefactoringAction 1444384625189 Grid.java ADD import java.util.HashSet IMPORT +RefactoringAction 1444384691446 Cell.java ADD int hashCode() METHOD +RefactoringAction 1444384691446 Cell.java ADD boolean equals(Object) METHOD +RefactoringAction 1444384979421 Cell.java ADD int getX FIELD +RefactoringAction 1444384981496 Cell.java RENAME getX=>int getX() METHOD +RefactoringAction 1444385015037 Cell.java ADD int getX()/2 METHOD +RefactoringAction 1444385017112 Cell.java RENAME getX()/2=>int getY() METHOD +RefactoringAction 1444385509365 Grid.java RENAME getNeighbors(Cell)=>int getNumNeighbors(Cell) METHOD +EditAction 1444385568913 TestGrid.java 792 2 12 2 +UnitTestCaseAction 1444385572423 TestGrid.java FAIL +UnitTestSessionAction 1444385572423 TestGrid FAIL +EditAction 1444385685296 Grid.java 517 2 5 0 +UnitTestCaseAction 1444385689071 TestGrid.java OK +UnitTestSessionAction 1444385689071 TestGrid OK +RefactoringAction 1444385737667 TestGrid.java ADD void testSingleCellOnGridHasOneNeighbor()/2 METHOD +RefactoringAction 1444385740257 TestGrid.java RENAME testSingleCellOnGridHasOneNeighbor()/2=>void testTwoCellOnGridHasOneNeighbor() METHOD +RefactoringAction 1444385741817 TestGrid.java RENAME testTwoCellOnGridHasOneNeighbor()=>void testTwoCellsOnGridHasOneNeighbor() METHOD +EditAction 1444385899223 Grid.java 563 2 5 0 +EditAction 1444385902468 TestGrid.java 1100 3 19 3 +UnitTestCaseAction 1444385908895 TestGrid.java FAIL +UnitTestSessionAction 1444385908895 TestGrid FAIL +EditAction 1444386011205 Grid.java 566 2 5 0 +UnitTestCaseAction 1444386014465 TestGrid.java FAIL +UnitTestSessionAction 1444386014465 TestGrid FAIL +EditAction 1444386132765 Grid.java 564 2 5 0 +UnitTestCaseAction 1444386136665 TestGrid.java FAIL +UnitTestSessionAction 1444386136665 TestGrid FAIL +EditAction 1444386214327 Grid.java 566 2 5 0 +UnitTestCaseAction 1444386219740 TestGrid.java FAIL +UnitTestSessionAction 1444386219740 Rerun org.unioulu.tol.sqatlab.gameoflife.test.TestGrid.testSingleCellOnGridHasOneNeighbor FAIL +UnitTestCaseAction 1444386241379 TestGrid.java FAIL +UnitTestSessionAction 1444386241379 TestGrid FAIL +RefactoringAction 1444386395687 TestGrid.java REMOVE testTwoCellsOnGridHasOneNeighbor() METHOD +EditAction 1444386406030 TestGrid.java 1106 2 12 2 +UnitTestCaseAction 1444386411537 TestGrid.java FAIL +UnitTestSessionAction 1444386411537 TestGrid FAIL +RefactoringAction 1444386415827 TestGrid.java RENAME testSingleCellOnGridHasOneNeighbor()=>void testTwoCellOnGridHasOneNeighbor() METHOD +RefactoringAction 1444386418417 TestGrid.java RENAME testTwoCellOnGridHasOneNeighbor()=>void testTwoNeighborCellOnGridHasOneNeighbor() METHOD +RefactoringAction 1444386419462 TestGrid.java RENAME testTwoNeighborCellOnGridHasOneNeighbor()=>void testTwoNeighborCellsOnGridHasOneNeighbor() METHOD +EditAction 1444386427809 TestGrid.java 1112 2 12 2 +UnitTestCaseAction 1444386431319 TestGrid.java FAIL +UnitTestSessionAction 1444386431319 TestGrid FAIL +RefactoringAction 1444386513254 TestGrid.java RENAME testTwoNeighborCellsOnGridHasOneNeighbor()=>void testSingleCellOnGridHasOneNeighbor() METHOD +RefactoringAction 1444386518418 TestGrid.java ADD void testTwoCellsOnGridHasOneNeighbor() METHOD +EditAction 1444386527809 TestGrid.java 1102 3 19 3 +UnitTestCaseAction 1444386533645 TestGrid.java FAIL +UnitTestSessionAction 1444386533645 TestGrid FAIL +UnitTestCaseAction 1444386947752 TestGrid.java FAIL +UnitTestSessionAction 1444386947752 TestGrid FAIL +UnitTestCaseAction 1444387045834 TestGrid.java FAIL +UnitTestSessionAction 1444387045834 TestGrid FAIL +UnitTestCaseAction 1444387161733 TestGrid.java FAIL +UnitTestSessionAction 1444387161733 TestGrid FAIL +UnitTestCaseAction 1444387221406 TestCell.java OK +UnitTestSessionAction 1444387221406 TestCell OK +UnitTestCaseAction 1444387224354 TestGrid.java FAIL +UnitTestSessionAction 1444387224354 TestGrid FAIL +UnitTestCaseAction 1444387418926 TestGrid.java OK +UnitTestSessionAction 1444387418926 TestGrid OK +RefactoringAction 1444387505902 TestGrid.java ADD void testTwoCellsOnGridHasOneNeighbor()/2 METHOD +RefactoringAction 1444387509521 TestGrid.java RENAME testTwoCellsOnGridHasOneNeighbor()/2=>void testTwoSeparateCellsOnGridHasOneNeighbor() METHOD +RefactoringAction 1444387515714 TestGrid.java RENAME testTwoSeparateCellsOnGridHasOneNeighbor()=>void testTwoSeparateCellsOnGridHasNoNeighbors() METHOD +EditAction 1444387588836 TestGrid.java 1418 4 26 4 +UnitTestCaseAction 1444387592143 TestGrid.java OK +UnitTestSessionAction 1444387592143 TestGrid OK +EditAction 1444387663953 TestGrid.java 1505 4 28 5 +UnitTestCaseAction 1444387685826 TestGrid.java OK +UnitTestSessionAction 1444387685826 TestGrid OK +RefactoringAction 1444387802675 TestGrid.java ADD void test FIELD +RefactoringAction 1444387805265 TestGrid.java RENAME test=>void testSingleCell FIELD +RefactoringAction 1444387813517 TestGrid.java RENAME testSingleCell=>void testSingleCellWithThreeNeighborsShouldDie FIELD +RefactoringAction 1444387816091 TestGrid.java RENAME testSingleCellWithThreeNeighborsShouldDie=>void testSingleCellWithThreeNeighborsShouldDie() METHOD +EditAction 1444387869805 TestGrid.java 1863 5 37 6 +CompilationAction 1444387872738 TestGrid.java +CompilationAction 1444387892987 TestGrid.java +UnitTestCaseAction 1444387895904 TestGrid.java OK +UnitTestSessionAction 1444387895904 TestGrid OK +EditAction 1444387906700 TestGrid.java 1916 5 39 6 +UnitTestCaseAction 1444387910959 TestGrid.java OK +UnitTestSessionAction 1444387910975 TestGrid OK +RefactoringAction 1444387939057 TestGrid.java RENAME testSingleCellWithThreeNeighborsShouldDie()=>void testSingleCellWithMoreThanThreeNeighborsShouldDie() METHOD +EditAction 1444387966466 TestGrid.java 1977 5 41 6 +EditAction 1444387976171 TestGrid.java 1977 5 41 6 +UnitTestCaseAction 1444387982161 TestGrid.java OK +UnitTestSessionAction 1444387982161 TestGrid OK +RefactoringAction 1444388025733 TestGrid.java ADD void testTwoSeparateCellsOnGridHasNoNeighbors()/2 METHOD +RefactoringAction 1444388034001 TestGrid.java RENAME testTwoSeparateCellsOnGridHasNoNeighbors()/2=>void testSingleCellsOnGridHasNoNeighbors() METHOD +RefactoringAction 1444388037621 TestGrid.java RENAME testSingleCellsOnGridHasNoNeighbors()=>void testSingleCellsOnGridHasThreeNeighbors() METHOD +EditAction 1444388071865 TestGrid.java 2417 6 53 8 +CompilationAction 1444388074626 TestGrid.java +EditAction 1444388147076 TestGrid.java 2441 6 53 8 +UnitTestCaseAction 1444388151741 TestGrid.java FAIL +UnitTestSessionAction 1444388151741 TestGrid FAIL +EditAction 1444388165596 TestGrid.java 2439 6 53 8 +UnitTestCaseAction 1444388171446 TestGrid.java FAIL +UnitTestSessionAction 1444388171446 TestGrid FAIL +UnitTestCaseAction 1444388341464 TestGrid.java FAIL +UnitTestSessionAction 1444388341464 TestGrid FAIL diff --git a/.besouro/20151009120031690/besouroEpisodes.txt b/.besouro/20151009120031690/besouroEpisodes.txt new file mode 100644 index 0000000..855f958 --- /dev/null +++ b/.besouro/20151009120031690/besouroEpisodes.txt @@ -0,0 +1,36 @@ +1444382674263 test-first 1 1442 true +1444382674264 test-first 1 1442 true +1444382674265 test-first 1 1442 true +1444382674266 test-first 1 1442 true +1444382674267 test-first 1 1442 true +1444382674268 test-last 1 1442 false +1444382674269 test-last 1 1442 false +1444382674270 test-last 1 1442 false +1444382674271 test-last 1 1442 false +1444382674272 test-first 1 1442 true +1444382980138 production 1 271 false +1444383502114 test-last 1 410 false +1444385689071 test-first 1 2154 true +1444385689072 test-first 1 2154 true +1444385689073 test-first 1 2154 true +1444385689074 test-first 1 2154 true +1444385689075 test-first 1 2154 true +1444385689076 test-first 1 2154 true +1444385689077 test-first 1 2154 true +1444385689078 test-first 1 2154 true +1444385689079 test-first 1 2154 true +1444385689080 test-first 1 2154 true +1444385689081 test-first 1 2154 true +1444385689082 test-first 1 2154 true +1444385689083 test-first 1 2154 true +1444385689084 test-first 1 2154 true +1444385689085 test-first 1 2154 true +1444385689086 test-first 1 2154 true +1444385689087 test-first 1 2154 true +1444385689088 test-first 1 2154 true +1444385689089 test-first 1 2154 true +1444385689090 test-first 1 2154 true +1444385689091 test-first 1 2154 true +1444385689092 test-first 1 2154 true +1444385689093 test-first 1 2154 true +1444385689094 test-first 1 2154 true diff --git a/.besouro/20151009120031690/disagreements.txt b/.besouro/20151009120031690/disagreements.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20151009120031690/randomHeuristicEpisodes.txt b/.besouro/20151009120031690/randomHeuristicEpisodes.txt new file mode 100644 index 0000000..c065066 --- /dev/null +++ b/.besouro/20151009120031690/randomHeuristicEpisodes.txt @@ -0,0 +1,4 @@ +1444382674263 test-first 1 1442 true +1444382980138 production 1 271 false +1444383502114 test-last 1 410 false +1444385689071 test-first 1 2154 true diff --git a/.besouro/20151009120031690/userComments.txt b/.besouro/20151009120031690/userComments.txt new file mode 100644 index 0000000..e69de29 diff --git a/.besouro/20151009120031690/zorroEpisodes.txt b/.besouro/20151009120031690/zorroEpisodes.txt new file mode 100644 index 0000000..1209ec2 --- /dev/null +++ b/.besouro/20151009120031690/zorroEpisodes.txt @@ -0,0 +1,4 @@ +1444382674263 test-first 1 1442 true +1444382980138 production 1 305 true +1444383502114 test-last 1 521 false +1444385689071 test-first 1 2186 true diff --git a/src/org/unioulu/tol/sqatlab/gameoflife/Cell.java b/src/org/unioulu/tol/sqatlab/gameoflife/Cell.java index b66e9c8..4b2d8ec 100644 --- a/src/org/unioulu/tol/sqatlab/gameoflife/Cell.java +++ b/src/org/unioulu/tol/sqatlab/gameoflife/Cell.java @@ -2,4 +2,66 @@ public class Cell { + String state; + int x; + int y; + + public Cell(String initialState) { + this.state = initialState; + } + + public Cell(int i, int j) { + this.x = i; + this.y = j; + } + + public int getX(){ + return x; + } + + public int getY(){ + return y; + } + + public void nextIteration(int numOfLiveCells) { + if(state == "Alive" && numOfLiveCells < 2){ + state = "Dead"; + }else + if (state == "Alive" && numOfLiveCells > 3){ + state = "Dead"; + }else + state ="Alive"; + } + + public Object getState() { + // TODO Auto-generated method stub + + return this.state; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + x; + result = prime * result + y; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Cell other = (Cell) obj; + if (x != other.x) + return false; + if (y != other.y) + return false; + return true; + } + } diff --git a/src/org/unioulu/tol/sqatlab/gameoflife/Grid.java b/src/org/unioulu/tol/sqatlab/gameoflife/Grid.java index 19dbf0b..3508516 100644 --- a/src/org/unioulu/tol/sqatlab/gameoflife/Grid.java +++ b/src/org/unioulu/tol/sqatlab/gameoflife/Grid.java @@ -1,5 +1,34 @@ package org.unioulu.tol.sqatlab.gameoflife; +import java.util.HashSet; +import java.util.Set; + public class Grid { + + private Set cells = new HashSet<>(); + + public int getNumNeighbors(Cell cell) { + int numNeighbors = 0; + Set neighborhood = new HashSet(); + for(int dx=-1; dx <= 1; dx++){ + for(int dy=-1; dy <= 1; dy++){ + Cell neighbor = new Cell(cell.x+dx, cell.y + dy); + + if(cells.contains(neighbor)) { + numNeighbors++; + } + } + + } + + return numNeighbors-1; + } + + public void addCell(Cell cell) { + + cells.add(cell); + } + + } diff --git a/src/org/unioulu/tol/sqatlab/gameoflife/test/TestCell.java b/src/org/unioulu/tol/sqatlab/gameoflife/test/TestCell.java index d8de09e..daca61e 100644 --- a/src/org/unioulu/tol/sqatlab/gameoflife/test/TestCell.java +++ b/src/org/unioulu/tol/sqatlab/gameoflife/test/TestCell.java @@ -3,12 +3,30 @@ import static org.junit.Assert.*; import org.junit.Test; +import org.unioulu.tol.sqatlab.gameoflife.Cell; public class TestCell { @Test - public void test() { - fail("Not yet implemented"); + public void testLiveCellWithNoNeighborsShouldDie() { + //arrange + Cell cell = new Cell("Alive"); + // + cell.nextIteration(0); + //assert + assertEquals("Dead", cell.getState()); } + + @Test + public void testLiveCellWithTwoNeighborsShouldLive() { + //arrange + Cell cell = new Cell("Alive"); + // + cell.nextIteration(2); + //assert + assertEquals("Alive", cell.getState()); + } + + } diff --git a/src/org/unioulu/tol/sqatlab/gameoflife/test/TestGrid.java b/src/org/unioulu/tol/sqatlab/gameoflife/test/TestGrid.java index 9614d55..ca94389 100644 --- a/src/org/unioulu/tol/sqatlab/gameoflife/test/TestGrid.java +++ b/src/org/unioulu/tol/sqatlab/gameoflife/test/TestGrid.java @@ -2,12 +2,106 @@ import static org.junit.Assert.*; import org.junit.Test; +import org.unioulu.tol.sqatlab.gameoflife.Cell; +import org.unioulu.tol.sqatlab.gameoflife.Grid; public class TestGrid { @Test - public void test() { - fail("Not yet implemented"); + public void testSingleCellOnGridHasNoNeighbors() { + //arrange + Grid grid = new Grid(); + Cell cell = new Cell(0,0); + //act + grid.addCell(cell); + int numNeighbors = grid.getNumNeighbors(cell); + //assert + assertEquals(0, numNeighbors); } + @Test + public void testSingleCellOnGridHasOneNeighbor() { + //arrange + Grid grid = new Grid(); + Cell cell1 = new Cell(0,0); + Cell cell2 = new Cell(0,1); + //act + grid.addCell(cell1); + grid.addCell(cell2); + int numNeighbors = grid.getNumNeighbors(cell1); + //assert + assertEquals(1, numNeighbors); + } + + @Test + public void testTwoCellsOnGridHasOneNeighbor() { + //arrange + Grid grid = new Grid(); + Cell cell1 = new Cell(0,0); + Cell cell2 = new Cell(0,1); + //act + grid.addCell(cell1); + grid.addCell(cell2); + int numNeighbors = grid.getNumNeighbors(cell1); + //assert + assertEquals(1, numNeighbors); + } + + @Test + public void testTwoSeparateCellsOnGridHasNoNeighbors() { + //arrange + Grid grid = new Grid(); + Cell cell1 = new Cell(0,0); + Cell cell2 = new Cell(0,2); + //act + grid.addCell(cell1); + grid.addCell(cell2); + int numNeighbors1 = grid.getNumNeighbors(cell1); + int numNeighbors2 = grid.getNumNeighbors(cell2); + //assert + assertEquals(0, numNeighbors1); + assertEquals(0, numNeighbors2); + } + + @Test + public void testSingleCellsOnGridHasThreeNeighbors() { + //arrange + Grid grid = new Grid(); + Cell cell1 = new Cell(0,0); + Cell cell2 = new Cell(0,1); + Cell cell3 = new Cell(1,0); + Cell cell4 = new Cell(1,1); + //act + grid.addCell(cell1); + grid.addCell(cell2); + grid.addCell(cell3); + grid.addCell(cell4); + int numNeighbors = grid.getNumNeighbors(cell2); + //assert + assertEquals(3, numNeighbors); + } + + @Test + public void testSingleCellWithMoreThanThreeNeighborsShouldDie() { + Grid grid = new Grid(); + Cell cell1 = new Cell(0,0); + Cell cell2 = new Cell(0,1); + Cell cell3 = new Cell(1,0); + Cell cell4 = new Cell(1,1); + Cell cell5 = new Cell(-1,0); + //act + grid.addCell(cell1); + grid.addCell(cell2); + grid.addCell(cell3); + grid.addCell(cell4); + grid.addCell(cell5); + + int numNeighbors = grid.getNumNeighbors(cell1); + + assertEquals(4, numNeighbors); + assertEquals("Dead", cell1.getState()); + } + + + }