Skip to content

Commit

Permalink
task.run for startup caching + fix admin module unit test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Drewster727 committed Apr 4, 2016
1 parent 7593d3a commit b1ea713
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
11 changes: 6 additions & 5 deletions PlexRequests.Core/Setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
using PlexRequests.Helpers;
using PlexRequests.Store;
using PlexRequests.Store.Repository;
using System.Threading.Tasks;

namespace PlexRequests.Core
{
Expand Down Expand Up @@ -102,14 +103,14 @@ private void CreateDefaultSettingsPage()
s.SaveSettings(defaultSettings);
}

public async void CacheQualityProfiles()
public void CacheQualityProfiles()
{
var mc = new MemoryCacheProvider();

try
{
CacheSonarrQualityProfiles(mc);
CacheCouchPotatoQualityProfiles(mc);
Task.Run(() => { CacheSonarrQualityProfiles(mc); });
Task.Run(() => { CacheCouchPotatoQualityProfiles(mc); });
// we don't need to cache sickrage profiles, those are static
// TODO: cache headphones profiles?
}
Expand All @@ -119,7 +120,7 @@ public async void CacheQualityProfiles()
}
}

private async void CacheSonarrQualityProfiles(MemoryCacheProvider cacheProvider)
private void CacheSonarrQualityProfiles(MemoryCacheProvider cacheProvider)
{
try
{
Expand All @@ -141,7 +142,7 @@ private async void CacheSonarrQualityProfiles(MemoryCacheProvider cacheProvider)
}
}

private async void CacheCouchPotatoQualityProfiles(MemoryCacheProvider cacheProvider)
private void CacheCouchPotatoQualityProfiles(MemoryCacheProvider cacheProvider)
{
try
{
Expand Down
4 changes: 4 additions & 0 deletions PlexRequests.UI.Tests/AdminModuleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
using PlexRequests.Store.Repository;
using PlexRequests.UI.Models;
using PlexRequests.UI.Modules;
using PlexRequests.Helpers;

namespace PlexRequests.UI.Tests
{
Expand All @@ -67,6 +68,7 @@ public class AdminModuleTests
private Mock<ICouchPotatoApi> CpApi { get; set; }
private Mock<IRepository<LogEntity>> LogRepo { get; set; }
private Mock<INotificationService> NotificationService { get; set; }
private Mock<ICacheProvider> Cache { get; set; }

private ConfigurableBootstrapper Bootstrapper { get; set; }

Expand Down Expand Up @@ -96,6 +98,7 @@ public void Setup()
PushoverApi = new Mock<IPushoverApi>();
NotificationService = new Mock<INotificationService>();
HeadphonesSettings = new Mock<ISettingsService<HeadphonesSettings>>();
Cache = new Mock<ICacheProvider>();

Bootstrapper = new ConfigurableBootstrapper(with =>
{
Expand All @@ -117,6 +120,7 @@ public void Setup()
with.Dependency(PushoverApi.Object);
with.Dependency(NotificationService.Object);
with.Dependency(HeadphonesSettings.Object);
with.Dependencies(Cache.Object);
with.RootPathProvider<TestRootPathProvider>();
with.RequestStartup((container, pipelines, context) =>
{
Expand Down
4 changes: 4 additions & 0 deletions PlexRequests.UI.Tests/PlexRequests.UI.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
<Project>{DD7DC444-D3BF-4027-8AB9-EFC71F5EC581}</Project>
<Name>PlexRequests.Core</Name>
</ProjectReference>
<ProjectReference Include="..\PlexRequests.Helpers\PlexRequests.Helpers.csproj">
<Project>{1252336d-42a3-482a-804c-836e60173dfa}</Project>
<Name>PlexRequests.Helpers</Name>
</ProjectReference>
<ProjectReference Include="..\PlexRequests.Services\PlexRequests.Services.csproj">
<Project>{566EFA49-68F8-4716-9693-A6B3F2624DEA}</Project>
<Name>PlexRequests.Services</Name>
Expand Down

0 comments on commit b1ea713

Please sign in to comment.