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