IW4M-Admin/Tests/ApplicationTests/DepedencyInjectionExtensions.cs
RaidMax 92a26600af actually fix the session score concurrency issue
fix rare bug with shared guid kicker plugin
allow hiding of the connection lost notification
2020-04-22 18:46:41 -05:00

38 lines
1.4 KiB
C#

using ApplicationTests.Fixtures;
using FakeItEasy;
using IW4MAdmin;
using Microsoft.Extensions.DependencyInjection;
using SharedLibraryCore.Interfaces;
using SharedLibraryCore.Services;
namespace ApplicationTests
{
static class DepedencyInjectionExtensions
{
public static IServiceCollection BuildBase(this IServiceCollection serviceCollection)
{
var manager = A.Fake<IManager>();
var logger = A.Fake<ILogger>();
A.CallTo(() => manager.GetLogger(A<long>.Ignored))
.Returns(logger);
serviceCollection.AddSingleton(logger)
.AddSingleton(manager)
.AddSingleton(A.Fake<IRConConnectionFactory>())
.AddSingleton(A.Fake<IRConConnection>())
.AddSingleton(A.Fake<ITranslationLookup>())
.AddSingleton(A.Fake<IRConParser>())
.AddSingleton(A.Fake<IParserRegexFactory>())
.AddSingleton(A.Fake<ClientService>());
serviceCollection.AddSingleton(_sp => new IW4MServer(_sp.GetRequiredService<IManager>(), ConfigurationGenerators.CreateServerConfiguration(),
_sp.GetRequiredService<ITranslationLookup>(), _sp.GetRequiredService<IRConConnectionFactory>())
{
RconParser = _sp.GetRequiredService<IRConParser>()
});
return serviceCollection;
}
}
}