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