public void GetNzbGetLogsNoConfigTest() { var expectedSettings = new NzbGetSettingsDto(); var mockSettings = new Mock <ISettingsService <NzbGetSettingsDto> >(); var mockLogger = new Mock <ILogger>(); var mockApi = new Mock <IThirdPartyService>(); mockSettings.Setup(x => x.GetSettings()).Returns(expectedSettings); var controller = new NzbGetController(mockSettings.Object, mockApi.Object, mockLogger.Object); var result = (PartialViewResult)controller.Logs(); var model = result.ViewBag; Assert.That(model.Error, Is.Not.Null); }
public void GetNzbGetLogsNullResultTest() { var expected = new NzbGetLogs { result = null, }; var mockSettings = new Mock <ISettingsService <NzbGetSettingsDto> >(); var mockApi = new Mock <IThirdPartyService>(); var mockLogger = new Mock <ILogger>(); mockSettings.Setup(x => x.GetSettings()).Returns(ExpectedSettings); mockApi.Setup(x => x.GetNzbGetLogs(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(expected); var controller = new NzbGetController(mockSettings.Object, mockApi.Object, mockLogger.Object); var result = (PartialViewResult)controller.Logs(); var model = (List <NzbGetLogViewModel>)result.Model; Assert.That(model.Count, Is.EqualTo(0)); }
public void GetNzbGetLogsTest() { var expected = new NzbGetLogs { result = new List <LogResult> { new LogResult { ID = 2, Kind = "WARNING", Text = "TEXT", Time = 22, }, new LogResult { ID = 9999, Kind = "WARNING", Text = "TEXT", Time = 1448544679, }, }, }; var ordered = expected.result.OrderByDescending(x => x.ID).ToList(); var mockSettings = new Mock <ISettingsService <NzbGetSettingsDto> >(); var mockApi = new Mock <IThirdPartyService>(); var mockLogger = new Mock <ILogger>(); mockSettings.Setup(x => x.GetSettings()).Returns(ExpectedSettings); mockApi.Setup(x => x.GetNzbGetLogs(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(expected); var controller = new NzbGetController(mockSettings.Object, mockApi.Object, mockLogger.Object); var result = (PartialViewResult)controller.Logs(); var model = (List <NzbGetLogViewModel>)result.Model; Assert.That(model[0].Id, Is.EqualTo(9999)); Assert.That(model[0].Kind, Is.EqualTo(ordered[0].Kind)); Assert.That(model[0].Text, Is.EqualTo(ordered[0].Text)); Assert.That(model[0].Time, Is.EqualTo(new DateTime(2015, 11, 26, 13, 31, 19))); }