2023-01-21 19:36:12 +00:00
|
|
|
using System.Runtime.InteropServices;
|
2021-09-27 12:42:46 +00:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
using Wabbajack.DTOs;
|
2023-01-21 19:36:12 +00:00
|
|
|
using Wabbajack.Hashing.PHash;
|
2021-09-27 12:42:46 +00:00
|
|
|
using Wabbajack.Paths.IO;
|
|
|
|
using Wabbajack.RateLimiter;
|
2022-06-22 01:38:42 +00:00
|
|
|
using Wabbajack.VFS.Interfaces;
|
2021-09-27 12:42:46 +00:00
|
|
|
using Xunit.DependencyInjection;
|
|
|
|
using Xunit.DependencyInjection.Logging;
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
namespace Wabbajack.VFS.Test;
|
|
|
|
|
|
|
|
public class Startup
|
2021-09-27 12:42:46 +00:00
|
|
|
{
|
2021-10-23 16:51:17 +00:00
|
|
|
public void ConfigureServices(IServiceCollection service)
|
2021-09-27 12:42:46 +00:00
|
|
|
{
|
2021-10-23 16:51:17 +00:00
|
|
|
service.AddSingleton<TemporaryFileManager, TemporaryFileManager>();
|
|
|
|
service
|
|
|
|
.AddAllSingleton<IResource, IResource<FileExtractor.FileExtractor>, Resource<FileExtractor.FileExtractor>>(
|
|
|
|
s =>
|
|
|
|
new Resource<FileExtractor.FileExtractor>("File Extractor", 2));
|
2021-10-23 18:36:35 +00:00
|
|
|
service
|
|
|
|
.AddAllSingleton<IResource, IResource<Context>, Resource<Context>>(
|
|
|
|
s =>
|
|
|
|
new ("VFS Context", 2));
|
2021-10-23 22:27:59 +00:00
|
|
|
|
|
|
|
service
|
|
|
|
.AddAllSingleton<IResource, IResource<FileHashCache>, Resource<FileHashCache>>(
|
|
|
|
s =>
|
|
|
|
new ("File Hash Cache", 2));
|
2023-01-21 19:36:12 +00:00
|
|
|
|
|
|
|
// ImageLoader
|
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
|
|
service.AddSingleton<IImageLoader, TexConvImageLoader>();
|
|
|
|
else
|
|
|
|
service.AddSingleton<IImageLoader, CrossPlatformImageLoader>();
|
|
|
|
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
// Keep this fixed at 2 so that we can detect deadlocks in the VFS parallelOptions
|
|
|
|
service.AddSingleton(new ParallelOptions {MaxDegreeOfParallelism = 2});
|
|
|
|
service.AddSingleton(new FileHashCache(KnownFolders.EntryPoint.Combine("hashcache.sqlite"),
|
|
|
|
new Resource<FileHashCache>("File Hashing", 10)));
|
2022-06-22 01:38:42 +00:00
|
|
|
service.AddAllSingleton<IVfsCache, VFSDiskCache>(x => new VFSDiskCache(KnownFolders.EntryPoint.Combine("vfscache.sqlite")));
|
2021-10-23 16:51:17 +00:00
|
|
|
service.AddTransient<Context>();
|
|
|
|
service.AddSingleton<FileExtractor.FileExtractor>();
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public void Configure(ILoggerFactory loggerFactory, ITestOutputHelperAccessor accessor)
|
|
|
|
{
|
|
|
|
loggerFactory.AddProvider(new XunitTestOutputLoggerProvider(accessor, delegate { return true; }));
|
2021-09-27 12:42:46 +00:00
|
|
|
}
|
|
|
|
}
|