Beispiel #1
0
        public void Liste_Zum_Laden_Nicht_Gefunden_Throws_ArgumentException()
        {
            var spiel = new SpieleMethoden();

            File.Delete(@"..\..\SpieleListe.xml");
            spiel.SpielLaden(spiel.ParameterDesSpielsListe);
        }
Beispiel #2
0
        public void Die_XML_Datei_in_Liste_laden_Testmethod()
        {
            var spiel = new SpieleMethoden();

            // Spiel Hinzufügen
            spiel.ParameterDesSpielsListe.Add(new ParameterDesSpiels()
            {
                TitelDesSpiels     = "League of Legends",
                InstallationsDatum = "17.06.2017",
                ZuletztGespielt    = "18.06.2017",
                InstallationsPfad  = @"C:\League of Legends\leagueClient.exe",
                Kategorie          = "MOBA",
                Publisher          = "Riot Games",
                UskEinstufung      = 12
            });
            // Spielspeichern
            XmlDocument doc = new XmlDocument();
            XmlNode     myRoot;

            doc.AppendChild(myRoot = doc.CreateElement("Spiele"));
            for (int i = 0; i < spiel.ParameterDesSpielsListe.Count; i++)
            {
                myRoot.AppendChild(doc.CreateElement(spiel.ParameterDesSpielsListe[i].TitelDesSpiels.Replace(" ", "_")));
                myRoot.SelectSingleNode(spiel.ParameterDesSpielsListe[i].TitelDesSpiels.Replace(" ", "_")).Attributes.Append(doc.CreateAttribute("Titel")).InnerText = spiel.ParameterDesSpielsListe[i].TitelDesSpiels;
                myRoot.SelectSingleNode(spiel.ParameterDesSpielsListe[i].TitelDesSpiels.Replace(" ", "_")).Attributes.Append(doc.CreateAttribute("Installations_Datum")).InnerText = spiel.ParameterDesSpielsListe[i].InstallationsDatum;
                myRoot.SelectSingleNode(spiel.ParameterDesSpielsListe[i].TitelDesSpiels.Replace(" ", "_")).Attributes.Append(doc.CreateAttribute("ZuletztGespielt")).InnerText     = spiel.ParameterDesSpielsListe[i].ZuletztGespielt;
                myRoot.SelectSingleNode(spiel.ParameterDesSpielsListe[i].TitelDesSpiels.Replace(" ", "_")).Attributes.Append(doc.CreateAttribute("InstallationsPfad")).InnerText   = spiel.ParameterDesSpielsListe[i].InstallationsPfad;
                myRoot.SelectSingleNode(spiel.ParameterDesSpielsListe[i].TitelDesSpiels.Replace(" ", "_")).Attributes.Append(doc.CreateAttribute("Kategorie")).InnerText           = spiel.ParameterDesSpielsListe[i].Kategorie;
                myRoot.SelectSingleNode(spiel.ParameterDesSpielsListe[i].TitelDesSpiels.Replace(" ", "_")).Attributes.Append(doc.CreateAttribute("Publisher")).InnerText           = spiel.ParameterDesSpielsListe[i].Publisher;
                myRoot.SelectSingleNode(spiel.ParameterDesSpielsListe[i].TitelDesSpiels.Replace(" ", "_")).Attributes.Append(doc.CreateAttribute("UskEinstufung")).InnerText       = spiel.ParameterDesSpielsListe[i].UskEinstufung.ToString();
            }
            doc.Save(@"..\..\SpieleListe.xml");
            spiel.ParameterDesSpielsListe.Clear();
            spiel.ListeSollLeerSein = true;
            spiel.SpielLaden(spiel.ParameterDesSpielsListe);
            spiel.ListeSollLeerSein = false;
            Assert.AreEqual("League of Legends", spiel.ParameterDesSpielsListe[0].TitelDesSpiels);
        }