Beispiel #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);
        }
Beispiel #2
0
        public void GetTeamSeasonScheduleAverages_GenericExceptionCaught_LogsAndRethrowsException()
        {
            // 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.
            A.CallTo(() => _storedProcedureRepository.GetTeamSeasonScheduleAverages(teamName, seasonID))
            .Throws <Exception>();

            // Act
            IEnumerable <GetTeamSeasonScheduleAverages_Result> result = null;

            Assert.Throws <Exception>(() => result = service.GetTeamSeasonScheduleAverages(teamName, seasonID));

            // Assert
            Assert.IsNull(result);
        }
Beispiel #3
0
        public void GetTeamSeasonScheduleAverages_ArgumentNullExceptionCaught_ShowsExceptionMessageAndReturnsEmptyCollection()
        {
            // 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 ex = new ArgumentNullException();

            A.CallTo(() => _storedProcedureRepository.GetTeamSeasonScheduleAverages(teamName, seasonID)).Throws(ex);

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

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

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