Move duplicate concrete IAbstractHttpClientFactorys to Common.HttpClientFactory

This commit is contained in:
Dominion
2023-04-23 13:57:57 -04:00
parent 43e1fec1b0
commit 4ecdf8afe1
15 changed files with 68 additions and 42 deletions
@@ -12,6 +12,7 @@ using Tgstation.Server.Api.Models;
using Tgstation.Server.Api.Models.Request;
using Tgstation.Server.Client;
using Tgstation.Server.Client.Components;
using Tgstation.Server.Common;
using Tgstation.Server.Host.Components.Byond;
using Tgstation.Server.Host.Configuration;
using Tgstation.Server.Host.IO;
@@ -102,21 +103,22 @@ namespace Tgstation.Server.Tests.Live.Instance
var generalConfigOptionsMock = new Mock<IOptions<GeneralConfiguration>>();
generalConfigOptionsMock.SetupGet(x => x.Value).Returns(new GeneralConfiguration());
var byondInstaller = new PlatformIdentifier().IsWindows
? (IByondInstaller)new WindowsByondInstaller(
var assemblyInformationProvider = new AssemblyInformationProvider();
var fileDownloader = new FileDownloader(
new HttpClientFactory(assemblyInformationProvider.ProductInfoHeaderValue),
Mock.Of<ILogger<FileDownloader>>());
IByondInstaller byondInstaller = new PlatformIdentifier().IsWindows
? new WindowsByondInstaller(
Mock.Of<IProcessExecutor>(),
Mock.Of<IIOManager>(),
new FileDownloader(
new ConcreteHttpClientFactory(),
Mock.Of<ILogger<FileDownloader>>()),
fileDownloader,
generalConfigOptionsMock.Object,
Mock.Of<ILogger<WindowsByondInstaller>>())
: new PosixByondInstaller(
Mock.Of<IPostWriteHandler>(),
Mock.Of<IIOManager>(),
new FileDownloader(
new ConcreteHttpClientFactory(),
Mock.Of<ILogger<FileDownloader>>()),
fileDownloader,
Mock.Of<ILogger<PosixByondInstaller>>());
using var windowsByondInstaller = byondInstaller as WindowsByondInstaller;
@@ -1,10 +0,0 @@
using Tgstation.Server.Common;
using Tgstation.Server.Host.Utils;
namespace Tgstation.Server.Tests.Live.Instance
{
sealed class ConcreteHttpClientFactory : IAbstractHttpClientFactory
{
public IHttpClient CreateClient() => new HttpClient();
}
}