Exemplo n.º 1
0
        //This method deserializes a string into game statistics information
        public static GameStats Deserialize(string data)
        {
            GameStats stats = new GameStats();

            stats.HighScores = HighScores.Deserialize(data);
            return(stats);
        }
Exemplo n.º 2
0
        public void Deserialize_InputSerializedString_ReturnsHighScoresObject()
        {
            string serialized = "knisely%903%mcgee%890%schaub%789%bluff%678%dark%567%hess%456%deb%345%act%234%ben%123%watson%1%";

            HighScores hiScore = new HighScores(new List <HiScore>());

            hiScore.HiScores.Add(new HiScore("ben", 123));
            hiScore.HiScores.Add(new HiScore("act", 234));
            hiScore.HiScores.Add(new HiScore("deb", 345));
            hiScore.HiScores.Add(new HiScore("hess", 456));
            hiScore.HiScores.Add(new HiScore("dark", 567));
            hiScore.HiScores.Add(new HiScore("bluff", 678));
            hiScore.HiScores.Add(new HiScore("schaub", 789));
            hiScore.HiScores.Add(new HiScore("mcgee", 890));
            hiScore.HiScores.Add(new HiScore("knisely", 903));
            hiScore.HiScores.Add(new HiScore("watson", 1));
            hiScore.HiScores.Sort(HighScores.CompareHighScores);

            HighScores score = HighScores.Deserialize(serialized);

            Assert.IsTrue(score.Equals(hiScore));
        }