Exemple #1
0
        //[Fact]
        public void GetTotalGoalsForSeason_returns_expected_goal_count()
        {
            // ARRANGE
            var mockTeamStatRepo = new Mock <ITeamStatRepository>();

            // setup a mock stat repo to return some fake data in our target method
            mockTeamStatRepo
            .Setup(mtsr => mtsr.FindAll(It.IsAny <Func <TeamStatSummary, bool> >()))
            .Returns(new List <TeamStatSummary>
            {
                new TeamStatSummary {
                    SeasonId = 1, Team = "team 1", GoalsFor = 1
                },
                new TeamStatSummary {
                    SeasonId = 1, Team = "team 2", GoalsFor = 2
                },
                new TeamStatSummary {
                    SeasonId = 1, Team = "team 3", GoalsFor = 3
                }
            });

            // create our TeamStatCalculator by injecting our mock repository
            var teamStatCalculator = new TeamStatCalculator(mockTeamStatRepo.Object);

            // ACT - call our method under test
            var result = teamStatCalculator.GetTotalGoalsForSeason(1);

            // ASSERT - we got the result we expected - our fake data has 6 goals
            //we should get this back from the method
            Assert.True(result == 6);
        }
        public void GetTotalGoalsForSeason_Returns_Expected_Goal_Count()
        {
            //Arrange
            var mockTeamRepo = new Mock <ITeamRepository>();

            //setup a mock stat repo to return some fake data in our target method
            mockTeamRepo.Setup(mtrsr => mtrsr.GetTeamStats(1)).Returns(new List <TeamStats>
            {
                new TeamStats {
                    SeasonId = 1, TeamName = "team 1", GoalsFor = 1
                },
                new TeamStats {
                    SeasonId = 1, TeamName = "team 2", GoalsFor = 2
                },
                new TeamStats {
                    SeasonId = 1, TeamName = "team 3", GoalsFor = 3
                }
            });

            //create TeamStatCalculator by injecting our mock repository
            var teamStatCalculator = new TeamStatCalculator(mockTeamRepo.Object);

            //Act
            var result = teamStatCalculator.GetTotalGoalsForSeason(1);

            //Assert
            Assert.True(result == 6);
        }