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

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

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

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

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

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

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

            // Act
            ObjectResult <GetTeamSeasonScheduleTotals_Result> result = null;

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

            // Assert
            Assert.IsNull(result);
        }