Added a new method for triggering jobs rather than scheduling ad-hoc.

This commit is contained in:
Joseph Milazzo 2021-03-14 09:39:48 -05:00
parent a7516d313d
commit d23a569446
4 changed files with 51 additions and 16 deletions

View file

@ -1,18 +1,50 @@
using Xunit;
using System.Collections.Generic;
using System.IO;
using API.Data;
using API.Entities;
using API.Interfaces;
using API.Interfaces.Services;
using API.Services;
using Microsoft.Extensions.Logging;
using NSubstitute;
using Xunit;
namespace API.Tests.Services
{
public class CacheServiceTests
{
// private readonly CacheService _cacheService;
// private readonly ILogger<CacheService> _logger = Substitute.For<ILogger<CacheService>>();
// private readonly IUnitOfWork _unitOfWork = Substitute.For<IUnitOfWork>();
// private readonly IArchiveService _archiveService = Substitute.For<IArchiveService>();
// private readonly IDirectoryService _directoryService = Substitute.For<DirectoryService>();
private readonly CacheService _cacheService;
private readonly ILogger<CacheService> _logger = Substitute.For<ILogger<CacheService>>();
private readonly IUnitOfWork _unitOfWork = Substitute.For<IUnitOfWork>();
private readonly IArchiveService _archiveService = Substitute.For<IArchiveService>();
private readonly IDirectoryService _directoryService = Substitute.For<DirectoryService>();
// public CacheServiceTests()
public CacheServiceTests()
{
_cacheService = new CacheService(_logger, _unitOfWork, _archiveService, _directoryService);
}
// [Fact]
// public async void Ensure_ShouldExtractArchive(int chapterId)
// {
// //_cacheService = new CacheService(_logger, _unitOfWork, _archiveService, _directoryService);
//
// // CacheDirectory needs to be customized.
// _unitOfWork.VolumeRepository.GetChapterAsync(chapterId).Returns(new Chapter
// {
// Id = 1,
// Files = new List<MangaFile>()
// {
// new MangaFile()
// {
// FilePath = ""
// }
// }
// });
//
// await _cacheService.Ensure(1);
//
// var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/CacheService/Archives");
//
// }
//string GetCachedPagePath(Volume volume, int page)