feat: mock run mode

extract IImageCapturerService interface from ImageCapturerService
add ImageCapturerMockService as implementation of IImageCapturerService
add --mock flag in command line interface and implement its usage
This commit is contained in:
2026-06-17 10:35:36 +03:00
parent 80856ba60d
commit 913805eb70
5 changed files with 107 additions and 25 deletions
+14 -4
View File
@@ -7,8 +7,7 @@ using Microsoft.Extensions.Logging.Console;
using GSS2.Core.Logging;
using GSS2.Core.Hardware;
using GSS2.Core.Analysis.AmineContent.Database.Calibration;
using GSS2.Core.Analysis.AmineContent.Database.Results;
using GSS2.Core.Analysis.AmineContent.Database;
using GSS2.Core.Analysis.AmineContent;
using ConsoleFormatter = GSS2.Core.Logging.ConsoleFormatter;
@@ -128,8 +127,19 @@ public static class DependencyInjectionHelper
ServiceLifetime.Singleton
);
public static IServiceCollection AddAmineContentImageCapturerService(this IServiceCollection services) => services
.AddSingleton<ImageCapturerService>();
public static IServiceCollection AddAmineContentImageCapturerService(this IServiceCollection services, bool mock = false)
{
if (!mock)
return services.AddSingleton<ImageCapturerService>();
return services.AddSingleton<ImageCapturerMockService>(serviceProvider =>
{
var logger = serviceProvider.GetService<ILogger<ImageCapturerMockService>>();
if (logger is null)
throw new Exception("Cannot get logger");
return new ImageCapturerMockService("./", logger);
});
}
public static IServiceCollection AddAmineContentAnalyzerService(this IServiceCollection services) => services
.AddSingleton<AnalyzerService>();