public AllSubscriptionsWithNextEpisodeResult Handle(AllSubscriptionsWithNextEpisodeQuery query) { var subscriptions = _subscriptionQueryDataSource.GetAllSubscriptions(); var result = new List <SubscriptionWithNextEpisodeDto>(); foreach (var subscription in subscriptions) { result.Add(new SubscriptionWithNextEpisodeDto { Subscription = subscription, NextEpisode = _episodesQueryDataSource.GetNextEpisode(subscription.Id) }); } return(new AllSubscriptionsWithNextEpisodeResult { Subscriptions = result }); }
public void Should_get_next_show_for_each_subscription() { _subscriptionQueryDataSource.GetAllSubscriptions().Returns(new List <Subscription> { CreateSubscription() }); _episodesQueryDataSource.GetNextEpisode(1) .Returns(new Episode { AirDate = DateTime.Now.AddDays(1), Title = "Hello", SeasonNumber = 1, EpisodeNumber = 2 }); var result = _handler.Handle(new AllSubscriptionsWithNextEpisodeQuery()); _episodesQueryDataSource.Received(1).GetNextEpisode(1); var subscription = result.Subscriptions.First(); Assert.Equal(555, subscription.Subscription.TvShowId); Assert.Equal("Hello", subscription.NextEpisode.Title); }