public async Task GetGuestAndHostSeasonIds_GuestAndHostSeasonIdsNull_GuestAndHostSeasonIdsChanged() { // Arrange var service = new GamePredictorService(_dataMapper, _seasonRepository, _teamSeasonRepository); GamePredictorService.GuestSeasonID = null; GamePredictorService.HostSeasonID = null; var dbContext = A.Fake <ProFootballEntities>(); var seasons = new List <Season> { new Season { ID = 2017 }, new Season { ID = 2016 }, new Season { ID = 2014 } }; A.CallTo(() => _seasonRepository.GetEntitiesAsync(dbContext)).Returns(seasons); // Act await service.GetGuestAndHostSeasonIds(dbContext); // Assert A.CallTo(() => _seasonRepository.GetEntitiesAsync(dbContext)).MustHaveHappenedOnceExactly(); // Get guest season. Assert.AreEqual(2017, GamePredictorService.GuestSeasonID); Assert.AreEqual(2017, GamePredictorService.HostSeasonID); }
public async Task GetGuestAndHostSeasonIds_GuestAndHostSeasonIdsNullButArgumentNullExceptionCaught_GuestAndHostSeasonIdsNotChanged() { // Arrange var service = new GamePredictorService(_dataMapper, _seasonRepository, _teamSeasonRepository); GamePredictorService.GuestSeasonID = null; GamePredictorService.HostSeasonID = null; var dbContext = A.Fake <ProFootballEntities>(); A.CallTo(() => _seasonRepository.GetEntitiesAsync(dbContext)).Throws <ArgumentNullException>(); // Act await service.GetGuestAndHostSeasonIds(dbContext); // Assert A.CallTo(() => _seasonRepository.GetEntitiesAsync(dbContext)).MustHaveHappenedOnceExactly(); // Get guest season. Assert.IsNull(GamePredictorService.GuestSeasonID); Assert.IsNull(GamePredictorService.HostSeasonID); }