private GetNzbGetDownloadInformation ( ) : System.Web.Mvc.ActionResult | ||
Résultat | System.Web.Mvc.ActionResult |
public void GetNzbGetDownloadInformation() { var f = new Fixture(); var expectedApi = f.Create<NzbGetList>(); var expectedStatus = f.Create<NzbGetStatus>(); var mockSettings = new Mock<ISettingsService<NzbGetSettingsDto>>(); var mockApi = new Mock<IThirdPartyService>(); var mockLogger = new Mock<ILogger>(); mockSettings.Setup(x => x.GetSettings()).Returns(ExpectedSettings).Verifiable(); mockApi.Setup(x => x.GetNzbGetList(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Returns(expectedApi).Verifiable(); mockApi.Setup(x => x.GetNzbGetStatus(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())).Returns(expectedStatus).Verifiable(); var controller = new NzbGetController(mockSettings.Object, mockApi.Object, mockLogger.Object); var result = (PartialViewResult)controller.GetNzbGetDownloadInformation(); var model = (DownloaderViewModel)result.Model; Assert.That(result.Model, Is.TypeOf<DownloaderViewModel>()); Assert.That(model.Application, Is.EqualTo(Applications.NzbGet)); Assert.That(model.DownloadItem[0].DownloadingName, Is.EqualTo(expectedApi.result[0].NZBName)); Assert.That(model.DownloadItem[0].NzbId, Is.EqualTo(expectedApi.result[0].NZBID)); }
public void GetNzbGetDownloadInformationNoConfig() { var badSettings = new NzbGetSettingsDto(); var mockSettings = new Mock<ISettingsService<NzbGetSettingsDto>>(); var mockApi = new Mock<IThirdPartyService>(); var mockLogger = new Mock<ILogger>(); mockSettings.Setup(x => x.GetSettings()).Returns(badSettings).Verifiable(); var controller = new NzbGetController(mockSettings.Object, mockApi.Object, mockLogger.Object); var result = (PartialViewResult)controller.GetNzbGetDownloadInformation(); var model = result.ViewBag; Assert.That(model.Error, Is.Not.Null); }