cs-codex-dist-tests/DistTestCore/Marketplace/MarketplaceAccessFactory.cs

43 lines
1.3 KiB
C#
Raw Normal View History

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;
private readonly MarketplaceNetwork marketplaceNetwork;
2023-04-14 10:37:05 +00:00
public GethMarketplaceAccessFactory(TestLog log, MarketplaceNetwork marketplaceNetwork)
2023-04-14 10:37:05 +00:00
{
this.log = log;
this.marketplaceNetwork = marketplaceNetwork;
2023-04-14 10:37:05 +00:00
}
public IMarketplaceAccess CreateMarketplaceAccess(CodexAccess access)
{
var companionNode = GetGethCompanionNode(access);
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
}
}
}