public static void SetUpFakeSeasonStandings(this ProFootballEntities dbContext, IEnumerable <GetSeasonStandings_Result> seasonStandingsEnumerable = null) { if (seasonStandingsEnumerable == null) { seasonStandingsEnumerable = new List <GetSeasonStandings_Result>(); } var seasonStandingsQueryable = seasonStandingsEnumerable.AsQueryable(); var fakeObjectResult = A.Fake <ObjectResult <GetSeasonStandings_Result> >(d => d.Implements(typeof(IEnumerable <GetSeasonStandings_Result>))); // Setup all IEnumerable methods using what you have from "seasonStandings" A.CallTo(() => (fakeObjectResult as IEnumerable <GetSeasonStandings_Result>).GetEnumerator()) .Returns(seasonStandingsQueryable.GetEnumerator()); // Do the wiring between DbContext and ObjectResult A.CallTo(() => dbContext.GetSeasonStandings(A <int> .Ignored, A <bool> .Ignored)).Returns(fakeObjectResult); }
/// <summary> /// Gets the standings for a specified season /// </summary> /// <param name="dbContext">An instance of the ProFootballEntities class</param> /// <param name="seasonID">The ID of the selected season</param> /// <param name="groupByDivision">A flag to tell the application whether to group the standings by division</param> /// <returns>The result of the stored procedure execution</returns> public ObjectResult <GetSeasonStandings_Result> GetSeasonStandings(ProFootballEntities dbContext, int?seasonID, bool?groupByDivision) { ObjectResult <GetSeasonStandings_Result> retVal = null; try { retVal = dbContext.GetSeasonStandings(seasonID, groupByDivision); } catch (ArgumentException ex) { _log.Error("Argument exception in StoredProcedureRepository.GetSeasonStandings: " + ex.Message); } catch (InvalidOperationException ex) { _log.Error("Invalid operation in StoredProcedureRepository.GetSeasonStandings: " + ex.Message); } return(retVal); }