public void Optimize() { _config = JsonConvert.DeserializeObject <DynastyConfiguration>(_file.File.ReadAllText("dynasty.json")); var segmenter = new DynastySegmenter(_config); var settings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; for (var i = _config.StartDate; i <= _config.EndDate; i = segmenter.GetNext(i)) { if (_current == null) { _current = JsonConvert.DeserializeObject <OptimizerConfiguration>(_file.File.ReadAllText(_configFilename)); } _current.StartDate = i; var endDate = segmenter.PeekNext(i); _current.EndDate = AdjustEndDate(endDate); string json = JsonConvert.SerializeObject(_current, settings); _file.File.WriteAllText(_configFilename, json); _logWrapper.Result($"For period: {_current.StartDate} {_current.EndDate}"); var initializer = new OptimizerInitializer(_file, _managerFactory.Create()); initializer.Initialize(new[] { _configFilename }); } }
public void InitializeTest() { var file = new Mock <IFileSystem>(); file.Setup(f => f.File.ReadAllText(It.IsAny <string>())).Returns("{}"); var manager = new Mock <IGeneManager>(); SetEntryAssembly(Assembly.GetCallingAssembly()); var unit = new OptimizerInitializer(file.Object, manager.Object); unit.Initialize(new[] { "" }); manager.Verify(m => m.Initialize(It.IsAny <IOptimizerConfiguration>(), It.IsAny <OptimizerFitness>())); manager.Verify(m => m.Start()); }