2023-04-14 10:37:05 +00:00
|
|
|
|
using DistTestCore.Codex;
|
|
|
|
|
using Logging;
|
|
|
|
|
|
|
|
|
|
namespace DistTestCore.Marketplace
|
2023-04-14 08:51:35 +00:00
|
|
|
|
{
|
|
|
|
|
public interface IMarketplaceAccessFactory
|
|
|
|
|
{
|
2023-04-14 10:37:05 +00:00
|
|
|
|
IMarketplaceAccess CreateMarketplaceAccess(CodexAccess access);
|
2023-04-14 08:51:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class MarketplaceUnavailableAccessFactory : IMarketplaceAccessFactory
|
|
|
|
|
{
|
2023-04-14 10:37:05 +00:00
|
|
|
|
public IMarketplaceAccess CreateMarketplaceAccess(CodexAccess access)
|
2023-04-14 08:51:35 +00:00
|
|
|
|
{
|
|
|
|
|
return new MarketplaceUnavailable();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class GethMarketplaceAccessFactory : IMarketplaceAccessFactory
|
|
|
|
|
{
|
2023-04-14 10:37:05 +00:00
|
|
|
|
private readonly TestLog log;
|
2023-04-18 08:22:11 +00:00
|
|
|
|
private readonly MarketplaceNetwork marketplaceNetwork;
|
2023-04-14 10:37:05 +00:00
|
|
|
|
|
2023-04-18 08:22:11 +00:00
|
|
|
|
public GethMarketplaceAccessFactory(TestLog log, MarketplaceNetwork marketplaceNetwork)
|
2023-04-14 10:37:05 +00:00
|
|
|
|
{
|
|
|
|
|
this.log = log;
|
2023-04-18 08:22:11 +00:00
|
|
|
|
this.marketplaceNetwork = marketplaceNetwork;
|
2023-04-14 10:37:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IMarketplaceAccess CreateMarketplaceAccess(CodexAccess access)
|
|
|
|
|
{
|
|
|
|
|
var companionNode = GetGethCompanionNode(access);
|
2023-04-18 13:33:12 +00:00
|
|
|
|
return new MarketplaceAccess(log, marketplaceNetwork, companionNode, access);
|
2023-04-14 10:37:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private GethCompanionNodeInfo GetGethCompanionNode(CodexAccess access)
|
2023-04-14 08:51:35 +00:00
|
|
|
|
{
|
2023-04-14 10:37:05 +00:00
|
|
|
|
var node = access.Container.Recipe.Additionals.Single(a => a is GethCompanionNodeInfo);
|
|
|
|
|
return (GethCompanionNodeInfo)node;
|
2023-04-14 08:51:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|