Load() 공개 메소드

Lädt eine Challenge aus einer angegebenen Datei.
public Load ( string filename ) : Challenge
filename string
리턴 Challenge
예제 #1
0
 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);
 }
예제 #2
0
 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++;
     }
 }