private static void RunGame(ISimpleInjectorWrapper container, string[] args) { string gamesCount = (args.Length > 1) ? args[1] : string.Empty; IDuelInitializer initializer = new DuelInitializer(container, args.First(), gamesCount); initializer.Run(); }
public GnuGoBot(ISimpleInjectorWrapper simpleInjector, string binaryPath, string botInstanceName) { if (simpleInjector == null) { throw new ArgumentNullException(nameof(simpleInjector)); } if (binaryPath == null) { throw new ArgumentNullException(nameof(binaryPath)); } if (botInstanceName == null) { throw new ArgumentNullException(nameof(botInstanceName)); } var fileService = simpleInjector.GetInstance <IFileService>(); var confService = simpleInjector.GetInstance <IConfigurationService>(); var path = fileService.PathCombine(confService.CurrentDirectoryPath, binaryPath); if (!fileService.FileExists(path)) { throw new FileNotFoundException("Bot binary not found,", path); } this.process = simpleInjector.GetInstance <IProcessManagerFactory>().Create(path, "--mode gtp"); this.process.DataReceived = this.OnDataReceived; this.Name = botInstanceName; this.MovePerformed = delegate { }; // To reduce null reference checking }
public Adjudicator(ISimpleInjectorWrapper simpleInjector, Duel duel) { if (simpleInjector == null) { throw new ArgumentNullException(nameof(simpleInjector)); } if (duel == null) { throw new ArgumentNullException(nameof(duel)); } var fileService = simpleInjector.GetInstance <IFileService>(); this.configurationService = simpleInjector.GetInstance <IConfigurationService>(); var binaryPath = this.configurationService.GetAdjudicatorBinaryPath(); if (!fileService.FileExists(binaryPath)) { throw new FileNotFoundException("Adjudicator binary not found,", binaryPath); } this.process = simpleInjector.GetInstance <IProcessManagerFactory>().Create(binaryPath, "--mode gtp"); this.logger = simpleInjector.GetInstance <ILogger>(); this.process.DataReceived = this.OnDataReceived; this.duel = duel; if (this.duel.BoardSize != 19) { this.process.WriteData("boardsize {0}", this.duel.BoardSize); } this.WhiteMoveValidated = delegate { }; this.BlackMoveValidated = delegate { }; this.Resigned = delegate { }; }
public GoBotFactory(ISimpleInjectorWrapper simpleInjector) { if (simpleInjector == null) { throw new ArgumentNullException(nameof(simpleInjector)); } this.simpleInjector = simpleInjector; }
public TournamentInitializer(ISimpleInjectorWrapper simpleInjector, string name, string gamesCount) { if (simpleInjector == null) { throw new ArgumentNullException(nameof(simpleInjector)); } this.configurationReader = simpleInjector.GetInstance <IConfigurationReader>(); this.botFactory = simpleInjector.GetInstance <IGoBotFactory>(); this.simpleInjector = simpleInjector; this.Name = name; this.gamesCount = gamesCount; }
public void SimpleInjectorWrapperCtorTest() { ISimpleInjectorWrapper injector = null; try { injector = new SimpleInjectorWrapper(null); Assert.True(false, "Should fail on previous statement"); } catch (Exception ex) { Assert.IsType(typeof(ArgumentNullException), ex); Assert.Equal("Value cannot be null.\r\nParameter name: container", ex.Message); } Container cont = new Container(); injector = new SimpleInjectorWrapper(cont); Assert.NotNull(injector); }