Added some tests and fixed the issue where the DB would get created in the wrong place depending on how you launched the application

This commit is contained in:
tidusjar 2016-03-29 14:13:13 +01:00
commit e2aa4016a8
8 changed files with 221 additions and 35 deletions

View file

@ -53,7 +53,7 @@ namespace PlexRequests.Services
private ISettingsService<AuthenticationSettings> Auth { get; }
private IRequestService RequestService { get; }
private static Logger Log = LogManager.GetCurrentClassLogger();
private IPlexApi PlexApi { get; set; }
private IPlexApi PlexApi { get; }
public void CheckAndUpdateAll(long check)
@ -63,7 +63,7 @@ namespace PlexRequests.Services
var requests = RequestService.GetAll();
var requestedModels = requests as RequestedModel[] ?? requests.ToArray();
if (!ValidateSettings(plexSettings, authSettings, requestedModels))
if (!ValidateSettings(plexSettings, authSettings) || !requestedModels.Any())
{
return;
}
@ -114,21 +114,6 @@ namespace PlexRequests.Services
}
private bool ValidateSettings(PlexSettings plex, AuthenticationSettings auth, IEnumerable<RequestedModel> requests)
{
if (plex.Ip == null || auth.PlexAuthToken == null || requests == null)
{
Log.Warn("A setting is null, Ensure Plex is configured correctly, and we have a Plex Auth token.");
return false;
}
if (!requests.Any())
{
Log.Info("We have no requests to check if they are available on Plex.");
return false;
}
return true;
}
private bool ValidateSettings(PlexSettings plex, AuthenticationSettings auth)
{
if (plex?.Ip == null || auth?.PlexAuthToken == null)