public ReadUserGuessService(IBattleshipsConfiguration configuration, IConvertCharService charService ) { _charService = charService; _configuration = configuration; }
public ShowGameStateService(IConvertCharService charService, IConsole console, IBattleshipsConfiguration configuration, ICellMapper mapper) { _charService = charService; _console = console; _configuration = configuration; _mapper = mapper; }
public BattleshipStateBuilder(IReadUserGuess guessReader, IBattleshipsConfiguration configuration, IDetectColisionService detectCollisionService, ICellMapper mapper, IRandom randomService) { _guessReader = guessReader; _configuration = configuration; _detectCollisionService = detectCollisionService; _mapper = mapper; _random = randomService; }
public CellMapper(IBattleshipsConfiguration configuration) { _cellStatesAfterHit = new[] { BattleshipGridCell.Miss, BattleshipGridCell.Hit }; _configuration = configuration; // cannot be static, depend on configuration which is injectable _displayMappings = new Dictionary <BattleshipGridCell, char> { { BattleshipGridCell.Empty, _configuration.Empty }, { BattleshipGridCell.Ship, _configuration.Empty }, { BattleshipGridCell.Miss, _configuration.Miss }, { BattleshipGridCell.Hit, _configuration.Hit } }; }
public void SetUp() { _guessService = Substitute.For <IReadUserGuess>(); _config = Substitute.For <IBattleshipsConfiguration>(); _randomService = Substitute.For <IRandom>(); _config.GridSize.Returns(gridSize); _detectCollisionService = Substitute.For <IDetectColisionService>(); var mapper = Substitute.For <ICellMapper>(); mapper.NewCellState(BattleshipGridCell.Empty).Returns(BattleshipGridCell.Miss); mapper.NewCellState(BattleshipGridCell.Ship).Returns(BattleshipGridCell.Hit); _servceUnderTest = new BattleshipStateBuilder( _guessService, _config, _detectCollisionService, mapper, _randomService); }
public static ContainerBuilder GetContainerBuilder(IBattleshipsConfiguration configuration) { var builder = new ContainerBuilder(); // configurations builder.RegisterInstance(configuration).As <IBattleshipsConfiguration>(); // I/O wrappers builder.RegisterType <Battleships.Services.Console>().As <IConsole>(); // services builder.RegisterType <BattleshipGame>().As <IBattleshipGame>(); builder.RegisterType <BattleshipStateBuilder>().As <IBattleshipStateBuilder>(); builder.RegisterType <ConvertCharService>().As <IConvertCharService>(); builder.RegisterType <RandomService>().As <IRandom>(); builder.RegisterType <DetectColisionService>().As <IDetectColisionService>(); builder.RegisterType <ShowGameStateService>().As <IShowGameState>(); builder.RegisterType <ReadUserGuessService>().As <IReadUserGuess>(); builder.RegisterType <CellMapper>().As <ICellMapper>(); return(builder); }
public RandomService(IBattleshipsConfiguration configuration) { _configuration = configuration; _random = new Random(); }
public static IContainer GetContainer(IBattleshipsConfiguration configuration) { ContainerBuilder builder = GetContainerBuilder(configuration); return(builder.Build()); }