public void FullGameTest()
        {
            var game =
                new CribbageGameRunner(new List<Player>
                {
                    new Player("Player 1", 1, new MaxPlayStrategy(), new MaxAverageDecision()),
                    new Player("Player 2", 2, new MaxPlayStrategy(), new MaxAverageDecision())
                });

            var result = game.Run();
        }
Exemple #2
0
        public void SmokeTest()
        {
            var results = new ConcurrentBag<Cribbage>();
            Task.WaitAll(Enumerable.Range(0, 10).Select(it =>
            {
                return Task.Run(() =>
                {
                    var playerCount = _random.Next()%2 == 0 ? 2 : 4;
                    var game = new CribbageGameRunner(Enumerable.Range(0, playerCount).Select(i => CreateRandomizedPlayer()).ToList(),CreateRandomizedGameRules(playerCount));
                    var result = game.Run();
                    results.Add(result);
                });
            }).ToArray());

            foreach (var game in results)
            {
                TestEndGame.Test(game.State);
                var gameStateBuilder = new GameStateBuilder();
                var gameState = gameStateBuilder.Build(game.Stream);

                XmlSerializer ser = new XmlSerializer(typeof(GameState));
                XmlSerializer eventStreamSerializer = new XmlSerializer(typeof(EventStream));
                var serializedGame = JsonConvert.SerializeObject(game.Stream.ToList());

                MemoryStream ms = new MemoryStream();
                eventStreamSerializer.Serialize(ms, game.Stream);
                ms.Position = 0;

                StreamReader r = new StreamReader(ms);
                string builtGameState = r.ReadToEnd();

                MemoryStream ms2 = new MemoryStream();
                ser.Serialize(ms2, game.State);
                ms2.Position = 0;

                StreamReader r2 = new StreamReader(ms2);
                string builtGameState2 = r2.ReadToEnd();
            }
        }