public void CalculatePossiblePlacements_InputEmptyGrid_ReturnsAllPossiblePlacements( Ship ship, List <Cell> shipRelativeCells, int expectedNumberOfPossiblePlacements) { var shipBuilderStub = new Mock <IShipBuilder>(); shipBuilderStub.Setup(s => s.Build(ship)).Returns(shipRelativeCells); var emptyGrid = EmptyGridGenerator.GenerateEmptyGridOfSize(Constants.GridSize); var shipPossiblePlacementsCalculator = new ShipPossiblePlacementsCalculator(shipBuilderStub.Object); var result = shipPossiblePlacementsCalculator.CalculatePossiblePlacements(ship, emptyGrid).ToList(); shipBuilderStub.Verify(s => s.Build(ship), Times.Once); Assert.That(result.Count, Is.EqualTo(expectedNumberOfPossiblePlacements)); }
public void CalculatePossiblePlacements_InputGridWithOnlyFourCellsForPlacement_ReturnsAllPossiblePlacements( Ship ship, List <Cell> shipRelativeCells, List <List <Cell> > expectedResult) { var shipBuilderStub = new Mock <IShipBuilder>(); shipBuilderStub.Setup(s => s.Build(ship)).Returns(shipRelativeCells); var gridWithOnlyFourCellsForPlacement = GetGridWithOnlyFourCellsForPlacement(); var shipPossiblePlacementsCalculator = new ShipPossiblePlacementsCalculator(shipBuilderStub.Object); var result = shipPossiblePlacementsCalculator .CalculatePossiblePlacements(ship, gridWithOnlyFourCellsForPlacement).ToList(); shipBuilderStub.Verify(s => s.Build(ship), Times.Once); Assert.That(result, Is.EqualTo(expectedResult)); }