public async Task HappyPathSendSeriesToSonarrAllSeason() { var seriesResult = new SonarrAddSeries() { title = "ABC" }; SonarrMock.Setup(x => x.GetSeries(It.IsAny <string>(), It.IsAny <Uri>())).Returns(F.Build <Series>().With(x => x.tvdbId, 1).With(x => x.title, "ABC").CreateMany().ToList()); Sender = new TvSender(SonarrMock.Object, SickrageMock.Object, Cache.Object); var request = new RequestedModel { SeasonsRequested = "All", ProviderId = 1, Title = "ABC" }; var result = await Sender.SendToSonarr(GetSonarrSettings(), request); Assert.That(result.title, Is.EqualTo("ABC")); SonarrMock.Verify(x => x.AddSeries(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <bool>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int[]>(), It.IsAny <string>(), It.IsAny <Uri>(), true, It.IsAny <bool>()), Times.Never); }
public async Task RequestEpisodesWithExistingSeriesTest() { var episodesReturned = new List <SonarrEpisodes> { new SonarrEpisodes { episodeNumber = 1, seasonNumber = 2, monitored = false, id = 22 } }; SonarrMock.Setup(x => x.GetEpisodes(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Uri>())).Returns(episodesReturned); SonarrMock.Setup(x => x.GetEpisode("22", It.IsAny <string>(), It.IsAny <Uri>())).Returns(new SonarrEpisode { id = 22 }); Sender = new TvSender(SonarrMock.Object, SickrageMock.Object); var model = new RequestedModel { Episodes = new List <EpisodesModel> { new EpisodesModel { EpisodeNumber = 1, SeasonNumber = 2 } } }; var series = new Series(); await Sender.RequestEpisodesWithExistingSeries(model, series, GetSonarrSettings()); SonarrMock.Verify(x => x.UpdateEpisode(It.Is <SonarrEpisode>(e => e.monitored), It.IsAny <string>(), It.IsAny <Uri>())); SonarrMock.Verify(x => x.GetEpisode("22", It.IsAny <string>(), It.IsAny <Uri>()), Times.Once); SonarrMock.Verify(x => x.SearchForEpisodes(It.IsAny <int[]>(), It.IsAny <string>(), It.IsAny <Uri>()), Times.Once); }
public async Task HappyPathSendEpisodeWithExistingSeriesToSonarr() { var seriesResult = new SonarrAddSeries { monitored = true, title = "TitleReturned" }; var selectedSeries = F.Build <Series>().With(x => x.tvdbId, 1).CreateMany(); SonarrMock.Setup(x => x.GetSeries(It.IsAny <string>(), It.IsAny <Uri>())).Returns(selectedSeries.ToList()); SonarrMock.Setup(x => x.AddSeries( It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <bool>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int[]>(), It.IsAny <string>(), It.IsAny <Uri>(), It.IsAny <bool>(), It.IsAny <bool>())).Returns(seriesResult); var sonarrEpisodes = new SonarrEpisodes() { title = "abc", seasonNumber = 2, episodeNumber = 1, monitored = false }; var episodesList = F.CreateMany <SonarrEpisodes>().ToList(); episodesList.Add(sonarrEpisodes); SonarrMock.Setup(x => x.GetEpisodes(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Uri>())).Returns(F.CreateMany <SonarrEpisodes>()); Sender = new TvSender(SonarrMock.Object, SickrageMock.Object, Cache.Object); var episodes = new List <EpisodesModel> { new EpisodesModel { EpisodeNumber = 1, SeasonNumber = 2 } }; var model = F.Build <RequestedModel>().With(x => x.ProviderId, 1) .With(x => x.Episodes, episodes).Create(); var result = await Sender.SendToSonarr(GetSonarrSettings(), model, "2"); Assert.That(result, Is.EqualTo(seriesResult)); SonarrMock.Verify(x => x.AddSeries(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <bool>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int[]>(), It.IsAny <string>(), It.IsAny <Uri>(), true, It.IsAny <bool>()), Times.Once); }
public async Task HappyPathSendSeriesToSonarr() { var seriesResult = new SonarrAddSeries() { monitored = true }; SonarrMock.Setup(x => x.GetSeries(It.IsAny <string>(), It.IsAny <Uri>())).Returns(new List <Series>()); SonarrMock.Setup( x => x.AddSeries( It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <bool>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int[]>(), It.IsAny <string>(), It.IsAny <Uri>(), It.IsAny <bool>(), It.IsAny <bool>())).Returns(seriesResult); Sender = new TvSender(SonarrMock.Object, SickrageMock.Object); var request = new RequestedModel(); var result = await Sender.SendToSonarr(GetSonarrSettings(), request); Assert.That(result, Is.EqualTo(seriesResult)); SonarrMock.Verify(x => x.AddSeries(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <bool>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int[]>(), It.IsAny <string>(), It.IsAny <Uri>(), true, It.IsAny <bool>()), Times.Once); }