/// <summary> /// Gets totals for a league's season /// </summary> /// <param name="leagueName">The name of the selected league</param> /// <param name="seasonID">The ID of the selected season</param> /// <returns>The result of the stored procedure execution</returns> public ObjectResult <GetLeagueSeasonTotals_Result> GetLeagueSeasonTotals(string leagueName, int?seasonID) { try { return(_dbContext.GetLeagueSeasonTotals(leagueName, seasonID)); } catch (ArgumentException ex) { _log.Error($"Argument exception in StoredProcedureRepository.GetLeagueSeasonTotals: {ex.Message}"); throw; } catch (InvalidOperationException ex) { _log.Error($"Invalid operation in StoredProcedureRepository.GetLeagueSeasonTotals: {ex.Message}"); throw; } catch (Exception ex) { _log.Error(ex.Message); throw; } }
public static void SetUpFakeLeagueSeasonTotals(this ProFootballEntities dbContext, IEnumerable <GetLeagueSeasonTotals_Result> leagueSeasonTotalsEnumerable = null) { if (leagueSeasonTotalsEnumerable == null) { leagueSeasonTotalsEnumerable = new List <GetLeagueSeasonTotals_Result> { new GetLeagueSeasonTotals_Result { TotalGames = 256, TotalPoints = 5120, AveragePoints = 20.00 } }; } var leagueSeasonTotalsQueryable = leagueSeasonTotalsEnumerable.AsQueryable(); var fakeObjectResult = A.Fake <ObjectResult <GetLeagueSeasonTotals_Result> >(d => d.Implements(typeof(IEnumerable <GetLeagueSeasonTotals_Result>))); // Setup all IEnumerable methods using what you have from "leagueSeasonTotals" A.CallTo(() => (fakeObjectResult as IEnumerable <GetLeagueSeasonTotals_Result>).GetEnumerator()) .Returns(leagueSeasonTotalsQueryable.GetEnumerator()); // Do the wiring between DbContext and ObjectResult A.CallTo(() => dbContext.GetLeagueSeasonTotals(A <string> .Ignored, A <int> .Ignored)) .Returns(fakeObjectResult); }
/// <summary> /// Gets totals for a league's season /// </summary> /// <param name="dbContext">An instance of the ProFootballEntities class</param> /// <param name="leagueName">The name of the selected league</param> /// <param name="seasonID">The ID of the selected season</param> /// <returns>The result of the stored procedure execution</returns> public ObjectResult <GetLeagueSeasonTotals_Result> GetLeagueSeasonTotals(ProFootballEntities dbContext, string leagueName, int?seasonID) { ObjectResult <GetLeagueSeasonTotals_Result> retVal = null; try { retVal = dbContext.GetLeagueSeasonTotals(leagueName, seasonID); } catch (ArgumentException ex) { _log.Error("Argument exception in StoredProcedureRepository.GetLeagueSeasonTotals: " + ex.Message); } catch (InvalidOperationException ex) { _log.Error("Invalid operation in StoredProcedureRepository.GetLeagueSeasonTotals: " + ex.Message); } return(retVal); }