wabbajack/Wabbajack.Compiler.Test/Startup.cs

54 lines
1.8 KiB
C#
Raw Normal View History

2022-08-22 15:34:19 +00:00
using System;
2021-09-27 12:42:46 +00:00
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
2022-08-22 15:34:19 +00:00
using Wabbajack.DTOs.Interventions;
using Wabbajack.Networking.Steam.UserInterventions;
2021-09-27 12:42:46 +00:00
using Wabbajack.Networking.WabbajackClientApi;
using Wabbajack.Services.OSIntegrated;
using Xunit.DependencyInjection;
using Xunit.DependencyInjection.Logging;
using Configuration = Wabbajack.Services.OSIntegrated.Configuration;
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
namespace Wabbajack.Compiler.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.AddOSIntegrated(o =>
2021-09-27 12:42:46 +00:00
{
2021-10-23 16:51:17 +00:00
o.UseLocalCache = true;
o.UseStubbedGameFolders = true;
});
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
service.AddScoped<ModListHarness>();
2022-08-22 15:34:19 +00:00
service.AddSingleton<IUserInterventionHandler, UserInterventionHandler>();
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
}
2022-08-22 15:34:19 +00:00
public class UserInterventionHandler : IUserInterventionHandler
{
public void Raise(IUserIntervention intervention)
{
if (intervention is GetAuthCode gac)
{
switch (gac.Type)
{
case GetAuthCode.AuthType.EmailCode:
Console.WriteLine("Please enter the Steam code that was just emailed to you");
break;
case GetAuthCode.AuthType.TwoFactorAuth:
Console.WriteLine("Please enter your 2FA code for Steam");
break;
default:
throw new ArgumentOutOfRangeException();
}
gac.Finish(Console.ReadLine()!.Trim());
}
}
}
2021-09-27 12:42:46 +00:00
}