public void GetLeagueSeasonTotals() { // Arrange var repository = new StoredProcedureRepository(); var dbContext = A.Fake <ProFootballEntities>(); var leagueName = "League"; var seasonID = 2017; A.CallTo(() => dbContext.GetLeagueSeasonTotals(A <string> .Ignored, A <int> .Ignored)) .Returns(A.Fake <ObjectResult <GetLeagueSeasonTotals_Result> >()); // Act var result = repository.GetLeagueSeasonTotals(dbContext, leagueName, seasonID); // Assert A.CallTo(() => dbContext.GetLeagueSeasonTotals(leagueName, seasonID)).MustHaveHappenedOnceExactly(); Assert.IsInstanceOf <ObjectResult <GetLeagueSeasonTotals_Result> >(result); }
public void GetLeagueSeasonTotals_GenericExceptionCaught_LogsAndRethrowsException() { // Arrange var dbContext = A.Fake <ProFootballEntities>(); var repository = new StoredProcedureRepository(dbContext); var leagueName = "League"; var seasonID = 2017; A.CallTo(() => dbContext.GetLeagueSeasonTotals(A <string> .Ignored, A <int> .Ignored)) .Throws <Exception>(); // Act ObjectResult <GetLeagueSeasonTotals_Result> result = null; Assert.Throws <Exception>( () => { result = repository.GetLeagueSeasonTotals(leagueName, seasonID); }); // Assert Assert.IsNull(result); }