public void Save_InputFile_NoExceptionThrown() { string path = Path.Combine(Directory.GetCurrentDirectory(), "tests/HSSave.txt"); 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); try { hiScore.Save(path); } catch (Exception e) { Assert.Fail(); } HighScores score = HighScores.Load(path); Assert.IsTrue(score.Equals(hiScore)); }
public void Load_InputFile_ReturnsHighScoresObject() { string path = Path.Combine(Directory.GetCurrentDirectory(), "tests/HSLoad.txt"); 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.Load(path); Assert.IsTrue(score.Equals(hiScore)); }
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)); }