public void SeasonGivenCallsTeamManagerWithSeasonValueReturnsTeamStatsView()
        {
            var teamStats = new TeamStats();
            _teamManager.Setup(x => x.GetSeasonStatsFor(2013)).Returns(teamStats);

            var result = _teamStatsController.Index(2013) as ViewResult;

            Assert.IsNotNull(result);

            var actualTeamStats = result.Model as TeamStats;

            Assert.IsNotNull(actualTeamStats);
            Assert.AreEqual(teamStats, actualTeamStats);

            _teamManager.Verify(x => x.GetSeasonStatsFor(2013));
        }
Exemple #2
0
        public void NoPlayerStatsMakesTotalsAllZero()
        {
            var teamStats = new TeamStats(_team, _playerYearStats, _seasons);

            Assert.AreEqual(_team.Year, teamStats.Year);
            Assert.AreEqual(_team.Wins, teamStats.Wins);
            Assert.AreEqual(_team.Losses, teamStats.Losses);
            CollectionAssert.AreEqual(_seasons, teamStats.Seasons);
            CollectionAssert.AreEqual(_playerYearStats, teamStats.PlayerYearStats);

            Assert.AreEqual(0, teamStats.TotalAtBats);
            Assert.AreEqual(0, teamStats.TotalRuns);
            Assert.AreEqual(0, teamStats.TotalHits);
            Assert.AreEqual(0, teamStats.TotalDoubles);
            Assert.AreEqual(0, teamStats.TotalTriples);
            Assert.AreEqual(0, teamStats.TotalHomeRuns);
            Assert.AreEqual(0, teamStats.TotalRunsBattedIn);
            Assert.AreEqual(0, teamStats.TotalWalks);
            Assert.AreEqual(0, teamStats.TotalStrikeOuts);
            Assert.AreEqual(0, teamStats.TotalAverage);
            Assert.AreEqual(0, teamStats.TotalOnBasePercentage);
        }
Exemple #3
0
        public void DefualtConstructorSetYearToCurrentYearAndSetDefaultValues()
        {
            var teamStats = new TeamStats();

            Assert.AreEqual(DateTime.Now.Year, teamStats.Year);
            Assert.AreEqual(0, teamStats.Wins);
            Assert.AreEqual(0, teamStats.Losses);

            CollectionAssert.AreEqual(new List<int> { DateTime.Now.Year }, teamStats.Seasons);
            Assert.IsNotNull(teamStats.PlayerYearStats);
            Assert.IsFalse(teamStats.PlayerYearStats.Any());

            Assert.AreEqual(0, teamStats.TotalAtBats);
            Assert.AreEqual(0, teamStats.TotalRuns);
            Assert.AreEqual(0, teamStats.TotalHits);
            Assert.AreEqual(0, teamStats.TotalDoubles);
            Assert.AreEqual(0, teamStats.TotalTriples);
            Assert.AreEqual(0, teamStats.TotalHomeRuns);
            Assert.AreEqual(0, teamStats.TotalRunsBattedIn);
            Assert.AreEqual(0, teamStats.TotalWalks);
            Assert.AreEqual(0, teamStats.TotalStrikeOuts);
            Assert.AreEqual(0, teamStats.TotalAverage);
            Assert.AreEqual(0, teamStats.TotalOnBasePercentage);
        }
        static void AssertEmptyTeamStats(TeamStats teamStats)
        {
            Assert.IsNotNull(teamStats);
            Assert.AreEqual(DateTime.Now.Year, teamStats.Year);
            Assert.AreEqual(0, teamStats.Wins);
            Assert.AreEqual(0, teamStats.Losses);

            CollectionAssert.AreEqual(new List<int> { DateTime.Now.Year }, teamStats.Seasons);
            Assert.IsNotNull(teamStats.PlayerYearStats);
            Assert.IsFalse(teamStats.PlayerYearStats.Any());

            Assert.AreEqual(0, teamStats.TotalAtBats);
            Assert.AreEqual(0, teamStats.TotalRuns);
            Assert.AreEqual(0, teamStats.TotalHits);
            Assert.AreEqual(0, teamStats.TotalDoubles);
            Assert.AreEqual(0, teamStats.TotalTriples);
            Assert.AreEqual(0, teamStats.TotalHomeRuns);
            Assert.AreEqual(0, teamStats.TotalRunsBattedIn);
            Assert.AreEqual(0, teamStats.TotalWalks);
            Assert.AreEqual(0, teamStats.TotalStrikeOuts);
            Assert.AreEqual(0, teamStats.TotalAverage);
            Assert.AreEqual(0, teamStats.TotalOnBasePercentage);
        }
Exemple #5
0
        public void StatsTotalsAndAverageAndOnBasePercentageAreCalculated()
        {
            CreatePlayerStats(atBats: 4, hits: 1, walks: 0);
            CreatePlayerStats(atBats: 4, hits: 3, walks: 0);
            CreatePlayerStats(atBats: 3, hits: 0, walks: 1);

            var teamStats = new TeamStats(_team, _playerYearStats, _seasons);

            Assert.AreEqual(_team.Year, teamStats.Year);
            Assert.AreEqual(_team.Wins, teamStats.Wins);
            Assert.AreEqual(_team.Losses, teamStats.Losses);
            CollectionAssert.AreEqual(_seasons, teamStats.Seasons);
            CollectionAssert.AreEqual(_playerYearStats, teamStats.PlayerYearStats);

            Assert.AreEqual(11, teamStats.TotalAtBats);
            Assert.AreEqual(4, teamStats.TotalHits);
            Assert.AreEqual(1, teamStats.TotalWalks);
            Assert.AreEqual(PercentHelper.CalculateAverage(11, 4), teamStats.TotalAverage);
            Assert.AreEqual(PercentHelper.CalculateOnBasePercentage(11, 4, 1), teamStats.TotalOnBasePercentage);
        }