コード例 #1
0
        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();
        }
コード例 #2
0
            public void it_should_have_saved_the_file()
            {
                var sut = new CsvFileRepository().Reset();

                sut.Save(new CsvFile());
                Assert.AreEqual(sut.AllFiles().Count(), 1);
            }
コード例 #3
0
        public void Should_Load_UnSettled_Bets_From_File()
        {
            IFileRepository csvFileRepositoryTests = new CsvFileRepository();

            List<BetDto> bets = csvFileRepositoryTests.LoadList<BetDto>("Unsettled.csv");

            Assert.IsNotNull(bets);
        }
コード例 #4
0
        public void Should_Load_Settled_Bets_From_File()
        {
            IFileRepository csvFileRepositoryTests = new CsvFileRepository();

            List <BetDto> bets = csvFileRepositoryTests.LoadList <BetDto>("Settled.csv");

            Assert.IsNotNull(bets);
        }
コード例 #5
0
            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);
            }
コード例 #6
0
        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);
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: jfsaguin/NCraft2016Display
        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();
        }
コード例 #8
0
ファイル: WebService.cs プロジェクト: bramble100/Peter2
 public WebService()
 {
     _csvFileRepository = new CsvFileRepository();
 }
コード例 #9
0
 public void SetUp()
 {
     _repository = new CsvFileRepository(_testFileLocation, _testFileName);
 }
コード例 #10
0
 public void SetUp()
 {
     _repository = new CsvFileRepository(_testFileLocation, _testFileName, _testDefaultReportStartDate, TestNrOfReportDays);
 }
コード例 #11
0
 public void TestInit()
 {
     repo = new CsvFileRepository(TestFile);
 }