public BattleshipGame( IConsole console, IBattleshipStateBuilder stateBuilder, IShowGameState gameShowService) : this(console, stateBuilder, gameShowService, stateBuilder.Build()) { }
public void SetUp() { initialState = BattleshipGameState.Empty(gridSize); initialState.Grid[0][0] = BattleshipGridCell.Ship; initialState.Grid[0][1] = BattleshipGridCell.Ship; initialState.Grid[0][2] = BattleshipGridCell.Ship; state1 = BattleshipGameState.Empty(gridSize); state1.Grid[0][0] = BattleshipGridCell.Hit; state1.Grid[0][1] = BattleshipGridCell.Ship; state1.Grid[0][2] = BattleshipGridCell.Ship; state2 = BattleshipGameState.Empty(gridSize); state2.Grid[0][0] = BattleshipGridCell.Hit; state2.Grid[0][1] = BattleshipGridCell.Hit; state2.Grid[0][2] = BattleshipGridCell.Ship; state3 = BattleshipGameState.Empty(gridSize); state3.Grid[0][0] = BattleshipGridCell.Hit; state3.Grid[0][1] = BattleshipGridCell.Hit; state3.Grid[0][2] = BattleshipGridCell.Hit; _console = Substitute.For <IConsole>(); _stateBuilder = Substitute.For <IBattleshipStateBuilder>(); _stateBuilder.Build().Returns(initialState); _gameShowService = Substitute.For <IShowGameState>(); _serviceUnderTests = new BattleshipGame(_console, _stateBuilder, _gameShowService); }
public BattleshipGame( IConsole console, IBattleshipStateBuilder stateBuilder, IShowGameState gameShowService, BattleshipGameState gameState ) { _console = console; _stateBuilder = stateBuilder; _gameShowService = gameShowService; _gameState = gameState; }
public void GivenNewStateBuilderInstance() { // setup mocked components _config = BattleshipsConfiguration.Default; _config.Ships = new List <int>(); var console = Substitute.For <IConsole>(); // use DI setup for rest var builder = Bootstrapper.GetContainerBuilder(_config); // register mocks builder.RegisterInstance(console); builder.RegisterInstance <IBattleshipsConfiguration>(_config); var container = builder.Build(); // get tested class instance _stateBuilder = container.Resolve <IBattleshipStateBuilder>(); }