public void GetRankingsDefensive_ExceptionCaught_LogsAndRethrowsException() { // Arrange var dbContext = A.Fake <ProFootballEntities>(); var repository = new StoredProcedureRepository(dbContext); var seasonID = 2017; A.CallTo(() => dbContext.GetRankingsDefensive(A <int> .Ignored)).Throws <Exception>(); // Act ObjectResult <GetRankingsDefensive_Result> result = null; Assert.Throws <Exception>(() => result = result = repository.GetRankingsDefensive(seasonID)); // Assert Assert.IsNull(result); }
public void GetRankingsDefensive_HappyPath() { // Arrange var dbContext = A.Fake <ProFootballEntities>(); var repository = new StoredProcedureRepository(dbContext); var seasonID = 2017; var defensiveRankings = A.Fake <ObjectResult <GetRankingsDefensive_Result> >(); A.CallTo(() => dbContext.GetRankingsDefensive(A <int> .Ignored)).Returns(defensiveRankings); // Act var result = repository.GetRankingsDefensive(seasonID); // Assert A.CallTo(() => dbContext.GetRankingsDefensive(seasonID)).MustHaveHappenedOnceExactly(); Assert.AreSame(defensiveRankings, result); }