public void calculateTeamWithAdvantageTest()
        {
            HockeyTeam home = new HockeyTeam("h");
            HockeyTeam away = new HockeyTeam("a");

            string t = PenaltyAndTimeCalculator.calculateTeamWithAdvantage(home, away);

            Assert.AreEqual("NONE", t);

            home.setPen1(new TimeSpan(0, 2, 0));
            home.managePenalties();
            away.setPen1(new TimeSpan(0, 2, 0));
            away.managePenalties();
            t = PenaltyAndTimeCalculator.calculateTeamWithAdvantage(home, away);
            Assert.AreEqual("NONE", t);


            home.setPen1(new TimeSpan(0, 2, 0));
            home.setPen2(new TimeSpan(0, 2, 0));
            home.managePenalties();
            away.setPen1(new TimeSpan(0, 2, 0));
            away.setPen2(new TimeSpan(0, 2, 0));
            away.managePenalties();
            t = PenaltyAndTimeCalculator.calculateTeamWithAdvantage(home, away);
            Assert.AreEqual("NONE", t);

            home.clearPen1();
            home.clearPen2();
            away.clearPen1();
            away.clearPen2();
            home.managePenalties();
            away.managePenalties();


            home.setPen1(new TimeSpan(0, 2, 0));
            home.managePenalties();
            t = PenaltyAndTimeCalculator.calculateTeamWithAdvantage(home, away);
            Assert.AreEqual("AWAY", t);

            away.setPen1(new TimeSpan(0, 2, 0));
            away.setPen2(new TimeSpan(0, 2, 0));
            away.managePenalties();
            t = PenaltyAndTimeCalculator.calculateTeamWithAdvantage(home, away);
            Assert.AreEqual("HOME", t);
        }
Exemplo n.º 2
0
 public void calculateAndSetActiveSkatersTest()
 {
     team.queuePenalty(new TimeSpan(0, 2, 0));
     team.managePenalties();
     team.calculateAndSetActiveSkaters();
     Assert.AreEqual(4, team.activeSkaters);
 }
        public void calculateTimeToDisplayTest()
        {
            HockeyTeam home = new HockeyTeam("h");
            HockeyTeam away = new HockeyTeam("a");

            home.setPen1(new TimeSpan(0, 2, 0));
            home.managePenalties();

            string t = PenaltyAndTimeCalculator.calculateTimeToDisplay(home, away);

            Assert.AreEqual("2:00", t);

            away.setPen1(new TimeSpan(0, 1, 40));
            away.managePenalties();
            t = PenaltyAndTimeCalculator.calculateTimeToDisplay(home, away);
            Assert.AreEqual("1:40", t);
        }