コード例 #1
0
        public void Setup()
        {
            SettingsMock = new Mock <ISettingsService <SonarrSettingsViewModelDto> >();
            ServiceMock  = new Mock <IThirdPartyService>();
            var f = new Fixture();

            ExpectedSettings = f.Create <SonarrSettingsViewModelDto>();
            SonarrSeries     = f.CreateMany <SonarrSeries>().ToList();
            SonarrEpisode    = f.CreateMany <SonarrEpisode>().ToList();


            SettingsMock.Setup(x => x.GetSettings()).Returns(ExpectedSettings);
            ServiceMock.Setup(x => x.GetSonarrSeries(It.IsAny <string>(), It.IsAny <string>())).Returns(SonarrSeries);
            ServiceMock.Setup(x => x.GetSonarrEpisodes(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>())).Returns(SonarrEpisode);
            _controller = new SonarrController(ServiceMock.Object, SettingsMock.Object);
        }
コード例 #2
0
        public void GetEpisodesForSeriesNoConfig()
        {
            SettingsMock = new Mock <ISettingsService <SonarrSettingsViewModelDto> >();
            ServiceMock  = new Mock <IThirdPartyService>();
            var f = new Fixture();

            ExpectedSettings = new SonarrSettingsViewModelDto();
            SonarrSeries     = f.CreateMany <SonarrSeries>().ToList();
            SonarrEpisode    = f.CreateMany <SonarrEpisode>().ToList();


            SettingsMock.Setup(x => x.GetSettings()).Returns(ExpectedSettings);
            ServiceMock.Setup(x => x.GetSonarrSeries(It.IsAny <string>(), It.IsAny <string>())).Returns(SonarrSeries);
            ServiceMock.Setup(x => x.GetSonarrEpisodes(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>())).Returns(SonarrEpisode);
            _controller = new SonarrController(ServiceMock.Object, SettingsMock.Object);

            var series = (PartialViewResult)_controller.GetEpisodes(1, "title");
            var model  = series.ViewBag;

            Assert.That(model.Error, Is.Not.Null);
        }