public void GetRankingsTotal_ExceptionCaught_LogsAndRethrowsException() { // Arrange var dbContext = A.Fake <ProFootballEntities>(); var repository = new StoredProcedureRepository(dbContext); var seasonID = 2017; A.CallTo(() => dbContext.GetRankingsTotal(A <int> .Ignored)).Throws <Exception>(); // Act ObjectResult <GetRankingsTotal_Result> result = null; Assert.Throws <Exception>(() => result = result = repository.GetRankingsTotal(seasonID)); // Assert Assert.IsNull(result); }
public void GetRankingsTotal_HappyPath() { // Arrange var dbContext = A.Fake <ProFootballEntities>(); var repository = new StoredProcedureRepository(dbContext); var seasonID = 2017; var totalRankings = A.Fake <ObjectResult <GetRankingsTotal_Result> >(); A.CallTo(() => dbContext.GetRankingsTotal(A <int> .Ignored)).Returns(totalRankings); // Act var result = repository.GetRankingsTotal(seasonID); // Assert A.CallTo(() => dbContext.GetRankingsTotal(seasonID)).MustHaveHappenedOnceExactly(); Assert.AreSame(totalRankings, result); }