public void SaveAndLoadClubWithMainClubTest()
        {
            string id = string.Empty;

            try
            {
                Club club = new Club("PSV", "Nederland");
                club.AddAlternativeName("PSV2");
                club.AddAlternativeName("PSV3");
                id = club.Id;
                ClubFileHandler.SaveClub(club);
                Assert.IsTrue(File.Exists(Path.Combine(Settings.BaseDirectoryName, "Clubs", id)));
                Club newClub = ClubFileHandler.GetClub(id);
                Assert.AreEqual("PSV", newClub.Name);
                Assert.AreEqual("Nederland", newClub.Country);
                Assert.AreEqual("PSV2", newClub.AlternativeNames[0]);
                Assert.AreEqual("PSV3", newClub.AlternativeNames[1]);
            }
            finally
            {
                if (File.Exists(Path.Combine(Settings.BaseDirectoryName, "Clubs", id)))
                {
                    File.Delete(Path.Combine(Settings.BaseDirectoryName, "Clubs", id));
                }
            }
        }
Ejemplo n.º 2
0
        //TODO: Use All* variables to ensure uniqueness
        public static Club GetClub(string id)
        {
            string filePath = Path.Combine(Settings.BaseDirectoryName, "Clubs", id);

            var lines = File.ReadAllLines(filePath).ToList();
            var club  = new Club(lines[0], lines[1], lines[2]);

            string[] alternativeNames = lines[3].Split(';');
            foreach (string alternativeName in alternativeNames)
            {
                club.AddAlternativeName(alternativeName);
            }

            return(club);
        }