Exemplo n.º 1
0
        public void CreateTeamFromStringErrors()
        {
            // Not enough fields
            var team = new Team("Arsenal, 1");
            Assert.AreEqual(null, team.Name);

            // Passing a non-int value
            try
            {
                new Team("Name, notnumber, 2, 3, 4, 5, -, 6, 7");
            } catch( Exception ex)
            {
                Assert.AreEqual("Input string was not in a correct format.", ex.Message);
            }
        }
Exemplo n.º 2
0
 public void CreateTeamFromString()
 {
     var team = new Team("Name, 1, 2, 3, 4, 5, -, 6, 7");
     Assert.AreEqual("Name", team.Name);
     Assert.AreEqual(1, team.Played);
     Assert.AreEqual(2, team.Won);
     Assert.AreEqual(3, team.Lost);
     Assert.AreEqual(4, team.Draw);
     Assert.AreEqual(5, team.Goals);
     Assert.AreEqual(6, team.Against);
     Assert.AreEqual(7, team.Points);
     // Extra values
     Assert.AreEqual(1, team.Diff);
     Assert.AreEqual(false, team.SmallestDiff);
 }
Exemplo n.º 3
0
        public void CreateTeam()
        {
            var team = new Team("Name", 1, 2, 3, 4, 6, 5, 7);
            Assert.AreEqual("Name", team.Name);
            Assert.AreEqual(1, team.Played);
            Assert.AreEqual(2, team.Won);
            Assert.AreEqual(3, team.Lost);
            Assert.AreEqual(4, team.Draw);
            Assert.AreEqual(6, team.Goals);
            Assert.AreEqual(5, team.Against);
            Assert.AreEqual(7, team.Points);
            // Extra values
            Assert.AreEqual(1, team.Diff);
            Assert.AreEqual(false, team.SmallestDiff);

            Assert.AreEqual("Team: Name\tFor: 6\tAgainst: 5. Diff = 1", team.ToString());
        }
        public static IList<Team> GetTeams(Stream file)
        {
            var fileHandler = new FileHandler(file);
            var content = fileHandler.ParseContent();
            var teams = new List<Team>();

            foreach (var line in content)
            {
                var team = new Team(line);
                // If it is a valid team, add it to the list
                if (team != null && team.Name != null && team.Name.Length >= 0)
                {
                    teams.Add(team);
                }
            }
            return teams;
        }