Exemple #1
0
        public void GetTeamSeasonScheduleAverages()
        {
            // Arrange
            var repository = new StoredProcedureRepository();

            var dbContext = A.Fake <ProFootballEntities>();
            var teamName  = "Team";
            var seasonID  = 2017;

            A.CallTo(() => dbContext.GetTeamSeasonScheduleAverages(A <string> .Ignored, A <int> .Ignored))
            .Returns(A.Fake <ObjectResult <GetTeamSeasonScheduleAverages_Result> >());

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

            // Assert
            A.CallTo(() => dbContext.GetTeamSeasonScheduleAverages(teamName, seasonID))
            .MustHaveHappenedOnceExactly();
            Assert.IsInstanceOf <ObjectResult <GetTeamSeasonScheduleAverages_Result> >(result);
        }
        public void GetTeamSeasonScheduleAverages_GenericExceptionCaught_LogsAndRethrowsException()
        {
            // Arrange
            var dbContext  = A.Fake <ProFootballEntities>();
            var repository = new StoredProcedureRepository(dbContext);

            var teamName = "Team";
            var seasonID = 2017;

            A.CallTo(() => dbContext.GetTeamSeasonScheduleAverages(A <string> .Ignored, A <int> .Ignored))
            .Throws <Exception>();

            // Act
            ObjectResult <GetTeamSeasonScheduleAverages_Result> result = null;

            Assert.Throws <Exception>(
                () => { result = repository.GetTeamSeasonScheduleAverages(teamName, seasonID); });

            // Assert
            Assert.IsNull(result);
        }