Ejemplo n.º 1
0
        public void testLoadAndSave()
        {
            Internationalizer.setLocale(new Locale("de", "DE"));
            Game g = new Game(2);
            Player p = g.getPlayers()[0];
            p.getHand().getHand().Add(CardMother.Feast());
            p.getDeck().getInDiscard().Add(CardMother.Estate());
            p = g.nextTurnPlayer();
            p.getHand().getHand().Add(CardMother.Village());

            //Setup Done
            string direc = Directory.GetCurrentDirectory();
            direc += "\\testSave.dom";
            FileStream stream = new FileStream(direc, FileMode.OpenOrCreate,FileAccess.ReadWrite);
            g.SaveFile(stream);

            Internationalizer.setLocale(new Locale("en", "US"));

            stream = new FileStream(direc, FileMode.OpenOrCreate, FileAccess.ReadWrite);
            Game g2 = Game.LoadFile(stream);
            Assert.AreEqual(1, g2.getCurrentPlayerNumber());
            Assert.IsTrue(g2.getCurrentPlayer().getHand().contains(CardMother.Village()));
            Assert.IsFalse(g2.isGameOver());
            Assert.AreEqual(4, g2.getPlayers()[0].getVictoryPts());
            Assert.AreEqual(3, g2.getPlayers()[1].getVictoryPts());
            Assert.AreEqual(12, g2.getPlayers()[0].getDeck().size() + g2.getPlayers()[0].getHand().size());
            Assert.AreEqual(11, g2.getPlayers()[1].getDeck().size() + g2.getPlayers()[1].getHand().size());
            Assert.AreEqual("Aktionen", Internationalizer.getMessage("Actions"));

            Internationalizer.setLocale(new Locale("en", "US"));
        }