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

            var season = new Season();

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

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

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

            var season = new Season();

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

            // Act
            Season result = null;

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

            // Assert
            Assert.IsNull(result);
        }