예제 #1
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();
            }
        }
예제 #2
0
 public GameStateEventListener(GameState gameState, GameStateBuilder gameStateBuilder)
 {
     _gameState = gameState;
     _gameStateBuilder = gameStateBuilder;
 }