2023-04-14 10:37:05 +00:00
|
|
|
|
using DistTestCore.Codex;
|
|
|
|
|
|
|
|
|
|
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-06-01 07:35:18 +00:00
|
|
|
|
private readonly TestLifecycle lifecycle;
|
2023-04-18 08:22:11 +00:00
|
|
|
|
private readonly MarketplaceNetwork marketplaceNetwork;
|
2023-04-14 10:37:05 +00:00
|
|
|
|
|
2023-06-01 07:35:18 +00:00
|
|
|
|
public GethMarketplaceAccessFactory(TestLifecycle lifecycle, MarketplaceNetwork marketplaceNetwork)
|
2023-04-14 10:37:05 +00:00
|
|
|
|
{
|
2023-06-01 07:35:18 +00:00
|
|
|
|
this.lifecycle = lifecycle;
|
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-06-01 07:35:18 +00:00
|
|
|
|
return new MarketplaceAccess(lifecycle, marketplaceNetwork, companionNode, access);
|
2023-04-14 10:37:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-03 08:21:15 +00:00
|
|
|
|
private GethAccount GetGethCompanionNode(CodexAccess access)
|
2023-04-14 08:51:35 +00:00
|
|
|
|
{
|
2023-05-03 08:21:15 +00:00
|
|
|
|
var account = access.Container.Recipe.Additionals.Single(a => a is GethAccount);
|
|
|
|
|
return (GethAccount)account;
|
2023-04-14 08:51:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|