public void CreateTeamSeason_HappyPath() { // Arrange var dbContext = A.Fake <ProFootballEntities>(); var repository = new TeamSeasonRepository(dbContext); A.CallTo(() => dbContext.TeamSeasons.Create()).Returns(new TeamSeason()); // Act var result = repository.CreateEntity(); // Assert A.CallTo(() => dbContext.TeamSeasons.Create()).MustHaveHappenedOnceExactly(); Assert.IsInstanceOf <TeamSeason>(result); }
public void CreateTeamSeason_ExceptionCaught_LogsAndRethrowsException() { // Arrange var dbContext = A.Fake <ProFootballEntities>(); var repository = new TeamSeasonRepository(dbContext); A.CallTo(() => dbContext.TeamSeasons.Create()).Throws <Exception>(); // Act TeamSeason result = null; Assert.Throws <Exception>(() => result = repository.CreateEntity()); // Assert Assert.IsNull(result); }