Esempio n. 1
0
        public void MatchTests()
        {
            ITeam bears   = new Team(new Football(), "Bears");
            ITeam packers = new Team(new Football(), "Packers");

            string date = "02/17/21";

            string time = "8:00 PM";

            // bears vs packers, 02/17/21 at 8PM. Sportplayed is football
            IMatch superBowl = new SportsAppDavidNicholOOP.Models.Match(bears, packers, date, time, bears.SportPlayed);

            Assert.AreEqual(superBowl.TeamOne, bears);
            Assert.AreEqual(superBowl.TeamTwo, packers);
            Assert.AreEqual(superBowl.Date, "02/17/21");
            Assert.AreEqual(superBowl.Time, "8:00 PM");
            Assert.AreEqual(superBowl.SportPlayed.Name, "Football");
            Assert.AreEqual(superBowl.About, "Lovely day to play some Football on 02/17/21. We have Bears versus Packers at 8:00 PM.");

            superBowl.SetWinner(bears);

            Assert.AreEqual(superBowl.Winner, bears); // in our dreams

            IMatchResult superBowlResult = new MatchResult(superBowl);

            Assert.AreEqual(superBowlResult.DeclareWinner(), $"This exciting Bears vs. Packers match on 02/17/21 resulted in a Bears Victory."); // Match result if there is a winner

            Assert.AreEqual(superBowlResult.DeclareTie(), $"This exciting Bears vs. Packers match on 02/17/21 resulted in a draw.");
        }
Esempio n. 2
0
        public void MatchResultsTests()
        {
            /*
             * So Sporting 'events' like scoring a goal are all going to be an outputted list of strings on a wpf window.
             * things like 'james smith scored a touchdown.' with a random player from a random team, a random number of times.
             * In order to test this, I had to modify my match, team and matchresults classes quite a bit so i can force
             * what the output could be. Much of my matchresults printevents method will change after these tests.
             */

            ITeam panthers = new Team(new Baseball(), "Panthers");
            ITeam knights  = new Team(new Baseball(), "Knights");

            IMatch       match       = new SportsAppDavidNicholOOP.Models.Match(panthers, knights, "01/02/03", "13 PM", panthers.SportPlayed);
            IMatchResult matchResult = new MatchResult(match);

            panthers.AddPlayer(new Player("Shiny Joe Harris"));
            panthers.AddPlayer(new Player("Slim Thomas Keller"));
            panthers.AddPlayer(new Player("Paul Lee"));
            panthers.AddPlayer(new Player("Crazy Hugh Porter"));

            knights.AddPlayer(new Player("Quick Mark Hammond"));
            knights.AddPlayer(new Player("Nick Sherman"));
            knights.AddPlayer(new Player("James Key"));
            knights.AddPlayer(new Player("Strongarm Will Campos"));

            /* first match result arg is a sport event, second is the team, third is the player from that team, fourth is the
             * num times it will run.
             * 2 is score run, 0 is panthers, 3 is crazy hugh porter, 1 is the amount of times it will print*/

            //matchresult.printmatchevents below was changed after the tests for it passed
            //to be random instead of allowing forced input

            //Assert.AreEqual(matchResult.PrintMatchEvents(2, 0, 3, 1), "Crazy Hugh Porter scored a run.\n");
            //Assert.AreEqual(matchResult.PrintMatchEvents(0, 1, 0, 2), "Quick Mark Hammond hit a home run.\nQuick Mark Hammond hit a home run.\n");
            //Assert.AreEqual(matchResult.PrintMatchEvents(1, 0, 2, 1), "Paul Lee hit a grand slam.\n");

            //match.SportPlayed = new Basketball(); // basketball time
            //Assert.AreEqual(matchResult.PrintMatchEvents(2, 0, 1, 1), "Slim Thomas Keller fouled.\n");
            //Assert.AreEqual(matchResult.PrintMatchEvents(0, 1, 1, 2), "Nick Sherman scored a three.\nNick Sherman scored a three.\n");
        }