public void GetSeasonStandingsForConference_ExceptionCaught_LogsAndRethrowsException() { // Arrange var dbContext = A.Fake <ProFootballEntities>(); var repository = new StoredProcedureRepository(dbContext); var seasonID = 2017; var conferenceName = "Conference"; A.CallTo(() => dbContext.GetSeasonStandingsForConference(A <int> .Ignored, A <string> .Ignored)) .Throws <Exception>(); // Act ObjectResult <GetSeasonStandingsForConference_Result> result = null; Assert.Throws <Exception>( () => { result = repository.GetSeasonStandingsForConference(seasonID, conferenceName); }); // Assert Assert.IsNull(result); }
public void GetSeasonStandingsForConference_HappyPath() { // Arrange var dbContext = A.Fake <ProFootballEntities>(); var repository = new StoredProcedureRepository(dbContext); var seasonID = 2017; var conferenceName = "Conference"; var standings = A.Fake <ObjectResult <GetSeasonStandingsForConference_Result> >(); A.CallTo(() => dbContext.GetSeasonStandingsForConference(A <int> .Ignored, A <string> .Ignored)) .Returns(standings); // Act var result = repository.GetSeasonStandingsForConference(seasonID, conferenceName); // Assert A.CallTo(() => dbContext.GetSeasonStandingsForConference(seasonID, conferenceName)) .MustHaveHappenedOnceExactly(); Assert.AreSame(standings, result); }