public void CreateSeason_HappyPath() { // Arrange var dbContext = A.Fake <ProFootballEntities>(); var repository = new SeasonRepository(dbContext); A.CallTo(() => dbContext.Seasons.Create()).Returns(new Season()); // Act var result = repository.CreateEntity(); // Assert A.CallTo(() => dbContext.Seasons.Create()).MustHaveHappenedOnceExactly(); Assert.IsInstanceOf <Season>(result); }
public void CreateSeason_ExceptionCaught_LogsAndRethrowsException() { // Arrange var dbContext = A.Fake <ProFootballEntities>(); var repository = new SeasonRepository(dbContext); A.CallTo(() => dbContext.Seasons.Create()).Throws <Exception>(); // Act Season result = null; Assert.Throws <Exception>(() => result = repository.CreateEntity()); // Assert Assert.IsNull(result); }