예제 #1
0
 public GameController(IOptions <ConnectionStrings> connIn)
 {
     _gameRepo = new GameRepository(connIn.Value.DefaultConnection);
     _engine   = new GameEngineRepository(connIn.Value.DefaultConnection);
     _diceRepo = new DiceRepository(connIn.Value.DefaultConnection);
     _shake    = new ShakeValueRepository(connIn.Value.DefaultConnection);
     _wallets  = new WalletRepository(connIn.Value.DefaultConnection);
 }
예제 #2
0
 public ValuesController(IOptions <ConnectionStrings> conn)
 {
     _repo               = new DiceRepository(conn.Value.DefaultConnection);
     _engine             = new GameEngineRepository(conn.Value.DefaultConnection);
     _serializerSettings = new JsonSerializerSettings
     {
         Formatting = Formatting.Indented
     };
 }
예제 #3
0
 public void CanGetTotalDiceScoreFromListOfDiceTest()
 {
     List<IDie> diceSet = new List<IDie>{
     new SixSidedDie(),
     new SixSidedDie(),
     new SixSidedDie(),
     new TwentySidedDie()
     };
     DiceRepository diceRepo = new DiceRepository();
     int diceScore = diceRepo.GetDiceRollTotal(diceSet);
     Console.WriteLine(string.Format("Multiple dice total test: {0}", diceScore));
     Assert.That(diceScore, Is.GreaterThan(2));
     Assert.That(diceScore, Is.LessThan(39));
 }
예제 #4
0
        public void Roll1000SetsOfthreeTwentySidedTestYields()
        {
            //test outputs to csv file which can be opened
            // in Excel and graph to prove bell curve
            StringBuilder resultstring = new StringBuilder();
            List<int> intList = new List<int>();
            DiceRepository dRepo = new DiceRepository();
            int length = 1000;
            Random rgen = new Random();
            for (int i = 0; i < length; i++)
            {
                int rollResult =
                    dRepo.GetDiceRollTotal(
                    new List<Die> {
                    new TwentySidedDie(rgen),
                    new TwentySidedDie(rgen),
                    new TwentySidedDie(rgen)
                    });

                intList.Add(rollResult);
            }
            Dictionary<int, int> scoreDict = new Dictionary<int, int>();
            for (int i = 3; i < 63; i++)
            {
                scoreDict[i+3] = intList.Where(x => x == i).Count();

            }

            StringBuilder header = new StringBuilder();
            StringBuilder row = new StringBuilder();
            foreach (var item in scoreDict)
            {
                header.Append(item.Key + ",");
                row.Append(item.Value + ",");
            }

            using (StreamWriter sr = new StreamWriter("c:/testouput.csv"))
            {
                sr.WriteLine(header.ToString()
                    .Substring(0,header.ToString().Length - 1));
                sr.WriteLine(row.ToString()
                    .Substring(0,row.ToString().Length -1));
            }
        }
예제 #5
0
 //this will likely never be used as a controller, and will instead be in the game engine repo.
 //
 public DiceController(IOptions <ConnectionStrings> connIn)
 {
     _repo = new DiceRepository(connIn.Value.DefaultConnection);
 }