Ejemplo n.º 1
0
        public void GetNoUsenetDownloaderDownloadCount()
        {
            var mockNzbGet = new Mock <ISettingsService <NzbGetSettingsDto> >();
            var mockSab    = new Mock <ISettingsService <SabNzbdSettingsDto> >();
            var logger     = new Mock <ILogger>();

            _controller = new DashboardController(HardwareServiceMock.Object, ThirdPartyApi.Object, logger.Object, mockNzbGet.Object, mockSab.Object, NzbDashSettings.Object);

            var result = (PartialViewResult)_controller.GetDownloads();
            var model  = (DashboardDownloadViewModel)result.Model;

            Assert.That(model.Application, Is.Null);
            logger.Verify(x => x.Trace(It.IsAny <string>()), Times.Once);
        }
Ejemplo n.º 2
0
        public void GetNzbGetDownloadCount()
        {
            var mockNzbGet = new Mock <ISettingsService <NzbGetSettingsDto> >();
            var mockSab    = new Mock <ISettingsService <SabNzbdSettingsDto> >();

            var nzbGetSettings = F.Create <NzbGetSettingsDto>();
            var nzbList        = F.Create <NzbGetList>();

            mockNzbGet.Setup(x => x.GetSettings()).Returns(nzbGetSettings).Verifiable();
            ThirdPartyApi.Setup(x => x.GetNzbGetList(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(nzbList).Verifiable();
            _controller = new DashboardController(HardwareServiceMock.Object, ThirdPartyApi.Object, new Mock <ILogger>().Object, mockNzbGet.Object, mockSab.Object, NzbDashSettings.Object);

            var result = (PartialViewResult)_controller.GetDownloads();
            var model  = (DashboardDownloadViewModel)result.Model;

            Assert.That(model.Application, Is.EqualTo("NzbGet"));
            Assert.That(model.DownloadItems, Is.EqualTo(nzbList.result.Count));

            mockNzbGet.Verify(x => x.GetSettings(), Times.Once);
            mockSab.Verify(x => x.GetSettings(), Times.Once);
            ThirdPartyApi.Verify(x => x.GetNzbGetList(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Once);
            ThirdPartyApi.Verify(x => x.GetSabNzbdQueue(It.IsAny <string>(), It.IsAny <string>()), Times.Never);
        }