public void ChallengeFileIO_Test() { ChallengeFileIO fileIO = new ChallengeFileIO (); Assert.DoesNotThrow (() => { fileIO.Load (filename); }); Assert.DoesNotThrow (() => { fileIO.LoadMetaData (filename); }); Assert.Throws<FileNotFoundException>(() => { fileIO.Load (TestHelper.TestResourcesDirectory + "DoesNotExist.challenge"); }); Assert.Throws<IOException>(() => { fileIO.Load (TestHelper.TestResourcesDirectory + "invalid.challenge"); }); Challenge tempChallenge = fileIO.Load (filename); File.Delete (filename); tempChallenge.Save (true); Challenge tempChallenge2 = fileIO.Load (filename); Assert.AreEqual (tempChallenge.MetaData, tempChallenge2.MetaData); }
public void Challenge_Test() { ChallengeFileIO file = new ChallengeFileIO (); ChallengeMetaData meta = file.LoadMetaData (filename); Challenge challenge = file.Load (filename); Challenge secondChallenge = new Challenge (meta, challenge.Start, challenge.Target); challenge.Name = "other"; Assert.AreEqual (challenge.Name, "other"); Assert.AreNotEqual (secondChallenge.Name, "other"); challenge.AddToHighscore ("Noob", 1337); string[] names = { "Erster", "Dritter", "Zweiter", "Noob" }; int[] times = { 1, 15, 7, 1337 }; int position = 0; foreach (KeyValuePair<string, int> entry in challenge.Highscore) { Assert.AreEqual (entry.Key, names [position]); Assert.AreEqual (entry.Value, times [position]); position++; } }