public async Task GetTeamSeasonScheduleAverages_WhenExceptionIsNotCaught_ShouldReturnTeamSeasonOpponentAveragesModel()
        {
            // Arrange
            var teamSeasonScheduleAveragesRepository = A.Fake <ITeamSeasonScheduleRepository>();
            TeamSeasonScheduleAverages?teamSeasonScheduleAverages = new TeamSeasonScheduleAverages();

            A.CallTo(() => teamSeasonScheduleAveragesRepository.GetTeamSeasonScheduleAveragesAsync(
                         A <string> .Ignored, A <int> .Ignored)).Returns(teamSeasonScheduleAverages);

            var mapper = A.Fake <IMapper>();
            var teamSeasonScheduleAveragesModel = new TeamSeasonScheduleAveragesModel();

            A.CallTo(() => mapper.Map <TeamSeasonScheduleAveragesModel>(A <TeamSeasonScheduleAverages> .Ignored))
            .Returns(teamSeasonScheduleAveragesModel);

            var testController = new TeamSeasonScheduleController(teamSeasonScheduleAveragesRepository, mapper);

            string teamName   = "Team";
            int    seasonYear = 1920;

            // Act
            var result = await testController.GetTeamSeasonScheduleAverages(teamName, seasonYear);

            // Assert
            A.CallTo(() => teamSeasonScheduleAveragesRepository.GetTeamSeasonScheduleAveragesAsync(teamName, seasonYear))
            .MustHaveHappenedOnceExactly();
            A.CallTo(() => mapper.Map <TeamSeasonScheduleAveragesModel>(teamSeasonScheduleAverages))
            .MustHaveHappenedOnceExactly();
            result.Value.ShouldBeOfType <TeamSeasonScheduleAveragesModel>();
        }
        public async Task GetTeamSeasonScheduleProfile_WhenExceptionIsCaught_ShouldReturnInternalServerError()
        {
            // Arrange
            var teamSeasonScheduleRepository = A.Fake <ITeamSeasonScheduleRepository>();

            A.CallTo(() => teamSeasonScheduleRepository.GetTeamSeasonScheduleProfileAsync(
                         A <string> .Ignored, A <int> .Ignored)).Throws <Exception>();

            var mapper = A.Fake <IMapper>();

            var testController = new TeamSeasonScheduleController(teamSeasonScheduleRepository, mapper);

            string teamName   = "Team";
            int    seasonYear = 1920;

            // Act
            var result = await testController.GetTeamSeasonScheduleProfile(teamName, seasonYear);

            // Assert
            result.Result.ShouldBeOfType <ObjectResult>();
            ((ObjectResult)result.Result).StatusCode.ShouldBe(StatusCodes.Status500InternalServerError);
            ((ObjectResult)result.Result).Value.ShouldBe("Database failure");
        }
        public async Task GetTeamSeasonScheduleProfile_WhenProfileIsNotEmpty_ShouldReturnTeamSeasonOpponentProfileModelArray()
        {
            // Arrange
            var teamSeasonScheduleRepository = A.Fake <ITeamSeasonScheduleRepository>();
            var teamSeasonScheduleProfile    = new List <TeamSeasonOpponentProfile>
            {
                new TeamSeasonOpponentProfile()
            };

            A.CallTo(() => teamSeasonScheduleRepository.GetTeamSeasonScheduleProfileAsync(
                         A <string> .Ignored, A <int> .Ignored)).Returns(teamSeasonScheduleProfile);

            var mapper = A.Fake <IMapper>();

            TeamSeasonOpponentProfileModel[] teamSeasonScheduleProfileModels =
            {
                new TeamSeasonOpponentProfileModel()
            };
            A.CallTo(() => mapper.Map <TeamSeasonOpponentProfileModel[]>(A <TeamSeasonOpponentProfile> .Ignored))
            .Returns(teamSeasonScheduleProfileModels);

            var testController = new TeamSeasonScheduleController(teamSeasonScheduleRepository, mapper);

            string teamName   = "Team";
            int    seasonYear = 1920;

            // Act
            var result = await testController.GetTeamSeasonScheduleProfile(teamName, seasonYear);

            // Assert
            A.CallTo(() => teamSeasonScheduleRepository.GetTeamSeasonScheduleProfileAsync(teamName, seasonYear))
            .MustHaveHappenedOnceExactly();
            A.CallTo(() => mapper.Map <TeamSeasonOpponentProfileModel[]>(teamSeasonScheduleProfile))
            .MustHaveHappenedOnceExactly();
            result.Value.ShouldBeOfType <TeamSeasonOpponentProfileModel[]>();
        }