public void GetSeasonStandingsForDivision_ExceptionCaught_LogsAndRethrowsException() { // Arrange var dbContext = A.Fake <ProFootballEntities>(); var repository = new StoredProcedureRepository(dbContext); var seasonID = 2017; var divisionName = "Division"; A.CallTo(() => dbContext.GetSeasonStandingsForDivision(A <int> .Ignored, A <string> .Ignored)) .Throws <Exception>(); // Act ObjectResult <GetSeasonStandingsForDivision_Result> result = null; Assert.Throws <Exception>( () => { result = repository.GetSeasonStandingsForDivision(seasonID, divisionName); }); // Assert Assert.IsNull(result); }
public void GetSeasonStandingsForDivision_HappyPath() { // Arrange var dbContext = A.Fake <ProFootballEntities>(); var repository = new StoredProcedureRepository(dbContext); var seasonID = 2017; var divisionName = "Division"; var standings = A.Fake <ObjectResult <GetSeasonStandingsForDivision_Result> >(); A.CallTo(() => dbContext.GetSeasonStandingsForDivision(A <int> .Ignored, A <string> .Ignored)) .Returns(standings); // Act var result = repository.GetSeasonStandingsForDivision(seasonID, divisionName); // Assert A.CallTo(() => dbContext.GetSeasonStandingsForDivision(seasonID, divisionName)). MustHaveHappenedOnceExactly(); Assert.AreSame(standings, result); }