示例#1
0
        public void AddSeason_HappyPath()
        {
            // Arrange
            var dbContext  = A.Fake <ProFootballEntities>();
            var repository = new SeasonRepository(dbContext);

            var season = new Season();

            A.CallTo(() => dbContext.Seasons.Add(A <Season> .Ignored)).Returns(season);

            // Act
            var result = repository.AddEntity(season);

            // Assert
            A.CallTo(() => dbContext.Seasons.Add(season)).MustHaveHappenedOnceExactly();
            Assert.AreSame(season, result);
        }
示例#2
0
        public void AddSeason_ExceptionCaught_LogsAndRethrowsException()
        {
            // Arrange
            var dbContext  = A.Fake <ProFootballEntities>();
            var repository = new SeasonRepository(dbContext);

            var season = new Season();

            A.CallTo(() => dbContext.Seasons.Add(A <Season> .Ignored)).Throws <Exception>();

            // Act
            Season result = null;

            Assert.Throws <Exception>(() => result = repository.AddEntity(season));

            // Assert
            Assert.IsNull(result);
        }