public void RemoveSeasons()
        {
            // Arrange
            var repository = new SeasonRepository();

            var dbContext = A.Fake <ProFootballEntities>();
            var seasons   = new List <Season>();

            for (int i = 0; i < 3; i++)
            {
                var season = new Season
                {
                    ID = 2017 - i
                };
                seasons.Add(season);
            }
            A.CallTo(() => dbContext.Seasons.RemoveRange(A <IEnumerable <Season> > .Ignored)).Returns(seasons);

            // Act
            var result = repository.RemoveEntities(dbContext, seasons);

            // Assert
            A.CallTo(() => dbContext.Seasons.RemoveRange(seasons)).MustHaveHappenedOnceExactly();
            Assert.AreSame(seasons, result);
        }
Esempio n. 2
0
        public void RemoveSeasons_HappyPath()
        {
            // Arrange
            var dbContext  = A.Fake <ProFootballEntities>();
            var repository = new SeasonRepository(dbContext);

            var seasons = new List <Season>();

            A.CallTo(() => dbContext.Seasons.RemoveRange(A <IEnumerable <Season> > .Ignored)).Returns(seasons);

            // Act
            var result = repository.RemoveEntities(seasons);

            // Assert
            A.CallTo(() => dbContext.Seasons.RemoveRange(seasons)).MustHaveHappenedOnceExactly();
            Assert.AreSame(seasons, result);
        }
Esempio n. 3
0
        public void RemoveSeasons_ExceptionCaught_LogsAndRethrowsException()
        {
            // Arrange
            var dbContext  = A.Fake <ProFootballEntities>();
            var repository = new SeasonRepository(dbContext);

            var seasons = new List <Season>();

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

            // Act
            IEnumerable <Season> result = null;

            Assert.Throws <Exception>(() => result = repository.RemoveEntities(seasons));

            // Assert
            Assert.IsNull(result);
        }