public void It_Checks_For_Cell_Growth_Into_Empty_Cells() { //--arrange _cellGrowthCalculatorMock = new Mock <ICellGrowthCalculator>(); _surroundingCellCalculatorMock = new Mock <ISurroundingCellCalculator>(); var expectedCellGrowthResult = new CellGrowthResult(new List <BioCell>(), new List <BioCell>()); BioCell capturedBioCell = null; Player capturedPlayer = null; SurroundingCells capturedSurroundingCells = null; _cellGrowthCalculatorMock.Setup(mock => mock.CalculateCellGrowth(It.IsAny <BioCell>(), It.IsAny <IPlayer>(), It.IsAny <SurroundingCells>())) .Returns(expectedCellGrowthResult) .Callback <BioCell, Player, SurroundingCells>((w, x, y) => { capturedBioCell = w; capturedPlayer = x; capturedSurroundingCells = y; }); _player = new Player("player 1", new Color(), 1, _cellGrowthCalculatorMock.Object, _surroundingCellCalculatorMock.Object, true); var cell = new BioCell(_player, 0, _player.Color, _surroundingCellCalculatorMock.Object); var surroundingCells = new SurroundingCells { TopLeftCell = GridCell.MakeEmptyCell(0, RelativePosition.TopLeft), TopCell = GridCell.MakeEmptyCell(0, RelativePosition.Top), TopRightCell = GridCell.MakeOutOfGridCell(0, RelativePosition.TopRight), RightCell = GridCell.MakeOutOfGridCell(0, RelativePosition.Right), BottomRightCell = GridCell.MakeOutOfGridCell(0, RelativePosition.BottomRight), BottomCell = GridCell.MakeOutOfGridCell(0, RelativePosition.Bottom), BottomLeftCell = GridCell.MakeOutOfGridCell(0, RelativePosition.BottomLeft), LeftCell = GridCell.MakeOutOfGridCell(0, RelativePosition.Left) }; //--act var actualCellGrowthResult = _player.CalculateCellGrowth(cell, surroundingCells); //--assert capturedBioCell.ShouldBeSameAs(cell); capturedPlayer.ShouldBeSameAs(_player); capturedSurroundingCells.ShouldBeSameAs(surroundingCells); actualCellGrowthResult.ShouldBeSameAs(expectedCellGrowthResult); }
public void It_Checks_For_Dead_Cell_Regeneration() { //--arrange var bioCell = new BioCell(_playerMock.Object, 1, Colors.Brown, _surroundingCellCalculatorMock.Object); var liveCells = new Dictionary <int, BioCell>(); var deadCells = new Dictionary <int, BioCell>(); var expectedSurroundingCells = new SurroundingCells(); BioCell actualBioCellInSurroundingCellCalculation = null; Dictionary <int, BioCell> actualLiveCellsInSurroundingCellCalculation = null; Dictionary <int, BioCell> actualDeadCellsInSurroundingCellCalculation = null; _surroundingCellCalculatorMock .Setup(x => x.GetSurroundingCells(It.IsAny <BioCell>(), It.IsAny <Dictionary <int, BioCell> >(), It.IsAny <Dictionary <int, BioCell> >())) .Returns(expectedSurroundingCells) .Callback <BioCell, Dictionary <int, BioCell>, Dictionary <int, BioCell> >((i, o, x) => { actualBioCellInSurroundingCellCalculation = i; actualLiveCellsInSurroundingCellCalculation = o; actualDeadCellsInSurroundingCellCalculation = x; }); var expectedCellGrowthResult = new CellGrowthResult(new List <BioCell>(), new List <BioCell>()); BioCell capturedBioCell = null; SurroundingCells capturedSurroundingCells = null; _playerMock.Setup(mock => mock.CalculateCellGrowth(It.IsAny <BioCell>(), It.IsAny <SurroundingCells>())) .Returns(expectedCellGrowthResult) .Callback <BioCell, SurroundingCells>((i, o) => { capturedBioCell = i; capturedSurroundingCells = o; }); //--act var actualCellGrowthResult = bioCell.RunCellGrowth(liveCells, deadCells); //--assert actualBioCellInSurroundingCellCalculation.ShouldBeSameAs(bioCell); actualLiveCellsInSurroundingCellCalculation.ShouldBeSameAs(liveCells); actualDeadCellsInSurroundingCellCalculation.ShouldBeSameAs(deadCells); capturedBioCell.ShouldBeSameAs(bioCell); capturedSurroundingCells.ShouldBeSameAs(expectedSurroundingCells); actualCellGrowthResult.ShouldBeSameAs(expectedCellGrowthResult); }