Exemplo n.º 1
0
        public void GetSeasonStandingsForLeague_ArgumentNullExceptionCaught_ShowsExceptionMessageAndReturnsEmptyCollection()
        {
            // Arrange
            var service = new SeasonStandingsControlService(_sharedService, _leagueRepository, _conferenceRepository,
                                                            _divisionRepository, _storedProcedureRepository);

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

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

            A.CallTo(
                () => _storedProcedureRepository.GetSeasonStandingsForLeague(A <int> .Ignored, A <string> .Ignored))
            .Throws(ex);

            // Act
            var result = service.GetSeasonStandingsForLeague(seasonID, leagueName);

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

            Assert.IsInstanceOf <IEnumerable <GetSeasonStandingsForLeague_Result> >(result);
            Assert.IsEmpty(result);
        }
Exemplo n.º 2
0
        public void GetSeasonStandingsForLeague_GenericExceptionCaught_LogsAndRethrowsException()
        {
            // Arrange
            var service = new SeasonStandingsControlService(_sharedService, _leagueRepository, _conferenceRepository,
                                                            _divisionRepository, _storedProcedureRepository);

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

            // Set up needed infrastructure of class under test.
            A.CallTo(
                () => _storedProcedureRepository.GetSeasonStandingsForLeague(A <int> .Ignored, A <string> .Ignored))
            .Throws <Exception>();

            // Act
            IEnumerable <GetSeasonStandingsForLeague_Result> result = null;

            Assert.Throws <Exception>(
                () => { result = service.GetSeasonStandingsForLeague(seasonID, leagueName); });

            // Assert
            Assert.IsNull(result);
        }