Esempio n. 1
0
        public void GetTeamSeasonScheduleAverages_HappyPath()
        {
            // Arrange
            var service = new TeamSeasonsControlService(_sharedService, _teamSeasonRepository,
                                                        _storedProcedureRepository);

            // Define argument variables of method under test.
            var teamName = "Team";
            var seasonID = 2017;

            // Set up required infrastructure of class under test.
            var dbContext = A.Fake <ProFootballEntities>();

            dbContext.SetUpFakeTeamSeasonScheduleAverages();

            var teamSeasonScheduleAverages = dbContext.GetTeamSeasonScheduleAverages(teamName, seasonID);

            A.CallTo(() => _storedProcedureRepository.GetTeamSeasonScheduleAverages(teamName, seasonID))
            .Returns(teamSeasonScheduleAverages);

            // Act
            var result = service.GetTeamSeasonScheduleAverages(teamName, seasonID);

            // Assert
            A.CallTo(() => _storedProcedureRepository.GetTeamSeasonScheduleAverages(teamName, seasonID))
            .MustHaveHappenedOnceExactly();

            Assert.IsInstanceOf <IEnumerable <GetTeamSeasonScheduleAverages_Result> >(result);
        }
Esempio n. 2
0
        //[TestCase]
        public void TestCase1()
        {
            // Arrange
            var service = new TeamSeasonsControlService(_sharedService, _teamSeasonRepository,
                                                        _storedProcedureRepository);

            // Define argument variables of method under test.

            // Set up required infrastructure of class under test.

            // Act
            // TODO: Call method under test.

            // Assert
            // TODO: Assert results of call to method under test.
        }
Esempio n. 3
0
        public void GetEntities_HappyPath()
        {
            // Arrange
            var service = new TeamSeasonsControlService(_sharedService, _teamSeasonRepository,
                                                        _storedProcedureRepository);

            // Define argument variables of method under test.
            var seasonID = 2017;

            // Set up required infrastructure of class under test.
            var teamCount      = 3;
            var seasonsPerTeam = 3;
            var teamSeasons    = new List <TeamSeason>(teamCount * seasonsPerTeam);

            for (int i = 1; i <= teamCount; i++)
            {
                var lastSeason = 2017;
                for (int j = lastSeason; j > lastSeason - seasonsPerTeam; j--)
                {
                    var teamSeason = new TeamSeason
                    {
                        TeamName = $"Team {i}",
                        SeasonID = j
                    };
                    teamSeasons.Add(teamSeason);
                }
            }
            A.CallTo(() => _teamSeasonRepository.GetEntities()).Returns(teamSeasons);

            // Act
            var result = service.GetEntities(seasonID);

            // Assert
            A.CallTo(() => _teamSeasonRepository.GetEntities()).MustHaveHappenedOnceExactly();

            Assert.IsInstanceOf <IEnumerable <TeamSeason> >(result);

            foreach (var teamSeason in result)
            {
                Assert.AreEqual(seasonID, teamSeason.SeasonID);
            }
        }
Esempio n. 4
0
        public void GetEntities_GenericExceptionCaught_LogsAndRethrowsException()
        {
            // Arrange
            var service = new TeamSeasonsControlService(_sharedService, _teamSeasonRepository,
                                                        _storedProcedureRepository);

            // Define argument variables of method under test.
            var seasonID = 2017;

            // Set up required infrastructure of class under test.
            A.CallTo(() => _teamSeasonRepository.GetEntities()).Throws <Exception>();

            // Act
            IEnumerable <TeamSeason> result = null;

            Assert.Throws <Exception>(() => result = service.GetEntities(seasonID));

            // Assert
            Assert.IsNull(result);
        }
Esempio n. 5
0
        public void GetEntities_ArgumentNullExceptionCaught_ShowsExceptionMessageAndReturnsEmptyCollection()
        {
            // Arrange
            var service = new TeamSeasonsControlService(_sharedService, _teamSeasonRepository,
                                                        _storedProcedureRepository);

            // Define argument variables of method under test.
            var seasonID = 2017;

            // Set up required infrastructure of class under test.
            var ex = new ArgumentNullException();

            A.CallTo(() => _teamSeasonRepository.GetEntities()).Throws(ex);

            // Act
            var result = service.GetEntities(seasonID);

            // Assert
            A.CallTo(() => _sharedService.ShowExceptionMessage(ex)).MustHaveHappenedOnceExactly();

            Assert.IsInstanceOf <IEnumerable <TeamSeason> >(result);
            Assert.IsEmpty(result);
        }