public GameRegistry() { string workingDirectory = WebConfigurationManager.AppSettings["CsvFilesLocation"]; int refreshRate = int.Parse(WebConfigurationManager.AppSettings["RefreshRate"]); Schedule(() => { var repo = new CsvFileRepository(workingDirectory); var execRepo = new ExecReportRepository(workingDirectory); var runner = new EngineExecutor(workingDirectory, execRepo); try { var results = runner.Process(); runner.WriteCsvResults(repo, results); } catch (AggregateException aex) { foreach (var ex in aex.InnerExceptions) { throw ex; } } }) .NonReentrant() .ToRunNow().AndEvery(refreshRate).Seconds(); }
public void it_should_have_saved_the_file() { var sut = new CsvFileRepository().Reset(); sut.Save(new CsvFile()); Assert.AreEqual(sut.AllFiles().Count(), 1); }
public void Should_Load_UnSettled_Bets_From_File() { IFileRepository csvFileRepositoryTests = new CsvFileRepository(); List<BetDto> bets = csvFileRepositoryTests.LoadList<BetDto>("Unsettled.csv"); Assert.IsNotNull(bets); }
public void Should_Load_Settled_Bets_From_File() { IFileRepository csvFileRepositoryTests = new CsvFileRepository(); List <BetDto> bets = csvFileRepositoryTests.LoadList <BetDto>("Settled.csv"); Assert.IsNotNull(bets); }
public void it_should_find_the_file() { var sut = new CsvFileRepository().Reset(); sut.Save(new CsvFile()); sut.Save(new CsvFile()); var file = sut.FindBy(2); Assert.NotNull(file); Assert.AreEqual(file.Id, 2); }
public void WriteCsvResults(CsvFileRepository repo, List <RunResult> runs) { var players = runs.Select((x, idx) => new Player() { Name = x.PlayerName, Score = GetScore(x), Rank = idx }) .OrderByDescending(x => x.Score) .ThenBy(x => x.Name) .ToList(); var scoreBoard = new ScoreBoard() { BatchDateTime = DateTime.Now, Players = players }; repo.Save(scoreBoard); }
static void Main(string[] args) { if (!args.Any() && args.Count() != 2) { Console.WriteLine("Usage: BattleshipRunner.exe <directory> <refreshInMilliseconds>"); Environment.ExitCode = 1; return; } string workingDir = string.Empty; int refreshrateMs = 10; if (!Directory.Exists(args[0])) { Console.WriteLine("Argument <directory> is not a valid."); Environment.ExitCode = 1; return; } else { workingDir = args[0]; } if (!int.TryParse(args[1], out refreshrateMs)) { Console.WriteLine("Argument <refreshInMilliseconds> should be a positive integer."); Environment.ExitCode = 1; return; } Console.WriteLine("**** Execution started ****"); var repo = new CsvFileRepository(workingDir); var execRepo = new ExecReportRepository(workingDir); var runner = new EngineExecutor(workingDir, execRepo); var results = runner.Process(); runner.WriteCsvResults(repo, results); Console.Write(results[0].Board); Console.WriteLine("**** Execution ended ****"); Console.ReadLine(); }
public WebService() { _csvFileRepository = new CsvFileRepository(); }
public void SetUp() { _repository = new CsvFileRepository(_testFileLocation, _testFileName); }
public void SetUp() { _repository = new CsvFileRepository(_testFileLocation, _testFileName, _testDefaultReportStartDate, TestNrOfReportDays); }
public void TestInit() { repo = new CsvFileRepository(TestFile); }